public virtual void Init(bool isPlayerOne, GameObject otherFighter) { GameObject canvas = GameObject.FindGameObjectWithTag("Canvas"); gameManager = GameObject.FindGameObjectWithTag("Game Manager").GetComponent <GameManager>(); rb = GetComponent <Rigidbody>(); this.isPlayerOne = isPlayerOne; this.otherFighter = otherFighter; otherFighterController = otherFighter.GetComponent <FighterController>(); fighterControllerState = FighterControllerState.DetermineFighterControllerState(this); if (isPlayerOne) { controllerInput = ControllerManager.GetControllerInput(1); fighterUI = canvas.transform.GetChild(0).GetComponent <FighterUI>(); } else { controllerInput = ControllerManager.GetControllerInput(2); fighterUI = canvas.transform.GetChild(1).GetComponent <FighterUI>(); } anim = GetComponent <Animator>(); attackManager = GetComponent <AttackManager>(); attackManager.Init(); fighterUI.Init(); startingPosition.Set(transform.position.x, transform.position.y, transform.position.z); startingRotation.Set(transform.rotation.x, transform.rotation.y, transform.rotation.z, transform.rotation.w); startingScale.Set(transform.localScale.x, transform.localScale.y, transform.localScale.z); }
public static FighterControllerState DetermineFighterControllerState(FighterController fighterController) { FighterControllerState fighterControllerState = null; if (fighterController.IsPlayerOne() || GameData.GetPlayers() == 2) { fighterControllerState = new PlayerControllerState(); } else { switch (GameData.GetComputerDifficulty()) { case Difficulty.Easy: fighterControllerState = new EasyAiControllerState(); break; case Difficulty.Medium: fighterControllerState = new MediumAiControllerState(); break; case Difficulty.Hard: fighterControllerState = new HardAiControllerState(); break; } } fighterControllerState.Init(fighterController); return(fighterControllerState); }