Ejemplo n.º 1
0
        public void Die()
        {
            // Detach main camera from player object
            Camera mainCam = this.GameObj.GetComponentsInChildren <Camera>().FirstOrDefault();

            mainCam.GameObj.Parent             = null;
            mainCam.GameObj.Transform.Vel      = Vector3.Zero;
            mainCam.GameObj.Transform.AngleVel = 0.0f;

            // Create explosion
            ExploEffect.Create(this.GameObj.Transform.Pos + MathF.Rnd.NextVector3(50.0f), MathF.Rnd.NextFloat(0.8f, 1.75f));
            ExploEffect.Create(this.GameObj.Transform.Pos + MathF.Rnd.NextVector3(50.0f), MathF.Rnd.NextFloat(0.8f, 1.75f));
            ExploEffect.Create(this.GameObj.Transform.Pos + MathF.Rnd.NextVector3(50.0f), MathF.Rnd.NextFloat(0.8f, 1.75f));

            // Schedule player object for disposal
            this.GameObj.DisposeLater();
        }
Ejemplo n.º 2
0
        public void Die()
        {
            if (this.type == AsteroidType.Big)
            {
                ExploEffect.Create(this.GameObj.Transform.Pos, 3.0f);

                if (Player.Instance != null)
                {
                    for (int i = MathF.Rnd.Next(1, 3); i > 0; i--)
                    {
                        this.CreateDebris(AsteroidType.Medium, Player.Instance.PickValidPowerup(PowerupType.Random));
                    }
                    for (int i = MathF.Rnd.Next(1, 3); i > 0; i--)
                    {
                        this.CreateDebris(AsteroidType.Small, Player.Instance.PickValidPowerup(PowerupType.Random));
                    }
                }
                else
                {
                    for (int i = MathF.Rnd.Next(1, 3); i > 0; i--)
                    {
                        this.CreateDebris(AsteroidType.Medium, PowerupType.None);
                    }
                    for (int i = MathF.Rnd.Next(1, 3); i > 0; i--)
                    {
                        this.CreateDebris(AsteroidType.Small, PowerupType.None);
                    }
                }

                Player.Score += 100;
            }
            else if (this.type == AsteroidType.Medium)
            {
                ExploEffect.Create(this.GameObj.Transform.Pos, 1.5f);

                if (Player.Instance != null)
                {
                    for (int i = MathF.Rnd.Next(1, 4); i > 0; i--)
                    {
                        this.CreateDebris(AsteroidType.Small, Player.Instance.PickValidPowerup(PowerupType.Random));
                    }
                }
                else
                {
                    for (int i = MathF.Rnd.Next(1, 4); i > 0; i--)
                    {
                        this.CreateDebris(AsteroidType.Small, PowerupType.None);
                    }
                }

                Player.Score += 50;
            }
            else if (this.type == AsteroidType.Small)
            {
                ExploEffect.Create(this.GameObj.Transform.Pos, 0.5f);

                Player.Score += 25;
            }

            if (this.powerup != PowerupType.None)
            {
                Powerup.Create(this.GameObj.Transform.Pos, this.powerup);
            }

            this.GameObj.DisposeLater();
        }