Esempio n. 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //Stop if you see another AI within range and start moving again when they are gone
        myRay = new Ray(transform.position, Vector3.right);
        Physics.Raycast(myRay.origin, myRay.direction, out myRCH, 1.5f, layerMask);
        if (myRCH.collider != null)
        {
            //Stop Next to Enemy and Ally
            if (myRCH.collider.tag == "Agent1" || myRCH.collider.tag == "Agent2")
            {
                agent1.velocity = new Vector3(0, 0, 0);
            }
            else
            {
                agent1.velocity = new Vector3(4, 0, 0);
            }

            //Attack
            if (myRCH.collider.tag == "Agent2")
            {
                attacktimer--;
                if (attacktimer <= 0)
                {
                    Agent2Controller AI2 = myRCH.collider.gameObject.GetComponent <Agent2Controller> ();
                    AI2.HP -= dmg;
                    anim.SetTrigger("Attack");
                    attacktimer = 45;
                }
            }
            else
            {
                attacktimer = 45;
            }
        }
        else
        {
            agent1.velocity = new Vector3(4, 0, 0);
        }

        if (hp < 5)
        {
            GetComponentInChildren <ParticleSystem> ().Play();
        }

        //Animation
        if (Mathf.Abs(agent1.velocity.x) > 0)
        {
            anim.SetBool("isWalking", true);
        }
        else
        {
            anim.SetBool("isWalking", false);
        }
        //Death
        if (hp <= 0)
        {
            AgentRespawn AR = GameObject.Find("Main Camera").GetComponent <AgentRespawn>();
            AR.DeleteAgent(gameObject);
        }
    }
    private void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.layer == 10)
        {
            Player2Controller P2 = col.gameObject.GetComponent <Player2Controller> ();
            P2.hp -= 25;

            //Changes color based on attack
            Color temp = col.gameObject.GetComponentInChildren <Light> ().color;
            temp.g -= .2f;

            //Changes intensity based on attack
            Light tempL = col.gameObject.GetComponentInChildren <Light>();
            tempL.intensity -= .2f;
            CameraShake CamShake = GameObject.Find("Main Camera").GetComponent <CameraShake> ();
            CamShake.PlayerShake(.5f);

            // new minion stats
            if (P2.hp <= 0)
            {
                GameObject   Cam     = GameObject.Find("Main Camera");
                AgentRespawn NewStat = Cam.gameObject.GetComponent <AgentRespawn> ();
                NewStat.Agent1InHP += 5;
                NewStat.Agent1dmg  += 2;
            }
        }
        if (col.gameObject.tag == "Agent2")
        {
            Agent2Controller A2 = col.gameObject.GetComponent <Agent2Controller> ();
            A2.HP -= 25;
        }
    }
    // Update is called once per frame
    void FixedUpdate()
    {
        timeUntilSpawn -= Time.deltaTime;
        if (timeUntilSpawn <= 0 && CastleL >= 0 && CastleR >= 0)
        {
            GameObject       Agent1Clone = Instantiate(Agent1, new Vector3(-38.0f, -13.89f, 0f), Quaternion.identity);
            Agent1Controller AI1         = Agent1Clone.gameObject.GetComponent <Agent1Controller> ();
            AI1.HP           = Agent1InHP;
            AI1.DMG          = Agent1dmg;
            Agent1Clone.name = "1_" + Count1.ToString();
            Agents1.Add(Agent1Clone);
            Count1++;

            GameObject       Agent2Clone = Instantiate(Agent2, new Vector3(38.0f, -13.89f, 0f), Quaternion.identity);
            Agent2Controller AI2         = Agent2Clone.gameObject.GetComponent <Agent2Controller> ();
            AI2.HP           = Agent2InHP;
            AI2.DMG          = Agent2dmg;
            Agent2Clone.name = "2_" + Count2.ToString();
            Agents2.Add(Agent2Clone);
            Count2++;
            timeUntilSpawn = spawnCD;
        }

        //OnGameOver
        if (CastleL <= 0)
        {
            foreach (GameObject A in Agents1)
            {
                if (A != null)
                {
                    Destroy(A);
                }
            }
            Agents1.Clear();
        }
        if (CastleR <= 0)
        {
            foreach (GameObject A in Agents2)
            {
                if (A != null)
                {
                    Destroy(A);
                }
            }
            Agents2.Clear();
        }

        if (CastleL <= 0 || CastleR <= 0)
        {
            ButtonPanel.SetActive(true);
            CameraShake CamShake = GameObject.Find("Main Camera").GetComponent <CameraShake> ();
            CamShake.LongShake(.5f);
        }
    }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        //Stop if you see another AI within range and start moving again when they are gone
        myRay = new Ray(transform.position, Vector3.right);
        Physics.Raycast(myRay.origin, myRay.direction, out myRCH, 2.5f, layerMask);
        if (myRCH.collider != null)
        {
            //Stop Next to Enemy and Ally
            if (myRCH.collider.tag == "Agent1" || myRCH.collider.tag == "Agent2")
            {
                agent1.velocity = new Vector3(0, 0, 0);
            }
            else
            {
                agent1.velocity = new Vector3(4, 0, 0);
            }

            //Attack
            if (myRCH.collider.tag == "Agent2")
            {
                attacktimer--;
                if (attacktimer <= 0)
                {
                    Agent2Controller AI2 = myRCH.collider.gameObject.GetComponent <Agent2Controller> ();
                    AI2.HP     -= dmg;
                    attacktimer = 45;
                }
            }
            else
            {
                attacktimer = 45;
            }
        }
        else
        {
            agent1.velocity = new Vector3(4, 0, 0);
        }

        if (hp <= 0)
        {
            AgentRespawn AR = GameObject.Find("Main Camera").GetComponent <AgentRespawn>();
            AR.DeleteAgent(gameObject);
        }
    }
Esempio n. 5
0
    private void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.layer == 10)
        {
            Player2Controller P2 = col.gameObject.GetComponent <Player2Controller> ();
            P2.hp -= 25;

            // new minion stats
            if (P2.hp <= 0)
            {
                GameObject   Cam     = GameObject.Find("Main Camera");
                AgentRespawn NewStat = Cam.gameObject.GetComponent <AgentRespawn> ();
                NewStat.Agent1InHP += 5;
                NewStat.Agent1dmg  += 2;
            }
        }
        if (col.gameObject.tag == "Agent2")
        {
            Agent2Controller A2 = col.gameObject.GetComponent <Agent2Controller> ();
            A2.HP -= 25;
        }
    }