コード例 #1
0
        public override void Draw(SpriteBatch batcher, GameTime gameTime)
        {
            batcher.Begin();

            WCore.Draw(batcher, gameTime);

            DrawUI(batcher);

            if (IsPaused)
            {
                DrawPause(batcher);
            }

            //Fade effect
            base.Draw(batcher, gameTime);

            batcher.End();
        }
コード例 #2
0
        public override void Update(GameTime gameTime)
        {
            KeyboardState state = Keyboard.GetState();

            // Pause/Unpause and pause/resume music
            if (state.IsKeyDown(Keys.P) && PState.IsKeyUp(Keys.P))
            {
                IsPaused = !IsPaused;
                SLocator.AManager.PauseOrResume();
            }

            // Check of we faded an start sound effect play
            if (IsFaded && !IsSoundOver)
            {
                IsSoundOver = true;
                SLocator.AManager.Play(SongTypes.LAUGH);
            }

            if (IsFaded && !IsSongStart && !SLocator.AManager.IsSoundPlaying)
            {
                IsSongStart = true;
                SLocator.AManager.Play(SongTypes.INGAME);
            }

            this.PState = state;

            // If not paused, update world
            if (!IsPaused)
            {
                WCore.Update(gameTime);
            }

            //If player is dead start fade out
            if (!WCore.IsPlayerAlive)
            {
                StartFade();
            }

            // switch to dead screen if faded
            if (!WCore.IsPlayerAlive && IsFaded)
            {
                SManager.SwitchScreen(ScreenTypes.DEAD, WCore.PSCore);
            }
        }
コード例 #3
0
        /// <summary>
        /// Summons magic entities
        /// </summary>
        protected void Summon()
        {
            var magicVelocity  = 200f;
            var nextMagic      = MagicState.FIST;
            var magicPosition  = Vector2.One;
            var magicDirection = SRandomizer.Next(2);
            var offset         = 72;
            var alpha          = 0.85f;

            var RHLimit = WCore.LLimits.Height - offset;
            var RWLimit = WCore.LLimits.Width - offset;
            var LHLimit = WCore.LLimits.Y + offset;
            var LWLimit = WCore.LLimits.X + offset;

            var randSpellCount = PRandomizer.Next(1, 1 + WCore.PSCore / 100);

            for (int i = 0; i < randSpellCount; i++)
            {
                // Choose which magic to spawn
                switch (SRandomizer.Next(3))
                {
                case 0:
                    nextMagic     = MagicState.FIST;
                    magicVelocity = 200; break;

                case 1: nextMagic = MagicState.PORTAL; break;

                case 2: nextMagic = MagicState.POOL; break;

                case 3: WCore.WGState = (GroundState)SRandomizer.Next(0, 3); continue;

                default: continue;
                }

                // Correct dicrection and velocity
                if (magicDirection == 0)
                {
                    magicDirection = -1;
                    magicVelocity  = -magicVelocity;
                }

                // Sets magic coordinates depending on the current ground
                switch (GState)
                {
                case GroundState.TOP:
                    if (nextMagic == MagicState.FIST || nextMagic == MagicState.PORTAL)
                    {
                        magicPosition.Y = PRandomizer.Next(LHLimit, RHLimit / 3);
                    }
                    else
                    {
                        magicPosition.Y = LHLimit;
                    }
                    magicPosition.X = PRandomizer.Next(LWLimit, RWLimit);
                    break;

                case GroundState.LEFT:
                    if (nextMagic == MagicState.FIST || nextMagic == MagicState.PORTAL)
                    {
                        magicPosition.X = PRandomizer.Next(LWLimit, RWLimit / 3);
                    }
                    else
                    {
                        magicPosition.X = LWLimit;
                    }
                    magicPosition.Y = PRandomizer.Next(LHLimit, RHLimit);
                    break;

                case GroundState.RIGHT:
                    if (nextMagic == MagicState.FIST || nextMagic == MagicState.PORTAL)
                    {
                        magicPosition.X = PRandomizer.Next((int)(RWLimit / 1.5), RWLimit);
                    }
                    else
                    {
                        magicPosition.X = RWLimit;
                    }
                    magicPosition.Y = PRandomizer.Next(LHLimit, RHLimit);
                    break;

                case GroundState.BOTTOM:
                    if (nextMagic == MagicState.FIST || nextMagic == MagicState.PORTAL)
                    {
                        magicPosition.Y = PRandomizer.Next((int)(RHLimit / 1.5), RHLimit);
                    }
                    else
                    {
                        magicPosition.Y = RHLimit;
                    }
                    magicPosition.X = PRandomizer.Next(LWLimit, RWLimit);
                    break;

                default: break;
                }

                // Corrects moving magic position
                if (nextMagic == MagicState.FIST)
                {
                    switch (GState)
                    {
                    case GroundState.TOP:
                    case GroundState.BOTTOM:
                        if (magicDirection == 1)
                        {
                            magicPosition.X = WCore.LLimits.X;
                        }
                        else
                        {
                            magicPosition.X = RWLimit;
                        }
                        break;

                    case GroundState.LEFT:
                    case GroundState.RIGHT:
                        if (magicDirection == 1)
                        {
                            magicPosition.Y = WCore.LLimits.Y;
                        }
                        else
                        {
                            magicPosition.Y = RHLimit;
                        }
                        break;

                    default: break;
                    }
                }

                WCore.AddToSpawnQueue(typeof(Magic).FullName, magicPosition, nextMagic, GState, magicVelocity, alpha);
            }
        }
コード例 #4
0
ファイル: Entity.cs プロジェクト: GoodforGod/CorridorGravity
 /// <summary>
 /// Kill entity
 /// </summary>
 public virtual void Kill(Entity killer)
 {
     WCore.Kill(this);
 }
コード例 #5
0
        public override void Update(GameTime gameTime)
        {
            bool temp = true;

            if (IsAnimated)
            {
                temp = AniManager.UpdateOnce(MState, gameTime);
            }

            if (IsGlided)
            {
                GlideAnimation.Update(gameTime);
            }

            // make actions depend on magic type
            switch (MState)
            {
            case MagicState.FIST:
                switch (GState)
                {
                case GroundState.BOTTOM:
                case GroundState.TOP:
                    Position.X   += Velocity.X * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    GPosition.Y   = GlideAnimation.COffset;
                    BoundingBox.Y = (int)Position.Y;
                    BoundingBox.X = (int)Position.X;

                    if (Position.X > WCore.LLimits.Width || Position.X < WCore.LLimits.X)
                    {
                        Kill(this);
                    }
                    break;

                case GroundState.RIGHT:
                case GroundState.LEFT:
                    Position.Y   += Velocity.X * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    GPosition.X   = GlideAnimation.COffset;
                    BoundingBox.X = (int)Position.X;
                    BoundingBox.Y = (int)Position.Y;

                    if (Position.Y > WCore.LLimits.Height || Position.Y < WCore.LLimits.Y)
                    {
                        Kill(this);
                    }
                    break;

                default: break;
                }
                break;

            case MagicState.DEAD:
                Alpha -= 0.03f;
                if (!temp)
                {
                    Kill(this);
                }
                break;

            case MagicState.PORTAL:
                if (EState == EntityState.NONE && AniManager.CTimeIntoAnimation.TotalSeconds > AniManager.CDuration.TotalSeconds / 2)
                {
                    EState = EntityState.PASSIVE;
                    WCore.AddToSpawnQueue(typeof(Enemy).FullName, Position);
                }
                if (!temp)
                {
                    Kill(this);
                }
                break;

            default:
                if (!temp)
                {
                    Kill(this);
                }
                break;
            }
        }