Example #1
0
    private void SpawnPeloton()
    {
        preparingPeloton = true;

        //GameObject newPeloton = new GameObject();
        GameObject newPeloton = (GameObject)GameObject.Instantiate((GameObject)Resources.Load("Prefabs/Peloton"), transform.position, Quaternion.identity);
        //newPeloton.name = leaderOwner.name + "Peloton";
        newPeloton.name = leaderOwner.name == Names.PLAYER_LEADER ? Names.PLAYER_PELOTON : Names.ENEMY_PELOTON;
        newPeloton.GetComponent<BehaviourTree>().enabled = false;
        //currentPeloton = newPeloton.AddComponent<Peloton>();
        currentPeloton = newPeloton.GetComponent<Peloton>();
        currentPeloton.SetLeader(leaderOwner);                                      //Leader
        newPeloton.transform.position = transform.position;                         //Posición Inicial
        AIManager.staticManager.AddPeloton(currentPeloton);                                       //Avisar al AIManager
        currentPeloton.SetObjective("Spawning");                                    //Objetivo
        //currentPeloton = newPelotonScript;
    }
Example #2
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 #3
0
 private void RemoveEnemyPeloton(Peloton p)
 {
     enemyTeam.Remove(p);
 }
Example #4
0
 public void AddPeloton(Peloton peloton)
 {
     if (peloton.gameObject.name == Names.PLAYER_PELOTON || peloton.gameObject.name == Names.PLAYER_LEADER_PELOTON) playerTeam.Add(peloton);
     else enemyTeam.Add(peloton);
 }
Example #5
0
 private void AddPlayerPeloton(Peloton peloton)
 {
     playerTeam.Add(peloton);
 }
Example #6
0
 private void AddEnemyPeloton(Peloton peloton)
 {
     enemyTeam.Add(peloton);
 }
Example #7
0
 public List<Peloton> GetNeighbourPelotons(Peloton peloton)
 {
     List<Peloton> neighbours = new List<Peloton>();
     if(peloton.gameObject.name == Names.PLAYER_LEADER_PELOTON || peloton.gameObject.name == Names.PLAYER_PELOTON)
     {
         foreach(Peloton p in playerTeam)
         {
             if (p != null && peloton != null && p != peloton && Vector3.Distance(p.transform.position, peloton.transform.position) < MERGE_DISTANCE)
                 neighbours.Add(p);
         }
     }
     else
     {
         foreach (Peloton p in enemyTeam)
         {
             if (p != null && peloton != null && p != peloton && Vector3.Distance(p.transform.position, peloton.transform.position) < MERGE_DISTANCE)
                 neighbours.Add(p);
         }
     }
     return neighbours;
 }
Example #8
0
 public List<Peloton> GetNearbyEnemies(Peloton peloton)
 {
     List<Peloton> neighbours = new List<Peloton>();
     if (peloton.GetLeader().name == Names.PLAYER_LEADER)
     {
         foreach (Peloton p in enemyTeam)
         {
             if (p != null && peloton != null && p != peloton && Vector3.Distance(p.transform.position, peloton.transform.position) < WATCH_DISTANCE)
                 neighbours.Add(p);
         }
     }
     else
     {
         foreach (Peloton p in playerTeam)
         {
             if (p != null && peloton != null && p != peloton && Vector3.Distance(p.transform.position, peloton.transform.position) < WATCH_DISTANCE)
                 neighbours.Add(p);
         }
     }
     return neighbours;
 }
Example #9
0
 public bool HasSameObjective(Peloton otherObjective)
 {
     if (otherObjective.objective == objective) {
         switch (objective)
         {
             case Names.OBJECTIVE_DEFEND:
                 return Vector3.Distance(otherObjective.targetPosition, targetPosition) < 10f;
             case Names.OBJECTIVE_ATTACK:
                 return otherObjective.targetElement.Equals(targetElement);
             case Names.OBJECTIVE_ATTACK_CAMP:
                 return otherObjective.targetElement.Equals(targetElement);
             case Names.OBJECTIVE_ATTACK_DOOR:
                 return otherObjective.targetElement.Equals(targetElement);
             case Names.OBJECTIVE_FOLLOW_LEADER:
                 return otherObjective.leader == leader;
             case Names.OBJECTIVE_CONQUER:
                 return otherObjective.targetElement.Equals(targetElement);
             case Names.OBJECTIVE_PUSH:
                 return true;
         }
     }
     return false;
 }
Example #10
0
    // Use this for initialization
    void Start()
    {
        thisMinion = gameObject.GetComponent<Minion>();
        pelotonObject = thisMinion.peloton.gameObject;
        peloton = pelotonObject.GetComponent<Peloton>();
        leader = gameObject.GetComponent<Minion>().peloton.GetLeader();
        leaderScript = AIManager.staticManager.GetLeaderByName(leader.name);

        animator = gameObject.GetComponent<Animator>();
    }
Example #11
0
 public void SetPeloton(Peloton p)
 {
     peloton = p;
     pelotonFollowing.pelotonObject = p.gameObject;
     pelotonFollowing.peloton = p;
     gameObject.name = (peloton.leader.name == Names.PLAYER_LEADER ? Names.PLAYER_MINION : Names.ENEMY_MINION);
 }
Example #12
0
 // Called when the owner (BehaviourTree or ActionState) is enabled
 public override void OnEnable()
 {
     base.OnEnable();
     peloton = this.self.gameObject.GetComponent<Peloton>();
     fruit = GameObject.Find("Fruit").GetComponent<Fruit>();
 }
Example #13
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();
         }
     }
 }
Example #14
0
 public void PushFuit(Peloton peloton)
 {
     GameObject.Find("Fruit").GetComponent<Fruit>().pushMelon(peloton);
 }
Example #15
0
 private void RemovePlayerPeloton(Peloton p)
 {
     playerTeam.Remove(p);
 }
 public Task <SettingsPelotonGetResponse> SettingsPelotonPostAsync(Peloton pelotonSettings)
 {
     return($"{_apiUrl}/api/settings/peloton"
            .PostJsonAsync(pelotonSettings)
            .ReceiveJson <SettingsPelotonGetResponse>());
 }
Example #17
0
 // Called when the owner (BehaviourTree or ActionState) is enabled
 public override void OnEnable()
 {
     base.OnEnable();
     peloton = this.self.gameObject.GetComponent<Peloton>();
 }
Example #18
0
    // Use this for initialization
    public virtual void Start()
    {
        meshRenderer = GetComponentInChildren<SkinnedMeshRenderer>();
        initPos = transform.position;
        initRot = transform.eulerAngles;

        anim = GetComponent<Animator>();
        skinnedMesh = transform.FindChild("Onion").GetComponent<SkinnedMeshRenderer>();

        behind = transform.position + transform.forward * -BEHIND_DIST;

        GameObject leaderPeloton = new GameObject();
        leaderPeloton.name = gameObject.name + "Peloton";
        myPeloton = leaderPeloton.AddComponent<Peloton>();
        myPeloton.SetLeader(gameObject);                                    //Leader
        myPeloton.SetObjective(Names.OBJECTIVE_FOLLOW_LEADER, gameObject);  //Objetivo
        myPeloton.transform.position = behind;                              //Posición Inicial
        //aiManager.AddPlayerPeloton(myPeloton);                            //Avisar al AIManager

        leaderFlag = GameObject.Find(gameObject.name + "Flag");

        leaderTarget = gameObject;
        //SetLeaderPelotonState(Names.STATE_FOLLOW_LEADER, leaderTarget);
    }