Ejemplo n.º 1
0
    void CheckForCommie()
    {
        if (Time.time > nextFire)
        {
            RaycastHit2D[] hit = Physics2D.RaycastAll(transform.position, RigidBody.velocity.normalized, CommieLookDistance,
                                                      CollideLayers);
            bool seeCommie = false;
            foreach (RaycastHit2D item in hit)
            {
                if (item.collider.gameObject != this.gameObject)
                {
                    Commie hitCommie = item.collider.GetComponent <Commie> ();
                    if (hitCommie != null)
                    {
                        seeCommie = true;
                    }
                }
            }

            bool randomFire = (Random.Range(0, 100) < RandomFireChance);

            if (seeCommie || randomFire)
            {
                FireProjectile(MyProjectile);
                nextFire = Time.time + FireRate;
                if (mySprite.isVisible)
                {
                    MyController.SFXSource.PlayOneShot(MyWeaponSound);
                }
            }
        }
    }
Ejemplo n.º 2
0
    public void BecomeCommie()
    {
        GameObject newCommieObject = (GameObject)Instantiate(CommiePrefab, transform.position, Quaternion.identity);
        Commie     newCommie       = newCommieObject.GetComponent <Commie> ();

        newCommie.transform.parent = MyController.CommieContainer;
        newCommie.MyDirection      = this.MyDirection;
        newCommie.StartVelocity    = this.RigidBody.velocity;
        newCommie.CivilianPrefab   = this.MyPrefab;
        if (mySprite.isVisible)
        {
            MyController.SFXSource.PlayOneShot(MyController.CommieSound);
        }

        MyController.CivilianCount--;
        MyController.PlayerConversions++;
        Destroy(this.gameObject);
    }
Ejemplo n.º 3
0
    void EnemyMegaphoneHit(Collider2D coll)
    {
        Commie hitCommie = coll.GetComponent <Commie> ();

        if (hitCommie != null)
        {
            hitCommie.Hit = true;
            hitCommie.BecomeCivilian();
            MyController.Score     -= 100;
            MyController.HitPoints -= 2;
            return;
        }

        PlayerController hitPlayer = coll.GetComponent <PlayerController> ();

        if (hitPlayer != null && !hitPlayer.Dead)
        {
            MyController.HitPoints -= 1;
            MyController.SFXSource.PlayOneShot(MyController.PlayerHitSound);
            return;
        }
    }