public BossAttacks WillAttack() { int w = 0; List <BossAttacks> l = new List <BossAttacks>(); for (int i = 0; i < ai_attacks.Length; i++) { BossAttacks a = ai_attacks[i]; if (a.cool > 0) { States.AgentAI.isStopped = true; continue; } States.AgentAI.isStopped = false; // States.MoveAnimations(); // GoToTarget(); if (Dis > a.MinDistance) { continue; } if (_angle < a.minAngle) { continue; } if (_angle > a.maxAngle) { continue; } if (a.Weight == 0) { continue; } w += a.Weight; l.Add(a); } if (l.Count == 0) { return(null); } int ran = Random.Range(0, w + 1); int C_W = 0; for (int i = 0; i < l.Count; i++) { C_W += l[i].Weight; if (C_W > ran) { return(l[i]); } } return(null); }
void HandleCoolDown() { for (int i = 0; i < ai_attacks.Length; i++) { BossAttacks a = ai_attacks[i]; if (a.cool > 0) { //States.anim.SetFloat("EenmyMOve", -1); States.anim.Play(BLock); a.cool -= Delta; if (a.cool < 0) { a.cool = 0; } } } }
public void In_Sight() { States.RotateToTarget = true; HandleCoolDown(); float disToDes = Vector3.Distance(States.TargetDestination, target.position); if (disToDes > 2 || Dis > Sight * 0.5) { GoToTarget(); } if (Dis < 2) { States.AgentAI.isStopped = true; } if (_AttackCount > 0) { _AttackCount--; return; } _AttackCount = AttackCount; BossAttacks a = WillAttack(); if (a != null) { States.anim.applyRootMotion = true; // States.AgentAI.enabled = false; _AiStates = AIstates.Attacking; States.anim.Play(a.targetAnim); States.CanMove = false; a.cool = a.CoolDown; States.AgentAI.isStopped = true; return; } }