all repos — RPG @ c94129d3dfd5f33cc122a2ecd284319917b4d0a4

Fully functional 3D turn based role playing game coded in C# and base Unity.

fix bad spawns
Marco Andronaco andronacomarco@gmail.com
Thu, 16 Apr 2020 18:06:48 +0200
commit

c94129d3dfd5f33cc122a2ecd284319917b4d0a4

parent

0d2b7dd3aa83d4e0ad258b02569c7e84be40b803

2 files changed, 5 insertions(+), 27 deletions(-)

jump to
M Assets/Scripts/Battle/Fighters/Brady.csAssets/Scripts/Battle/Fighters/Brady.cs

@@ -24,20 +24,11 @@ Ability ability;

Fighter target; do { res = Random.Range(1, 101); - Debug.Log(res); if (res < 70) { output = true; //attack - Fighter[] ggs = GameObject.Find("BattleManager").GetComponent<BattleManager>().getGuys(false); //TODO: try FindObjectOfType - - /* - List<Fighter> goodGuys = new List<Fighter>(); - foreach(Fighter f in ggs){ - if(!f.dead) - goodGuys.Add(f); - } - */ + Fighter[] ggs = GameObject.FindObjectOfType<BattleManager>().getGuys(false); target = ggs[Random.Range(0, ggs.Length)];
M Assets/Scripts/Utility/GameMaster.csAssets/Scripts/Utility/GameMaster.cs

@@ -23,8 +23,6 @@

[Header("Inventory")] public int gold = 0; public Inventory inventory; - public bool loaded = false; - public int currentLevel = 0; #endregion #region Private

@@ -124,25 +122,16 @@

#region Battaglia vinta o ritorno all'overworld case "Level0": case "Level1": - case "Level2": player = FindObjectOfType<NoJumpController>().gameObject; - if (fighting == "") //first spawn - { - if (!loaded) - { - lastPosition = player.transform.position; - lastRotation = player.transform.rotation; - } - } - else + if (fighting != "") { //return from battle foreach (string enemy in killedEnemies) { GameObject.Find(enemy).SetActive(false); } + player.transform.SetPositionAndRotation(lastPosition, lastRotation); } - player.transform.SetPositionAndRotation(lastPosition, lastRotation); break; #endregion

@@ -217,13 +206,12 @@ save.rot1 = t.rotation.y;

save.rot2 = t.rotation.z; save.rot3 = t.rotation.w; save.timerfloat = timer; - Debug.Log("saving scene Level" + currentLevel + ", fighting: " + fighting); + //Debug.Log("saving scene Level" + currentLevel + ", fighting: " + fighting); return save; } public void LoadManager(int cl, List<string> ke, int g, Dictionary<string, Stats> p, Inventory i, string f, Vector3 pos, Quaternion rot, float timerfloat) { - loaded = true; currentLevel = cl; killedEnemies = ke; gold = g;

@@ -233,12 +221,11 @@ fighting = f;

lastPosition = pos; lastRotation = rot; timer = timerfloat; - Debug.Log("loading scene Level" + currentLevel + ", fighting: " + fighting); + //Debug.Log("loading scene Level" + currentLevel + ", fighting: " + fighting); } public void resetGame() { - loaded = false; currentLevel = 0; killedEnemies = new List<string>(); gold = 0;