Пример #1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Ball")
     {
         if (ball.GetBallGotenBot() == -1)
         {
             other.gameObject.GetComponent <BallScript>().SetBallGottenBot(order);
             ball.GetComponent <MeshRenderer>().enabled = false;
             transform.Find("Hightlight").gameObject.SetActive(true);
             GetComponent <Animator>().SetFloat("runningSpd", 0.4f);
         }
     }
     else if (other.gameObject.tag == "Wall")
     {
         GetComponent <Animator>().SetTrigger("die");
         other.gameObject.GetComponent <WallScript>().DestroyBot(order);
     }
     else if (other.gameObject.tag == "Bot")
     {
         if (ball.GetBallGotenBot() == order && deactiveTime == System.DateTime.MinValue && other.gameObject.GetComponent <DefBotScript>().getDeactiveTime() == System.DateTime.MinValue)
         {
             deactiveTime = System.DateTime.Now;
             other.gameObject.GetComponent <DefBotScript>().setDeactiveTime(deactiveTime);
             other.gameObject.transform.Find("Aoe").gameObject.GetComponent <MeshRenderer>().enabled = false;
             transform.Find("Hightlight").gameObject.SetActive(false);
             transform.Find("Arrow").gameObject.SetActive(false);
             GetComponent <Animator>().SetBool("isRunning", false);
             transform.Find("Alpha_Surface").gameObject.GetComponent <SkinnedMeshRenderer>().material.color = Color.grey;
             if (ball.GetComponent <BallScript>().GetAttackerList().Count > 1)
             {
                 ball.GetComponent <BallScript>().SetBallGottenBot(-1);
                 ball.GetComponent <BallScript>().SetNearestAttacker(-1);
                 ball.GetComponent <MeshRenderer>().enabled = true;
             }
         }
     }
     else if (other.gameObject.tag == "Aoe")
     {
         other.gameObject.GetComponentInParent <DefBotScript>().AddTarget(order);
     }
     else if (other.gameObject.tag == "Goal")
     {
         if (ball.GetBallGotenBot() == order)
         {
             ball.AttackWin();
         }
     }
 }
Пример #2
0
 public void Move(List <GameObject> attackerList, float moveSpd, float returnSpd)
 {
     if (deactiveTime == System.DateTime.MinValue)
     {
         target = -1;
         for (int i = 0; i < targetList.Count; i++)
         {
             if (targetList[i] == ball.GetBallGotenBot())
             {
                 target = targetList[i];
                 break;
             }
         }
         if (target > -1)
         {
             if (attackerList[target].GetComponent <BotScript>().getDeactiveTime() == System.DateTime.MinValue)
             {
                 GetComponent <Animator>().SetBool("isRunning", true);
                 targetPos          = new Vector3(attackerList[target].transform.position.x, attackerList[target].transform.position.y, attackerList[target].transform.position.z);
                 transform.rotation = Quaternion.LookRotation(targetPos - transform.position);
                 transform.position = Vector3.MoveTowards(transform.position, targetPos, 0.05f);
             }
             else if (transform.position != orgPos)
             {
                 GetComponent <Animator>().SetBool("isRunning", true);
                 transform.rotation = Quaternion.LookRotation(orgPos - transform.position);
                 transform.position = Vector3.MoveTowards(transform.position, orgPos, 0.1f);
             }
         }
         else if (transform.position != orgPos)
         {
             GetComponent <Animator>().SetBool("isRunning", true);
             transform.rotation = Quaternion.LookRotation(orgPos - transform.position);
             transform.position = Vector3.MoveTowards(transform.position, orgPos, 0.1f);
         }
     }
     else
     {
         if (transform.position != orgPos)
         {
             GetComponent <Animator>().SetBool("isRunning", true);
             transform.rotation = Quaternion.LookRotation(orgPos - transform.position);
             transform.position = Vector3.MoveTowards(transform.position, orgPos, 0.1f);
         }
         if ((System.DateTime.Now - deactiveTime).Seconds >= 4)
         {
             transform.Find("Aoe").gameObject.GetComponent <MeshRenderer>().enabled = true;
             deactiveTime = System.DateTime.MinValue;
             transform.Find("Beta_Surface").gameObject.GetComponent <SkinnedMeshRenderer>().material.color = originalColor;
         }
     }
 }