public void Reset() { CurrentBehaviour.OnActionFinished(); SetAction(((int)AIToadController.Action.None)); SetDecidedAction(((int)AIToadController.Action.None)); SetBehaviour(((int)AIToadController.Behaviour.Passive)); m_MakeDecision = false; m_AiActive = false; EnableColliders(true); m_NumberOfAttacks = 0; m_HitPlayer = false; m_GoToPillar = false; m_ToadBoss.TargetForComboFront.SetActive(true); m_ToadBoss.TargetForComboFront.GetComponent <ComboTarget>().Reset(); m_ToadBoss.TargetForComboLeft.SetActive(true); m_ToadBoss.TargetForComboLeft.GetComponent <ComboTarget>().Reset(); m_ToadBoss.TargetForComboRight.SetActive(true); m_ToadBoss.TargetForComboRight.GetComponent <ComboTarget>().Reset(); m_ToadBoss.m_Marked = false; transform.position = m_JumpPosition[3].transform.position; m_ToadBoss.m_MaxHealth = 500.0f; m_ToadBoss.SetCurrentHealthAsMaxHealth(); m_MaxHealth = Constants.ToadMaxHealth; m_CurrentHealth = m_MaxHealth; transform.rotation = initalRotaton; }
public override void Execute() { if (CurrentBehaviour != null) { Transform playerTransform = Target.transform; Behaviour aiBehaviour = current; float dist = Vector2.Distance(playerTransform.position, transform.position); if (CurrentBehaviour.GetType() == typeof(Aggro) && dist <= activeRange) { CurrentBehaviour.Execute(playerTransform.position); } else if (CurrentBehaviour.GetType() == typeof(Patrol) && dist <= activeRange) { CurrentBehaviour.Execute(patrolPath); if (Vector2.Distance(patrolPath, transform.position) <= relativeRange) { patrolPath = GenerateRandom(Camera.main); CurrentBehaviour.Execute(patrolPath, cooldownTimer.GetDownTime()); if (dist <= activeRange) { CurrentBehaviour = new Aggro("aggro", this, activeRange, attackRange); } } } } }
public void SetCurrentBehaviour(int a_CurrentBehaviour) { switch (a_CurrentBehaviour) { case 0: m_CurrentBehaviour = CurrentBehaviour.None; break; case 1: m_CurrentBehaviour = CurrentBehaviour.Arrive; break; case 2: m_CurrentBehaviour = CurrentBehaviour.Flow; break; case 3: m_CurrentBehaviour = CurrentBehaviour.Path; break; default: m_CurrentBehaviour = CurrentBehaviour.Arrive; break; } }
private void UpdateSpeed(float horizontalMove) { if (behaviours.ContainsKey(currentHash) == false) { return; } currentSpeed = CurrentBehaviour.GetSpeed(horizontalMove); animator.SetFloat("Speed", Mathf.Abs(currentSpeed)); }
public void CurrentActionFinished() { // Set the Action Before Last as the previous action ActionBeforeLast = PreviousAction; // Set Previous action as current action PreviousAction = CurrentAction; CurrentBehaviour.OnActionFinished(); }
//private void SetDefaultNonParameterMemberVariables() //{ // //myGhostHealthState = GhostHealthState.Alive; // //ChangeState(new SAlive()); //} public void ChangeState(IGhostState aState) { if (CurrentBehaviour == aState) { return; } if (CurrentBehaviour != null) { CurrentBehaviour.Exit(this); } CurrentBehaviour = aState; aState.Enter(this); }
protected override Vector2?NextTarget() { //switch (myGhostHealthState) //{ // case GhostHealthState.Alive: // return GoToPosition(Player.Column, Player.Row); // case GhostHealthState.Scared: // return AvoidPosition(Player.Position); // case GhostHealthState.Dead: // return GoToPosition((int)SpawnPosition.X / Tile.Size, (int)SpawnPosition.Y / Tile.Size); //} //return null; return(CurrentBehaviour.FindPath(this)); }
// Update is called once per frame protected virtual void Update() { // If the AI is active, then update if (m_AiActive == true) { if (CurrentBehaviour != null) { // If the boss should make a decision if (m_MakeDecision == true) { CurrentBehaviour.Update(); } } // Always update the current action CurrentAction.Update(); } }
override protected void CalculateSourceRectangle(GameTime aGameTime) { myFrameTimeCounterMilliseconds -= aGameTime.ElapsedGameTime.Milliseconds; if (myFrameTimeCounterMilliseconds <= 0) { myFrameTimeCounterMilliseconds = myTimePerFrameMilliseconds; //switch (myGhostHealthState) //{ // case GhostHealthState.Alive: // ChangeSourceRectangleAlive(); // break; // case GhostHealthState.Scared: // ChangeSourceRectangleScared(); // break; // case GhostHealthState.Dead: // ChangeSourceRectangleDead(); // break; //} CurrentBehaviour.Execute(this); } }
protected override void Update() { base.Update(); //m_NavMeshAgent.destination = m_Player.transform.position; if (m_KingBoss.m_ShieldUp == true) { // m_Shield.SetActive(true); } if (m_KingBoss.m_ShieldUp == false) { // m_Shield.SetActive(false); } ShowDebugStuff(); // Enable the AI if the plater gets close if (GetDistanceToPlayer() < 50.0f && m_AiActive == false) { Services.GameManager.KingTriggered = true; m_AiActive = true; SetBehaviour((int)AIKingController.Behaviour.Offensive); SetAction((int)AIKingController.Action.None); m_MakeDecision = true; } // Enable the AI with button press if (Input.GetKeyDown("n")) { m_AiActive = true; SetBehaviour((int)AIKingController.Behaviour.Passive); SetAction((int)AIKingController.Action.Dodge); //SetNextAction((int)AIKingController.Action.DuelMove); // m_MakeDecision = true; //m_Animator.SetTrigger("t_Vertical_Swing"); } // If the AI is active if (m_AiActive == true) { // If the player enters the pillars and the current beahviour isint pillar //if (m_LeftPillars.m_IsPlayerinside == true || m_RightPillars.m_IsPlayerinside == true && !IsCurrentAction((int)AIKingController.Behaviour.Pillar)) //{ // // Change the behaviour to pillar // SetBehaviour((int)AIKingController.Behaviour.Pillar); //} // If the Duel Behaviour is true and the behaviour isin't dueling if (m_IsDueling == true && !IsCurrentBehaviour((int)Behaviour.Dueling)) { // Set Dueling to false and restart the Fire Circle cooldown m_IsDueling = false; FireCirlceCooldownTimer.Restart(); } if (IsCurrentBehaviour((int)AIKingController.Behaviour.Offensive)) { // If the king is walking if (IsCurrentAction((int)AIKingController.Action.Walk)) { // If the boss reaches melee range if (GetDistanceToPlayer() < Constants.MeleeRange) { // Reset the walk and finish the action so the behaviour will choose the melee attack or continue walking CurrentAction.Start(); CurrentBehaviour.OnActionFinished(); } } } // If the player and the king are in the center of the room if (m_RoomCenter.m_IsKingInside == true && m_RoomCenter.m_IsPlayerinside == true && m_IsDueling == false && FireCirlceCooldownTimer.IsFinished() && IsCurrentAction((int)AIKingController.Action.Walk)) { // If the player is within range to start the duel if (GetDistanceToPlayer() < 15.0f && GetDistanceToPlayer() > 8.0f) { // Set the action to summon fire circle and switch behaviour to dueling SetBehaviour((int)AIKingController.Behaviour.Dueling); SetAction((int)AIKingController.Action.FireCircle); m_IsDueling = true; FireCircleLengthTimer.Restart(); } } } //// If the boss hit the player //if (m_HitPlayer == true) //{ // // Set hit to false so it only will be true for one frame // m_HitPlayer = false; //} }
public void SetBehaviour(int aBehaviour) { CurrentBehaviour = m_AIBehaviours[aBehaviour]; CurrentBehaviour.Start(); }