コード例 #1
0
        public void Update(float dt)
        {
            if (Hit)
            {
                hitTimer.Update(dt);

                if (hitTimer.IsTimeUp())
                {
                    recovering();
                }
            }

            if (Recovering)
            {
                recoveryTimer.Update(dt);

                if (recoveryTimer.IsTimeUp())
                {
                    recoveredFromHit();
                }
            }

            if (Dead)
            {
                this.RespawnTimer.Update(dt);
            }
        }
コード例 #2
0
        public override void Update(float dt)
        {
            if (!this.Fallen)
            {
                if (!fallTimer.IsReset())
                {
                    fallTimer.Update(dt);

                    if (fallTimer.IsTimeUp())
                    {
                        fallAway();
                    }
                }
            }
            else
            {
                if (!resetTimer.IsReset())
                {
                    resetTimer.Update(dt);

                    if (resetTimer.IsTimeUp())
                    {
                        Reset();
                    }
                }
            }
        }
コード例 #3
0
        protected void doBlink(float dt)
        {
            blinkTimer.Update(dt);

            if (blinkTimer.IsTimeUp())
            {
                blinkTimer.SetDelay(blinkDelay);
                toggleBlink();
            }
        }
コード例 #4
0
        /*
         * public override void Respawn()
         * {
         *  base.Respawn();
         *  SetUpEnemy(this.SpawnPosition, EnemyFactory.BatWidth, EnemyFactory.BatHeight, EnemyFactory.BatHealth, EnemyFactory.BatHitDelay, EnemyFactory.BatRecoveryDelay);
         * }
         */

        // Activities:
        private bool checkFlap()
        {
            if (this.Position.Y >= ConvertUnits.ToSimUnits(this.SpawnPosition.Y) || this.PhysicsContainer.Object.OnGround)
            {
                if (flapTimer.IsTimeUp())
                {
                    flapTimer.SetDelay(flapTimerDelay);
                    enemyEvent.flap = true;
                    return(true);
                }
            }

            return(false);
        }
コード例 #5
0
        public bool CheckStopDiving()
        {
            if (this.PhysicsContainer.Object.OnGround)
            {
                return(true);
            }

            if (diveTimer.IsTimeUp())
            {
                return(true);
            }

            return(false);
        }
コード例 #6
0
        public bool CheckForPlayer(bool playerInSight)
        {
            if (playerInSight)
            {
                if (!EnemySeesPlayer)
                {
                    EnemySeesPlayer = true;
                    enemySawPlayerTimer.SetDelay(enemySightDelay);
                }

                if (enemySawPlayerTimer.IsTimeUp())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                if (EnemySeesPlayer)
                {
                    EnemySeesPlayer = false;
                    enemySawPlayerTimer.SetDelay(enemySightDelay);
                }

                if (enemySawPlayerTimer.IsTimeUp())
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
コード例 #7
0
        protected void checkShake(float dt)
        {
            if (livingEntity.Health.Hit)
            {
                shakeTimer.Update(dt);

                if (shakeTimer.IsTimeUp())
                {
                    shakeTimer.SetAccumulatedDelay(shakeDelay);
                    doShake();
                }
            }
            else
            {
                shakePositionOffset = Vector2.Zero;
            }
        }
コード例 #8
0
        public void Update(float dt)
        {
            lifeTimer.Update(dt);

            if (fadeAway)
            {
                Opacity = lifeTimer.PercentFromTimeUp() * initialOpacity;
            }

            if (alphaAway)
            {
                Alpha = lifeTimer.PercentFromTimeUp() * initialAlpha;
            }

            if (lifeTimer.IsTimeUp())
            {
                this.Active = false;
            }
        }
コード例 #9
0
        public void Update(float dt)
        {
            if (Running)
            {
                emissionTimer.Update(dt);
                if (emissionTimer.IsTimeUp())
                {
                    emissionTimer.SetAccumulatedDelay(emissionDelay);
                    EmitParticleWithDisplayEntity(this.DisplayEntity);
                }
            }

            foreach (Particle particle in particles)
            {
                if (particle.Active)
                {
                    particle.Update(dt);
                }
            }
        }
コード例 #10
0
        public override void Draw(GameTime gameTime)
        {
            ++frameCounter;

            string fps = string.Format("fps: {0}", frameRate);

            if (debugText)
            {
                GraphicsDevice.Viewport = game.defaultViewport;

                spriteBatch.Begin();

                spriteBatch.DrawString(spriteFont, fps, new Vector2(5, 5), Color.White);

                if (!debugTextTimer.IsTimeUp())
                {
                    spriteBatch.DrawString(spriteFont, debugString, new Vector2(5, 37), Color.White);
                }

                spriteBatch.End();
            }
        }
コード例 #11
0
        public override void Update(float dt)
        {
            // horizontally
            if (Math.Abs(Position.X - ConvertUnits.ToSimUnits(initialPosition.X)) > ConvertUnits.ToSimUnits(distance))
            {
                MarkDone();
            }
            // vertically
            else if (Math.Abs(Position.Y - ConvertUnits.ToSimUnits(initialPosition.Y)) > ConvertUnits.ToSimUnits(distance))
            {
                MarkDone();
            }

            if (!doneTimer.IsReset())
            {
                doneTimer.Update(dt);

                if (doneTimer.IsTimeUp())
                {
                    MarkDone();
                    doneTimer.Reset();
                }
            }
        }
コード例 #12
0
        public void TurnAround(Enemy enemy)
        {
            Stop();

            if (!turnAround)
            {
                turnAround = true;
                turnAroundTimer.SetDelay(turnAroundTimerDelay);
            }

            if (turnAroundTimer.IsTimeUp())
            {
                turnAround = false;

                if (enemy.FacingRight)
                {
                    enemy.FacingRight = false;
                }
                else
                {
                    enemy.FacingRight = true;
                }
            }
        }
コード例 #13
0
        protected override void performChecks()
        {
            // we don't care about the ceiling
            checkForGround();
            checkForWall(false, false);
            checkForCharOnHead(true, false);

            // record the previous values to the next values
            prevOnGround    = nextOnGround;
            prevOnLeftWall  = nextOnLeftWall;
            prevOnRightWall = nextOnRightWall;

            // record the next values
            nextOnGround    = onGroundPhysics;
            nextOnLeftWall  = OnLeftWall;
            nextOnRightWall = OnRightWall;

            if (onGroundPhysics)
            {
                enableOnGroundDelay = true;
            }
            if (OnLeftWall)
            {
                enableOnLeftWallDelay = true;
            }
            if (OnRightWall)
            {
                enableOnRightWallDelay = true;
            }

            onGroundDelay = false;
            if (enableOnGroundDelay && !onGroundPhysics)
            {
                if (prevOnGround && !nextOnGround)
                {
                    if (body.LinearVelocity.Y >= 0) // so that it doesn't happen when shooting upwards off a platform
                    {
                        onGroundTimer.SetDelay(onGroundOrWallDelay);
                    }
                }

                if (!onGroundPhysics && !onGroundTimer.IsTimeUp())
                {
                    onGroundDelay = true;
                }
            }

            if (enableOnLeftWallDelay && !OnLeftWall)
            {
                if (prevOnLeftWall && !nextOnLeftWall)
                {
                    onLeftWallTimer.SetDelay(onGroundOrWallDelay);
                }

                if (!OnLeftWall && !onLeftWallTimer.IsTimeUp())
                {
                    OnLeftWall = true;
                }
            }

            if (enableOnRightWallDelay && !OnRightWall)
            {
                if (prevOnRightWall && !nextOnRightWall)
                {
                    onRightWallTimer.SetDelay(onGroundOrWallDelay);
                }

                if (!OnRightWall && !onRightWallTimer.IsTimeUp())
                {
                    OnRightWall = true;
                }
            }
        }