void FixedUpdate() { if (health > 0) // If health is greater than 0 { if (Time.time > initialTime) // And the current time is higher than the initialTime { initialTime++; // Incriment initialTime health--; // Decrement health } } if (health <= 0) // If health is less than or equal to 0... { second = 1.0f; // Make sure second is equal to one second again... health = 60; // Make sure health is equal to 60 again... SetTime(); // Call the SetTime() function switcher.DeleteYokai(GameObject.Find("Yokai(Clone)")); // Delete the current instance of the Yokai prefab invisibleObjects.SetInvisible(); // Toggle SetInvisible GameObject.Find("InputListener").GetComponent <InputListener>().SetYumiActive(true); // Toggle InputListener } }
void Update() { activePlayer = yumiActive ? human : yokai; // Choose which character to call movement methods on //Debug.Log(activePlayer + " is now active"); if ((Input.GetKey("a") || Input.GetKey("left")) && (Input.GetKey("d") || Input.GetKey("right"))) { activePlayer.CallLeft(false); activePlayer.CallRight(false); } else if (Input.GetKey("a") || Input.GetKey("left")) { activePlayer.CallLeft(true); activePlayer.CallRight(false); switcher.SetSpawnOffset(false); // If Yokai is spawned, do so on the left side of human } else if (Input.GetKey("d") || Input.GetKey("right")) { activePlayer.CallLeft(false); activePlayer.CallRight(true); switcher.SetSpawnOffset(true); // If Yokai is spawned, do so on the right side of human } else { activePlayer.CallLeft(false); activePlayer.CallRight(false); } // Jumping if (Input.GetKeyDown("w") || Input.GetKeyDown("up") || Input.GetKeyDown("space")) { activePlayer.CallJump(); } if (Input.GetKeyUp("w") || Input.GetKeyUp("up") || Input.GetKeyUp("space")) { activePlayer.CallShortHop(); } // Character Swap if (Input.GetKeyDown("f")) //Updated the mapping to "f" to be in line with most other games. 1-3 will be for spells. -Daniel Jaffe { if (GameObject.Find("Yokai(Clone)") == null) { switcher.SpawnYokai(); invisibleObjects.SetVisible(); yokai = GameObject.Find("Yokai(Clone)").GetComponent <PlayerController>(); activePlayer.ClearCalls(); SetYumiActive(false); } else { switcher.DeleteYokai(GameObject.Find("Yokai(Clone)")); invisibleObjects.SetInvisible(); SetYumiActive(true); } } // Spell Casting!!! (Finally-- lol) if (Input.GetKeyDown("1") && yumiActive) //Press 1 and start the earth spell { if (spellcaster.GetSpellStatus()) { spellcaster.DestroySpellSpawner(); } spellcaster.CallEarthSpell(); } if (Input.GetKeyDown("2") && yumiActive) //Press 2 and start the ice spell { if (spellcaster.GetSpellStatus()) { spellcaster.DestroySpellSpawner(); } spellcaster.CallIceSpell(); } if (Input.GetKeyDown("3") && yumiActive) //Press 3 and start the wind spell { if (spellcaster.GetSpellStatus()) { spellcaster.DestroySpellSpawner(); } spellcaster.CallWindSpell(); } if (Input.GetKeyDown("escape") || (!yumiActive && GameObject.Find("Yokai(Clone)") != null)) //Press escape and cancel out of spell casting mode. Also cancel if Yokai is spawned. { spellcaster.DestroySpellSpawner(); } }