private void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.layer == 9)
        {
            Player1Controller P1 = col.gameObject.GetComponent <Player1Controller> ();
            P1.hp -= 25;
            //Changes color based on attack
            Color temp = col.gameObject.GetComponentInChildren <Light> ().color;
            temp.r -= .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);
            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;
        }
    }
示例#2
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.left);
        Physics.Raycast(myRay.origin, myRay.direction, out myRCH, 1.5f, layerMask);
        if (myRCH.collider != null)
        {
            if (myRCH.collider.tag == "Agent1" || myRCH.collider.tag == "Agent2")
            {
                agent2.velocity = new Vector3(0, 0, 0);
            }
            else
            {
                agent2.velocity = new Vector3(-4, 0, 0);
            }
            //Attack
            if (myRCH.collider.tag == "Agent1")
            {
                attacktimer--;
                if (attacktimer <= 0)
                {
                    Agent1Controller AI1 = myRCH.collider.gameObject.GetComponent <Agent1Controller> ();
                    AI1.HP -= dmg;
                    anim.SetTrigger("Attack");
                    attacktimer = 45;
                }
            }
            else
            {
                attacktimer = 45;
            }
        }
        else
        {
            agent2.velocity = new Vector3(-4, 0, 0);
        }

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

        //Animation
        if (Mathf.Abs(agent2.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);
        }
    }
    // 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);
        }
    }
示例#4
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;
     }
 }
 // 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.left);
     Physics.Raycast(myRay.origin, myRay.direction, out myRCH, 2.5f, layerMask);
     if (myRCH.collider != null)
     {
         if (myRCH.collider.tag == "Agent1" || myRCH.collider.tag == "Agent2")
         {
             agent2.velocity = new Vector3(0, 0, 0);
         }
         else
         {
             agent2.velocity = new Vector3(-4, 0, 0);
         }
         //Attack
         if (myRCH.collider.tag == "Agent1")
         {
             attacktimer--;
             if (attacktimer <= 0)
             {
                 Agent1Controller AI1 = myRCH.collider.gameObject.GetComponent <Agent1Controller> ();
                 AI1.HP     -= dmg;
                 attacktimer = 45;
             }
         }
         else
         {
             attacktimer = 45;
         }
     }
     else
     {
         agent2.velocity = new Vector3(-4, 0, 0);
     }
     if (hp <= 0)
     {
         AgentRespawn AR = GameObject.Find("Main Camera").GetComponent <AgentRespawn>();
         AR.DeleteAgent(gameObject);
     }
 }