Example #1
0
    public void pushMelon(Peloton peloton)
    {
        if (!AIManager.staticManager.EndGame)
        {
            pushed = true;
            if (!melonAudio.isPlaying) melonAudio.Play();
            int minionCount = peloton.GetMinionList().Count;
            if (!AIManager.staticManager.DisableElements) velocity = peloton.Size() * push_per_minion * (peloton.leader.GetComponent<Leader>().pushBuff > 0 ? peloton.leader.GetComponent<Leader>().BUFF_MULTIPLYER : 1f) * Time.deltaTime;
            else velocity = 0.5f;

            if (peloton.leader.name == Names.ENEMY_LEADER && canAdvanceToOrange)
            {
                velocity *= -1;
                angle = velocity / fruitMesh.GetComponent<SphereCollider>().radius;
                fruitMesh.transform.Rotate(angle / 2f, 0, 0);
                transform.position += new Vector3(0, 0, 1) * velocity;
                peloton.transform.position = purpleObjective.transform.position;
            }

            if (peloton.leader.name == Names.PLAYER_LEADER && canAdvanceToPurple)
            {
                angle = velocity / fruitMesh.GetComponent<SphereCollider>().radius;
                fruitMesh.transform.Rotate(angle / 2f, 0, 0);
                transform.position += new Vector3(0, 0, 1) * velocity;
                peloton.transform.position = orangeObjective.transform.position;
            }

            if (transform.position.z + radius < orangeDoor.transform.position.z && orangeDoor.GetComponent<Door>().doorsUp)
                canAdvanceToOrange = false;
            else canAdvanceToOrange = true;
            if (transform.position.z >= purpleDoor.transform.position.z - radius && purpleDoor.GetComponent<Door>().doorsUp)
                canAdvanceToPurple = false;
            else canAdvanceToPurple = true;

            if (AIManager.staticManager.DisableElements)
            {
                canAdvanceToOrange = true;
                canAdvanceToPurple = true;
            }
        }
    }
Example #2
0
 private void Merge(Peloton anotherPeloton)
 {
     if (!anotherPeloton.IsLeaderPeloton())
     {
         if (IsLeaderPeloton())
         {
             AddMinionList(anotherPeloton.GetMinionList());
             anotherPeloton.RemoveAllMinions();
             anotherPeloton.DestroyPeloton();
         }
         else if (this.Size() > anotherPeloton.Size() || (this.Size() == anotherPeloton.Size() && this.gameObject.GetInstanceID() > anotherPeloton.gameObject.GetInstanceID()))
         {
             AddMinionList(anotherPeloton.GetMinionList());
             anotherPeloton.RemoveAllMinions();
             anotherPeloton.DestroyPeloton();
         }
     }
 }