예제 #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;
        }
    }
예제 #3
0
 void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.tag == "CastleL")
     {
         GameObject   Cam      = GameObject.Find("Main Camera");
         AgentRespawn CastleHP = Cam.gameObject.GetComponent <AgentRespawn> ();
         CastleHP.CastleL -= 1;
         AgentRespawn AR = GameObject.Find("Main Camera").GetComponent <AgentRespawn>();
         AR.DeleteAgent(gameObject);
     }
 }
예제 #4
0
 void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.tag == "CastleL")
     {
         GameObject   Cam      = GameObject.Find("Main Camera");
         AgentRespawn CastleHP = Cam.gameObject.GetComponent <AgentRespawn> ();
         CastleHP.CastleL -= 1;
         CastleHP.Reduce('R');
         CameraShake CamShake = GameObject.Find("Main Camera").GetComponent <CameraShake> ();
         CamShake.MinorShake(.5f);
         AgentRespawn AR = GameObject.Find("Main Camera").GetComponent <AgentRespawn>();
         AR.DeleteAgent(gameObject);
     }
 }
예제 #5
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);
        }
    }
예제 #6
0
 private void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.layer == 9)
     {
         Player1Controller P1 = col.gameObject.GetComponent <Player1Controller> ();
         P1.hp -= 25;
         if (P1.hp <= 0)
         {
             GameObject   Cam     = GameObject.Find("Main Camera");
             AgentRespawn NewStat = Cam.gameObject.GetComponent <AgentRespawn> ();
             NewStat.Agent2InHP += 5;
             NewStat.Agent2dmg  += 2;
         }
     }
     if (col.gameObject.tag == "Agent1")
     {
         Agent1Controller A1 = col.gameObject.GetComponent <Agent1Controller> ();
         A1.HP -= 25;
     }
 }
예제 #7
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;
        }
    }