public static State_Player_Idle Instantiate() { if (instance == null) { instance = new State_Player_Idle(); } return(instance); }
public override void Execute(PlayerManager obj) { // If the player die if (obj.IsDead()) { obj.GetFSM().ChangeState(State_Player_Die.Instantiate()); } // Loop function during useskill state obj.UseSkill(); // If there is any move input, to move state if (Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxisRaw("Vertical") != 0) { obj.GetFSM().ChangeState(State_Player_Move.Instantiate()); } // Else to idle state else { obj.GetFSM().ChangeState(State_Player_Idle.Instantiate()); } }
/// <summary> /// Init of the player /// </summary> /// <param name="inWorld"></param> public void PlayerPlusInit(bool inWorld) { InWorld = inWorld; _playerMovement = GetComponent <PlayerMovement>(); _playerMovement.initialSpeed = MoveSpeed; _playerMovement.enabled = false; _sm_player = new StateMachine <PlayerManager>(this); _sm_player.SetCurrentState(State_Player_Idle.Instantiate()); _sphereCollider = GetComponent <SphereCollider>(); _sphereCollider.enabled = true; _anim = GetComponent <Animator>(); if (InWorld) { _sphereCollider.enabled = false; Debug.Log("Inworld."); return; } _playerHealth = GetComponent <PlayerHealth>(); _playerHealth.MaxHealth = _playerHealth.CurrentHealth = Health; _playerHealth.RecoverRate = HealthRecoverRatePerMin; _playerHealth.enabled = true; _playerMagic = GetComponent <PlayerMagic>(); _playerMagic.MaxMagic = _playerMagic.CurrentMagic = Magic; _playerMagic.RecoverRate = MagicRecoverRatePerMin; _playerMagic.enabled = true; _playerShooting = GetComponentInChildren <PlayerShooting>(); _playerShooting.bulletMagicValue = SkillMagic; //_playerShooting.enabled = false; //_playerShooting.enabled = true; _enemyListSize = GameObject.FindGameObjectWithTag("InstanceManager").GetComponent <EnemySpawnManager>().enemies.Length; _playerKillCounter = GetComponent <PlayerKillCounter>(); _playerKillCounter.Length = _enemyListSize; _playerKillCounter.enabled = true; }
public override void Execute(PlayerManager obj) { // If the player dies if (obj.IsDead()) { obj.GetFSM().ChangeState(State_Player_Die.Instantiate()); } // The loop function during the move state obj.Move(); // If there is no input detected, change to idle state if (Input.GetAxisRaw("Horizontal") == 0 || Input.GetAxisRaw("Vertical") == 0) { obj.GetFSM().ChangeState(State_Player_Idle.Instantiate()); } // Cannot shoot if in the World Scene if (!obj.InWorld) { if (Input.GetButton("Fire1")) { obj.GetFSM().ChangeState(State_Player_UseSkill.Instantiate()); } } }