コード例 #1
0
        //If power up collides with player, increase count
        void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.tag == "Player")
            {
                ScoreControl.RaiseScore(250);

                MasterControl.upgradeItem++;
            }

            //If passes through scene and hits bound, destroy
            if (other.gameObject.tag == "EnemyBound")
            {
                Destroy(this.gameObject);
            }
        }
コード例 #2
0
        public ParticleEmitter enemyExplosion;                          //Explosion particles

        void OnTriggerEnter(Collider other)
        {
            //If power up ship is hit by player or player bullet, destroy ship
            if (other.gameObject.tag == "PlayerBullet" || other.gameObject.tag == "Player")
            {
                //If game wave is 7, count for shield
                MasterControl.shieldUpgrade--;

                ScoreControl.RaiseScore(400);

                //Create upgrade object
                Instantiate(upgradeObjects[MasterControl.upgradeItem], this.transform.position, this.transform.rotation);

                //Destroy ship
                StartCoroutine("DestroyObject");
            }
        }
コード例 #3
0
        public float xVect = 0, yVect = 0, zVect = 0;                   //Manually change position

        void OnTriggerEnter(Collider other)
        {
            //Check for collision with player or player bullets
            if (other.gameObject.tag == "PlayerBullet" || other.gameObject.tag == "Player")
            {
                ScoreControl.RaiseScore(100);

                AudioControl.PlayAudio("Explosion");

                Instantiate(enemyExplosion, this.transform.position, this.transform.rotation);

                Destroy(this.gameObject);
            }

            //Check if enemy has passed the camera and destroy it
            if (other.gameObject.tag == "EnemyBound")
            {
                Destroy(this.gameObject);
            }
        }
コード例 #4
0
        //If hit by player bullet, decrease health
        void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.tag == "PlayerBullet")
            {
                arcturusHealth--;

                AudioControl.PlayAudio("Shield");

                //If health has reached 0
                if (arcturusHealth <= 0)
                {
                    //Phase 1 ship collision
                    if (isMainShip)
                    {
                        //Ignore collision while blink and explosion happen
                        if (roundOne)
                        {
                            ScoreControl.RaiseScore(1000);

                            Physics.IgnoreLayerCollision(8, 11);
                            Physics.IgnoreLayerCollision(10, 11);
                        }

                        //If final phase and dead, begin blink and explode sequence
                        else
                        {
                            ScoreControl.RaiseScore(5000);

                            blinkControl   = true;
                            startExplosion = true;
                        }

                        Physics.IgnoreLayerCollision(8, 11);
                        Physics.IgnoreLayerCollision(10, 11);

                        explosionProcess = true;
                        shipDead         = true;

                        //Stop random movement
                        bossMovementControl.CancelActiveRequest();
                    }

                    //Phase 2 ships collision
                    else if (!isMainShip)
                    {
                        ScoreControl.RaiseScore(450);

                        AudioControl.PlayAudio("Explosion");

                        Instantiate(enemyExplosion, this.transform.position, this.transform.rotation);

                        //Create 3 new ships upon each larger ship destroyed
                        if (!isLastShip)
                        {
                            for (int i = 1; i <= 3; i++)
                            {
                                Instantiate(nextPhase, this.transform.position, this.transform.rotation);
                            }
                        }

                        //Count down of smaller ships to reach before starting final phase
                        if (isLastShip)
                        {
                            ScoreControl.RaiseScore(650);

                            //Only increase by 1 then cut off
                            if (lastPhaseDead)
                            {
                                lastShipCount++;

                                lastPhaseDead = false;
                            }
                        }

                        //Destroy each smaller ship
                        Destroy(this.gameObject);
                    }
                }
            }

            //When ship goes around of view and hits colliders, stop ship in its place for the time
            if (other.gameObject.tag == "BossStopper")
            {
                GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0);
            }
        }