Ejemplo n.º 1
0
 public void ShootAIBullet()
 {
     if (mps.GetAmmo() > 0)
     {
         GameObject newBullet;
         if (mps.isInSpecialMode())
         {
             newBullet = Instantiate(specialBulletPrefab,
                                     transform.position + transform.forward * 3.2f,
                                     transform.rotation) as GameObject;
         }
         else
         {
             newBullet = Instantiate(bulletPrefab,
                                     transform.position + transform.forward * 1.6f,
                                     transform.rotation) as GameObject;
         }
         newBullet.transform.forward = transform.forward;
         mps.AmmoDec();
         mps.bulletsFired++;
         if (mps.bulletsFired > 50)
         {
             mps.bulletsFired = 0;
             mps.LoseApproval();
         }
     }
 }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.JoystickButton5))
     {
         if (mps.offenseMode)
         {
             if (mps.GetAmmo() > 0)
             {
                 GameObject newBullet;
                 if (mps.isInSpecialMode())
                 {
                     newBullet = Instantiate(specialBulletPrefab,
                                             transform.position + transform.forward * 3.2f,
                                             transform.rotation) as GameObject;
                 }
                 else
                 {
                     newBullet = Instantiate(bulletPrefab,
                                             transform.position + transform.forward * 1.6f,
                                             transform.rotation) as GameObject;
                 }
                 newBullet.transform.forward = transform.forward;
                 mps.AmmoDec();
                 mps.bulletsFired++;
                 if (mps.bulletsFired > 50)
                 {
                     mps.bulletsFired = 0;
                     //mps.LoseApproval();
                 }
             }
         }
         else
         {
             if (!(mps.isInSpecialMode()))
             {
                 GameObject newShield = Instantiate(shieldPrefab,
                                                    transform.position,
                                                    transform.rotation) as GameObject;
                 newShield.GetComponent <KeepShieldInFront>().playerTransform = transform;
                 mps.AmmoInc();
             }
         }
     }
 }
Ejemplo n.º 3
0
    void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.CompareTag("Bullet"))
        {
            Destroy(other.gameObject);

            if (!(!offenseMode && inSpecialMode))
            {
                health -= 2;
                if (health < 0)
                {
                    health = 0;
                }
            }
        }
        if (other.gameObject.CompareTag("BulletSpecial"))
        {
            Destroy(other.gameObject);

            if (!(!offenseMode && inSpecialMode))
            {
                health -= 2;
                if (health < 0)
                {
                    health = 0;
                }
            }
        }

        if (other.gameObject.CompareTag("Player"))
        {
            ManagePlayerState otherPSM = other.gameObject.GetComponent <ManagePlayerState>();
            if (otherPSM.isInSpecialMode())
            {
                health -= 20;
            }
        }
    }