Merge branch 'melania-dev'

This commit is contained in:
KrolMel 2022-10-01 18:08:38 +02:00
commit 968e16fc9f
23 changed files with 27380 additions and 12483 deletions

View File

@ -51,6 +51,7 @@
<Compile Include="Assets\LetterText.cs" /> <Compile Include="Assets\LetterText.cs" />
<Compile Include="Assets\Scripts\SceneManager\SceneTaskManager.cs" /> <Compile Include="Assets\Scripts\SceneManager\SceneTaskManager.cs" />
<Compile Include="Assets\Scripts\SettingsButton.cs" /> <Compile Include="Assets\Scripts\SettingsButton.cs" />
<Compile Include="Assets\Scripts\SceneManager\MainCharacter\MainCharacterManager.cs" />
<Compile Include="Assets\Scripts\UI\ISlot.cs" /> <Compile Include="Assets\Scripts\UI\ISlot.cs" />
<Compile Include="Assets\Scripts\Enemies&apos; Scprits\Enemy.cs" /> <Compile Include="Assets\Scripts\Enemies&apos; Scprits\Enemy.cs" />
<Compile Include="Assets\Scripts\Objects\GoldOre.cs" /> <Compile Include="Assets\Scripts\Objects\GoldOre.cs" />

8
Assets/Resources.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3ee6e7ceeba1b814cb5310e2f2eaf155
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4cb7163e44af59f4c9350005c199db3c
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,10 @@ public class DoorBehaviour : MonoBehaviour
public string SceneName = "SampleScene"; public string SceneName = "SampleScene";
public GameObject SaveController; public GameObject SaveController;
[SerializeField]
public Gateway gateway;
private void Awake() private void Awake()
{ {
if(Instance == null) if(Instance == null)
@ -34,7 +38,17 @@ public class DoorBehaviour : MonoBehaviour
public void ScenetToMoveTo() public void ScenetToMoveTo()
{ {
// 1. Save all befor change scene //saving info about used gate/door/teleport
OnMapAppearanceMethod.Gateway = OnMapAppearanceMethodEnum.Gateway;
PlayerPrefs.SetString("gateway.sourceMapName", gateway.currentMapName);
PlayerPrefs.SetString("gateway.nextMapName", gateway.nextMapName);
PlayerPrefs.SetFloat("gateway.respawnCoords.x", gateway.respawnCoords.x);
PlayerPrefs.SetFloat("gateway.respawnCoords.y", gateway.respawnCoords.y);
PlayerPrefs.SetFloat("gateway.respawnCoords.z", gateway.respawnCoords.z);
// 1. Save all before change scene
SaveController.GetComponent<SaveController>().SaveItems(); SaveController.GetComponent<SaveController>().SaveItems();
SaveController.GetComponent<SaveController>().SaveQuests(); SaveController.GetComponent<SaveController>().SaveQuests();
SaveController.GetComponent<SaveController>().SaveInventory(); SaveController.GetComponent<SaveController>().SaveInventory();

View File

@ -57,7 +57,9 @@ public class FollowingEnemy : Enemy
} }
myRigidbody = GetComponent<Rigidbody2D>(); myRigidbody = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>(); anim = GetComponent<Animator>();
target = GameObject.FindWithTag("Player").transform; target = GameObject.FindWithTag("Player").transform;
other = GameObject.FindWithTag("Player");
} }
// Update is called once per frame // Update is called once per frame

View File

@ -62,6 +62,7 @@ public class FollowingPatrollingEnemy : Enemy
myRigidbody = GetComponent<Rigidbody2D>(); myRigidbody = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>(); anim = GetComponent<Animator>();
target = GameObject.FindWithTag("Player").transform; target = GameObject.FindWithTag("Player").transform;
other = GameObject.FindWithTag("Player");
} }
// Update is called once per frame // Update is called once per frame

View File

@ -1,6 +1,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using System.Linq;
public class Player : MonoBehaviour public class Player : MonoBehaviour
{ {
@ -45,6 +46,8 @@ public class Player : MonoBehaviour
void Start() void Start()
{ {
Panel = GameObject.FindObjectsOfType<GameObject>(true).Where(sr => sr.gameObject.name == "YouDied").ToArray()[0];
healthBar = (HealthBar)FindObjectOfType<HealthBar>();
int continued = PlayerPrefs.GetInt("continued"); int continued = PlayerPrefs.GetInt("continued");
if (continued == 1) if (continued == 1)
{ {
@ -59,13 +62,16 @@ public class Player : MonoBehaviour
healthBar.SetMaxHealth(maxHealth.initialValue); healthBar.SetMaxHealth(maxHealth.initialValue);
healthBar.SetHealth(currentHealth); healthBar.SetHealth(currentHealth);
walkSpeed = 4f; walkSpeed = 4f;
currentHealth = 10;
} }
public void TakeDamage(float damage) public void TakeDamage(float damage)
{ {
currentHealth = currentHealth - damage; currentHealth = currentHealth - damage;
Debug.Log(currentHealth);
healthBar.SetHealth(currentHealth); healthBar.SetHealth(currentHealth);
var em = dmgParticleSystem.emission; var em = dmgParticleSystem.emission;
em.enabled = true; em.enabled = true;
StartCoroutine(Timer()); StartCoroutine(Timer());
@ -106,108 +112,108 @@ public class Player : MonoBehaviour
private void HandleInput() private void HandleInput()
{ {
if (Input.GetKeyDown(KeyCode.Space)) if (Input.GetKeyDown(KeyCode.Space))
{ {
attackSword = true; attackSword = true;
} }
if (Input.GetKeyDown(KeyCode.LeftShift)) if (Input.GetKeyDown(KeyCode.LeftShift))
{ {
attackFist = true; attackFist = true;
} }
if(Input.GetKeyDown(KeyCode.X)) if(Input.GetKeyDown(KeyCode.X))
{ {
pickaxeInUse = true; pickaxeInUse = true;
} }
}
private void ResetValues()
{
attackSword = false;
attackFist = false;
pickaxeInUse = false;
}
void Update()
{
//if (canWalk == true)
//{
inputHorizontal = Input.GetAxisRaw("Horizontal");
inputVertical = Input.GetAxisRaw("Vertical");
myAnimator.SetFloat("moveX", inputHorizontal * walkSpeed);
myAnimator.SetFloat("moveY", inputVertical * walkSpeed);
if (inputHorizontal != 0)
{
myAnimator.SetFloat("speed", walkSpeed);
}
else if (inputVertical != 0)
{
myAnimator.SetFloat("speed", walkSpeed);
}
else
{
myAnimator.SetFloat("speed", 0);
} }
if (inputHorizontal == 1 || inputHorizontal == -1 || inputVertical == 1 || inputVertical == -1) private void ResetValues()
{ {
myAnimator.SetFloat("lastMoveX", inputHorizontal); attackSword = false;
myAnimator.SetFloat("lastMoveY", inputVertical); attackFist = false;
pickaxeInUse = false;
} }
void Update()
{
//if (canWalk == true)
//{
inputHorizontal = Input.GetAxisRaw("Horizontal");
inputVertical = Input.GetAxisRaw("Vertical");
myAnimator.SetFloat("moveX", inputHorizontal * walkSpeed);
myAnimator.SetFloat("moveY", inputVertical * walkSpeed);
if (inputHorizontal != 0)
{
myAnimator.SetFloat("speed", walkSpeed);
}
else if (inputVertical != 0)
{
myAnimator.SetFloat("speed", walkSpeed);
}
else
{
myAnimator.SetFloat("speed", 0);
}
if (inputHorizontal == 1 || inputHorizontal == -1 || inputVertical == 1 || inputVertical == -1)
{
myAnimator.SetFloat("lastMoveX", inputHorizontal);
myAnimator.SetFloat("lastMoveY", inputVertical);
}
timerRegen += Time.deltaTime; timerRegen += Time.deltaTime;
if(timerRegen >= waitRegen) if(timerRegen >= waitRegen)
{
startRegen = true;
}
if (startRegen == true)
{
timerTick += Time.deltaTime;
if(timerTick >= waitTick)
{ {
if(currentHealth < 10) startRegen = true;
}
if (startRegen == true)
{
timerTick += Time.deltaTime;
if(timerTick >= waitTick)
{ {
currentHealth = currentHealth + 1; if(currentHealth < 10)
healthBar.SetHealth(currentHealth); {
timerTick = 0f; currentHealth = currentHealth + 1;
healthBar.SetHealth(currentHealth);
timerTick = 0f;
}
} }
} }
PlayerPrefs.SetFloat("health", currentHealth);
//}
HandleInput();
} }
PlayerPrefs.SetFloat("health", currentHealth);
//} void FixedUpdate()
HandleInput();
}
void FixedUpdate()
{
if(canWalk == true)
{
if (inputHorizontal != 0 || inputVertical != 0)
{ {
if (inputHorizontal != 0 && inputVertical != 0) if(canWalk == true)
{ {
inputHorizontal *= speedLimiter; if (inputHorizontal != 0 || inputVertical != 0)
inputVertical *= speedLimiter; {
if (inputHorizontal != 0 && inputVertical != 0)
{
inputHorizontal *= speedLimiter;
inputVertical *= speedLimiter;
}
rb.velocity = new Vector2(inputHorizontal * walkSpeed, inputVertical * walkSpeed);
}
else
{
rb.velocity = new Vector2(0f, 0f);
}
} }
rb.velocity = new Vector2(inputHorizontal * walkSpeed, inputVertical * walkSpeed);
HandleAttacks();
ResetValues();
} }
else
public void SaveCheckpoint()
{ {
rb.velocity = new Vector2(0f, 0f); PlayerPrefs.SetFloat("health-S", currentHealth);
} }
}
HandleAttacks();
ResetValues();
}
public void SaveCheckpoint()
{
PlayerPrefs.SetFloat("health-S", currentHealth);
}
} }

View File

@ -11,6 +11,7 @@ public class RespawnScript : MonoBehaviour
public void RespawnOnCurrentScene() public void RespawnOnCurrentScene()
{ {
mainCh = GameObject.FindGameObjectWithTag("Player");
Scene scene = SceneManager.GetActiveScene(); Scene scene = SceneManager.GetActiveScene();
currentScene = scene.name; currentScene = scene.name;
SceneManager.LoadScene(currentScene); SceneManager.LoadScene(currentScene);

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 56b5700f3ae9ef149bb959906fe6b684
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,105 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.SceneManagement;
using System;
public class MainCharacterManager : MonoBehaviour
{
[SerializeField]
public GameObject avatar;
[SerializeField]
public GameObject AvatarClone;
public Vector3 startPosition;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void Awake()
{
try
{
avatar = GetMainCharacterObject();
GameObject globalGUI = GameObject.FindGameObjectWithTag("GUI");
if (AvatarClone == null)
{
startPosition = InitCharacterPosition();
AvatarClone = GameObject.Instantiate(avatar, startPosition, Quaternion.identity);
}
}
catch (UnityException e)
{
Debug.Log(e);
}
//DynamicPanel.transform.localPosition = uiPanelTemplate.transform.position; // prevent overwritten position by... environment???
}
// Later here we will decide whether the player is loading a saved game, thus, a saved position
// In general we have 3 cases -> saved game and save position, new position on the map, and position after using teleport/door
private Vector3 InitCharacterPosition()
{
switch (OnMapAppearanceMethod.Gateway)
{
case OnMapAppearanceMethodEnum.Gateway:
{
if (SceneManager.GetActiveScene().name != PlayerPrefs.GetString("gateway.nextMapName") && PlayerPrefs.GetString("gateway.nextMapName") != "")
{
throw new Exception("Gateway says we should be somewhere else: " + PlayerPrefs.GetString("gateway.nextMapName"));
}
var x = PlayerPrefs.GetFloat("gateway.respawnCoords.x");
var y = PlayerPrefs.GetFloat("gateway.respawnCoords.y");
var z = PlayerPrefs.GetFloat("gateway.respawnCoords.z");
return new Vector3(x, y, z);
}
default:
{
return DefaultPlayerMapPosition();
}
}
}
private Vector3 DefaultPlayerMapPosition()
{
switch (SceneManager.GetActiveScene().name)
{
case "CaveEntrance":
{
return new Vector3(0.5f, -37, 10);
}
default:
{
return avatar.transform.position;
}
}
}
private GameObject GetMainCharacterObject()
{
/* Debug.Log("XDDDDD");
string[] obects = AssetDatabase.FindAssets("t:Object", new[] { "Assets/Resources/" });
foreach (string localObject in obects)
{
Debug.Log(AssetDatabase.GUIDToAssetPath(localObject));
}
return (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Resources/ThePlayer.prefab", typeof(GameObject));*/
return Resources.Load("ThePlayer") as GameObject;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e11719a854a3211459e4fb55658c64c3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum OnMapAppearanceMethodEnum
{
NewGame = 0,
LoadGame = 1,
Gateway = 2
//maybe respawn too
}
public class OnMapAppearanceMethod : MonoBehaviour
{
public static OnMapAppearanceMethodEnum Gateway { get; set; }
// every script which makes player appear somewhere should change this variable ! ! !
void Awake()
{
Gateway = OnMapAppearanceMethodEnum.NewGame;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9fbd4e55be86a9d49adcb35c89ee9c18
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SaveDynamicObjects : MonoBehaviour
{
public void Save()
{
//saving player position
var player = GameObject.FindGameObjectWithTag("Player");
player.GetComponent<PlayerPosition>().SavePosition();
player.GetComponent<Player>().SaveCheckpoint();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f284f94fc82ae2b48a2fed669d33ff24
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 76fee0239f055c44882bc4e8c4b2cd4c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.SceneManagement;
[Serializable]
public class Gateway
{
[SerializeField]
public int id;
[SerializeField]
public string currentMapName;
[SerializeField]
public Vector3 coords;
[SerializeField]
public string nextMapName; //name of the next map
[SerializeField]
public Vector3 respawnCoords; // coords on the next map
public Gateway(int _id, Vector3 _coords, string _nextMapName, Vector3 _respawnCoords)
{
id = _id;
currentMapName = SceneManager.GetActiveScene().name;
coords = _coords;
respawnCoords = _respawnCoords;
nextMapName = _nextMapName;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 95981f14d41640244a6706f1444f553d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -6,7 +6,7 @@ EditorUserSettings:
serializedVersion: 4 serializedVersion: 4
m_ConfigSettings: m_ConfigSettings:
RecentlyUsedScenePath-0: RecentlyUsedScenePath-0:
value: 22424703114646680e0b0227036c72111f19352f223d667d6d0a1532f0e1372ce7f518c8ea3f7129370bfb25 value: 22424703114646680e0b0227036c72111f19352f223d667d6d1a1226ece42776f7e93ffdfe
flags: 0 flags: 0
RecentlyUsedScenePath-1: RecentlyUsedScenePath-1:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d