Beispiel #1
0
    public void setState(PowerupState theState)
    {
        Color color;
        switch (theState)
        {
        case PowerupState.kPowerupStateCorrect:
            LevelPropertiesScript.sharedInstance().nPowerupsExplode++;
            color = Color.green;
            break;
        case PowerupState.kPowerupStateWaiting:
            LevelPropertiesScript.sharedInstance().nPowerupsGot++;
            color = Color.yellow;
            audio.clip = this.audioClip;
            float volume = 2.0f;
            audio.volume = volume;
            audio.Play();
            break;
        case PowerupState.kPowerupStateDefault:
        default:
            color = Color.blue;
            break;
        }

        this.powerupLight.color = color;
        this.powerupSphere.renderer.material.color = new Color(color.r, color.g, color.b, 0.5f);

        this.state = theState;
    }
Beispiel #2
0
        // Handle all powerups
        private void handlePowerUp()
        {
            if (pState != PowerupState.None)
            {
                // restart timedown
                if (powerUpRemaining <= 0)
                {
                    pState           = PowerupState.None;
                    powerUpRemaining = powerUpTicks;
                    return;
                }

                if (powerUpRemaining > 0)
                {
                    powerUpRemaining--;
                }
            }
        }
        public override bool Update(GameTime gameTime, float percent)
        {
            timer += gameTime.ElapsedGameTime.Milliseconds;
            if (timer > maxNextBehaviorTimer)
            {
                timer = 0;
                RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
                rng.GetBytes(random);
                if (random[0] < 190)
                {
                    Velocity             = new Vector2(-Velocity.X, Velocity.Y);
                    Orientation          = 1 - Orientation;
                    maxNextBehaviorTimer = ((random[0] % 3) + 3) * 1000;
                }
            }

            Position = new Vector2(Position.X + Velocity.X, Position.Y + Velocity.Y * percent);
            bool retVal = PowerupState.Update(gameTime, percent);

            Removed = base.Update(gameTime, percent) || retVal;
            return(Removed);
        }
Beispiel #4
0
        public override bool Update(GameTime gameTime, float percent)
        {
            bool retval = base.Update(gameTime, percent);

            if (BoundingBox != null && BoundingBox.Dimensions.Bottom >= MarioCloneGame.LevelAreas[LevelArea].Bottom)
            {
                if (!(PowerupState is GoombaDead))
                {
                    PowerupState.BecomeDead();
                }
            }
            else if (Gravity)
            {
                Velocity = new Vector2(Velocity.X, Velocity.Y + Mario.GravityAcceleration * percent);
            }

            if (!(PowerupState is GoombaDead))
            {
                Gravity = true;
                if (((Position.X > MarioCloneGame.Player1.Position.X && Orientation is Facing.Left) ||
                     (Position.X < MarioCloneGame.Player1.Position.X && Orientation is Facing.Right)) &&
                    (Math.Abs(MarioCloneGame.Player1.Position.X - Position.X) < 600 && Math.Abs(MarioCloneGame.Player1.Position.X - Position.X) > 100 &&
                     Math.Abs(MarioCloneGame.Player1.Position.Y - Position.Y) < 100))
                {
                    fireballPool.GetAndRelease(this);
                }
                if (((Position.X > MarioCloneGame.Player2.Position.X && Orientation is Facing.Left) ||
                     (Position.X < MarioCloneGame.Player2.Position.X && Orientation is Facing.Right)) &&
                    (Math.Abs(MarioCloneGame.Player2.Position.X - Position.X) < 600 && Math.Abs(MarioCloneGame.Player1.Position.X - Position.X) > 100 &&
                     Math.Abs(MarioCloneGame.Player2.Position.Y - Position.Y) < 100))
                {
                    fireballPool.GetAndRelease(this);
                }
            }

            fireballPool.Update(gameTime);
            return(retval);
        }
Beispiel #5
0
 // Use this for initialization
 void Start()
 {
     this.state = PowerupState.NoPowerup;
 }
Beispiel #6
0
 // Consume powerup
 public void ConsumeSpeedPack(float speed)
 {
     powerUpSpeed     = speed;
     pState           = PowerupState.Speed;
     powerUpRemaining = powerUpTicks;
 }
Beispiel #7
0
 // Consume powerup
 public void ConsumeWeaponPack()
 {
     pState           = PowerupState.Weapon;
     powerUpRemaining = powerUpTicks;
 }
Beispiel #8
0
        public override bool Update(GameTime gameTime, float percent)
        {
            var newSpawns = new List <Vector2>();

            foreach (var spawn in Spawns)
            {
                if (spawn.X > Position.X)
                {
                    newSpawns.Add(spawn);
                }
                else
                {
                    ActiveSpawn = new Vector2(spawn.X, spawn.Y);
                }
            }
            Spawns.Clear();
            Spawns.AddRange(newSpawns);

            Position = new Vector2(Position.X + Velocity.X * percent, Position.Y + Velocity.Y * percent);
            ActionState.UpdateHitBox();

            if (BoundingBox.Dimensions.Bottom >= MarioCloneGame.LevelAreas[LevelArea].Bottom)
            {
                if (!(PowerupState is MarioDead2))
                {
                    BecomeDead();
                }
            }
            else
            {
                if (Gravity)
                {
                    Velocity = new Vector2(Velocity.X, Velocity.Y + GravityAcceleration * percent);
                }
                Gravity = true;
            }

            //TODO fix update to be inside the states or smth, or give mario a BecomeFall() method
            if (!(ActionState is MarioFall2 || ActionState is MarioDash) && Velocity.Y > 1.5)
            {
                StateMachine.TransitionFall();
            }

            StateMachine.UpdateDash(gameTime);

            PowerupState.Update(gameTime);
            _FireBallPool.Update(gameTime);

            if (Position.X < 19000 && outSideBoss == false)
            {
                EventManager.Instance.TriggerEnterBossRoom(this);
                outSideBoss = true;
            }
            else if (Position.X > 19000 && outSideBoss == true)
            {
                EventManager.Instance.TriggerEnterBossRoom(this);
                outSideBoss = false;
            }

            return(base.Update(gameTime, percent));
        }
Beispiel #9
0
 public void BecomeFire()
 {
     PowerupState.BecomeFire();
 }
Beispiel #10
0
 public void BecomeSuper()
 {
     PowerupState.BecomeSuper();
 }
Beispiel #11
0
 public void BecomeNormal()
 {
     PowerupState.BecomeNormal();
 }
Beispiel #12
0
 public void BecomeDead()
 {
     PowerupState.BecomeDead();
 }