Exemple #1
0
        void reverseChase()
        {
            _blinkyTimer = new EggTimer(4600.Milliseconds(), () => { });

            _pacTimer = new EggTimer(4350.Milliseconds(), async() =>
            {
                _finished = true;
                await _mediator.Publish(new CutSceneFinishedEvent());
            });

            _pacMan.Visible    = false;
            _bigPacMan.Visible = true;

            var s    = new LevelStats(0);
            var sess = new GhostFrightSession(s.GetLevelProps());

            _blinky.Direction = new DirectionInfo(Directions.Right, Directions.Right);
            _blinky.SetFrightSession(sess);
            _blinky.SetFrightened();
            _blinkyPositions = _blinkyPositions.Reverse();

            var bigPacPos = _pacPositions.Reverse();

            bigPacPos = new StartAndEndPos(bigPacPos.Start - new Vector2(100, 0), bigPacPos.End);

            _pacPositions = bigPacPos;
        }
Exemple #2
0
        public BigPacChaseAct(IMediator mediator, IGameSoundPlayer gameSoundPlayer)
        {
            _mediator        = mediator;
            _gameSoundPlayer = gameSoundPlayer;
            _finished        = false;

            var justOffScreen = new Vector2(250, 140);

            _blinkyTimer = new EggTimer(4500.Milliseconds(), reverseChase);

            _pacTimer = new EggTimer(4750.Milliseconds(), () => { });

            _pacMan = new AttractScenePacMan {
                Direction = Directions.Left
            };

            _bigPacMan = new GeneralSprite(Vector2.Zero,
                                           new Size(31, 32),
                                           new Vector2(16, 16),
                                           new Vector2(488, 16),
                                           new Vector2(520, 16),
                                           110.Milliseconds())
            {
                Visible = false
            };


            _blinky = new AttractGhost(GhostNickname.Blinky, Directions.Left);

            _pacPositions = new StartAndEndPos(justOffScreen, new Vector2(-70, justOffScreen.Y));

            _blinkyPositions = new StartAndEndPos(justOffScreen + new Vector2(20, 0), new Vector2(-40, justOffScreen.Y));
        }
Exemple #3
0
        /// <summary> Updates the creature </summary>
        public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
        {
            if (!IsActive)
            {
                return;
            }

            CheckNeighborhood(chunks, (float)gameTime.ElapsedGameTime.TotalSeconds);
            UpdateAnimation(gameTime, chunks, camera);
            Status.Update(this, gameTime, chunks, camera);
            JumpTimer.Update(gameTime);
            HandleBuffs(gameTime);

            if (Stats.LaysEggs)
            {
                if (EggTimer == null)
                {
                    EggTimer = new Timer(1200.0f, false);
                }
                EggTimer.Update(gameTime);

                if (EggTimer.HasTriggered)
                {
                    LayEgg();
                    EggTimer = new Timer(1200.0f + MathFunctions.Rand(-30.0f, 30.0f), false);
                }
            }
        }
Exemple #4
0
        public GhostTearAct(IGameSoundPlayer gameSoundPlayer, IMediator mediator)
        {
            _gameSoundPlayer = gameSoundPlayer;
            _mediator        = mediator;

            _finished = false;
            //NextAct = nextAct;
            _stage     = Stage.MovingBlinky;
            _animFrame = 0;

            _tearFrames = new[]
            {
                new Vector2(589, 98),
                new Vector2(609, 98),
                new Vector2(622, 98),
                new Vector2(636, 98),
                new Vector2(636, 98),
                new Vector2(636, 98),
                new Vector2(649, 98)
            };

            _blinkyLookFrames = new[] {
                new Vector2(584, 113),
                new Vector2(600, 113)
            };

            _blinkyTimer = new EggTimer(4500.Milliseconds(), blinkyCaught);

            _tearTimer = new LoopingTimer(500.Milliseconds(),
                                          () => {
                if (_stage == Stage.TearingBlinky)
                {
                    updateTearAnimation();
                }
            });

            _lookTimer = new LoopingTimer(TimeSpan.MaxValue, () => { });

            _pacTimer = new EggTimer(4750.Milliseconds(), () => { });

            _pacMan = new AttractScenePacMan
            {
                Direction = Directions.Left
            };

            _snagSprite = new GeneralSprite(_centerPoint, _tearSize, _tearOffset, _tearFrames[0])
            {
                Visible = true
            };

            _blinky        = new AttractGhost(GhostNickname.Blinky, Directions.Left);
            _lookingBlinky = new NullSprite();

            var justOffScreen = new Vector2(250, 140);

            _pacPositions = new StartAndEndPos(justOffScreen, new Vector2(-70, justOffScreen.Y));

            _blinkyPositions = new StartAndEndPos(justOffScreen + new Vector2(120, 0), _centerPoint - new Vector2(10, 0));
        }
Exemple #5
0
    void reset()
    {
        _showTimer = new(10.Seconds(), () => { Visible = false; });

        Position = Tile.ToCenterCanvas(new(14, 17.2f));

        Visible = false;
    }
Exemple #6
0
        /// <summary> Updates the creature </summary>
        public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
        {
            if (FirstUpdate)
            {
                FirstUpdate = false;
                Faction.Minions.Add(AI);
                Physics.AllowPhysicsSleep = false;
            }

            if (!Active)
            {
                return;
            }
            DrawLifeTimer.Update(gameTime);

            if (!DrawLifeTimer.HasTriggered)
            {
                float val   = Hp / MaxHealth;
                Color color = val < 0.75f ? (val < 0.5f ? Color.Red : Color.Orange) : Color.LightGreen;
                Drawer2D.DrawLoadBar(Manager.World.Camera, AI.Position - Vector3.Up * 0.5f, color, Color.Black, 32, 2, Hp / MaxHealth);
            }

            CheckNeighborhood(chunks, (float)gameTime.ElapsedGameTime.TotalSeconds);
            UpdateAnimation(gameTime, chunks, camera);
            Status.Update(this, gameTime, chunks, camera);
            JumpTimer.Update(gameTime);
            HandleBuffs(gameTime);

            if (Stats.LaysEggs)
            {
                if (EggTimer == null)
                {
                    EggTimer = new Timer(1200f + MathFunctions.Rand(-30, 30), false);
                }
                EggTimer.Update(gameTime);

                if (EggTimer.HasTriggered)
                {
                    LayEgg();
                    EggTimer = new Timer(1200f + MathFunctions.Rand(-30, 30), false);
                }
            }

            if (IsPregnant && World.Time.CurrentDate > CurrentPregnancy.EndDate)
            {
                var baby = EntityFactory.CreateEntity <GameComponent>(BabyType, Physics.Position);
                baby.GetRoot().GetComponent <CreatureAI>().PositionConstraint = AI.PositionConstraint;
                CurrentPregnancy = null;
            }

            if (MathFunctions.RandEvent(0.0001f))
            {
                NoiseMaker.MakeNoise("Chirp", AI.Position, true, 0.25f);
            }
        }
Exemple #7
0
        public void CancelRestartTest()
        {
            bool fired = false;
            bool running = false;

            EggTimer timer = new EggTimer(2);

            timer.TimerExpired += new TimerExpiredHandler(delegate {
                fired = true;
            });

            timer.TimerStarted += new TimerStartedHandler(delegate {
                running = true;
            });

            timer.TimerStopped += new TimerStoppedHandler(delegate {
                running = false;
            });

            timer.Start();

            Assert.IsTrue(timer.IsRunning);
            Assert.IsTrue(running);

            Thread.Sleep(1100);

            timer.Cancel();

            Assert.IsFalse(fired, "timer expired after cancel");
            Assert.IsFalse(timer.IsRunning);
            Assert.IsFalse(running);
            Assert.AreEqual(0, timer.Remaining);

            Thread.Sleep(1100);

            Assert.IsFalse(fired, "timer expired after cancel");
            Assert.AreEqual(0, timer.Remaining);

            timer.Restart();

            Assert.IsTrue(timer.IsRunning);
            Assert.IsTrue(running);

            Thread.Sleep(1100);

            Assert.IsTrue(timer.IsRunning);
            Assert.IsTrue(running);
            Assert.IsFalse(fired, "timer expired early");

            Thread.Sleep(1100);

            Assert.IsTrue(fired, "timer did not expire after restart");
            Assert.IsFalse(running);
            Assert.IsFalse(timer.IsRunning);
        }
    public BigPacChaseAct(IMediator mediator, IGameSoundPlayer gameSoundPlayer)
    {
        _mediator        = mediator;
        _gameSoundPlayer = gameSoundPlayer;
        _finished        = false;

        var justOffScreen = new Vector2(250, 140);

        _blinkyTimer = new(4500.Milliseconds(), reverseChase);

        _pacTimer = new(4750.Milliseconds(), static () => { });
Exemple #9
0
//carvable
        public void Carve(Mobile from, Item item)
        {
            from.SendMessage("You destroy the egg.");

            if (m_Timer != null)
            {
                m_Timer.Stop();
                m_Timer = null;
            }

            Delete();
        }
Exemple #10
0
    void selectNext()
    {
        if (++_index >= _texts.Length)
        {
            _index = 0;
        }

        _current = _texts[_index];
        _state   = State.Idle;
        _timer   = new(_current.TimeIdle);
        _pos     = new(300, _current.YPosition);
    }
//carvable
		public void Carve( Mobile from, Item item )
		{
			from.SendMessage( "You destroy the egg." );

			if (m_Timer != null)
			{
				m_Timer.Stop();
				m_Timer = null;
			}

			Delete();
		}
Exemple #12
0
    ValueTask scrollingIn()
    {
        Debug.Assert(_tweener != null, $"{nameof(_tweener)} != null");

        _pos = new(_tweener.Position, _current.YPosition);

        if (_tweener.HasEnded)
        {
            _state = State.Stationary;
            _timer = new(_current.TimeStationary);
        }

        return(default);
Exemple #13
0
    public ChaseSubAct()
    {
        _finished   = false;
        _tempTimers = new();

        _ghostPoints = Points.From(200);

        _tempSprites = new();
        _ghosts      = new();

        var justOffScreen = new Vector2(250, 140);

        _ghostEatenTimer = new(0.Milliseconds(), static () => { });
    void reverseChase()
    {
        _ghostTimer = new(4600.Milliseconds(), async() =>
        {
            _finished = true;
            await _mediator.Publish(new CutSceneFinishedEvent());
        });

        _pacMan.Visible = false;
        _blinky.Visible = false;
        _worm.Visible   = true;

        _ghostStartAndEndPos = _ghostStartAndEndPos.Reverse();
    }
Exemple #15
0
    public Marquee(MarqueeText[] texts)
    {
        _timer = new(1000.Seconds());
        _texts = texts;
        _index = -1;
        selectNext();

        _tweeningFunction = Tweener.CreateTweeningFunction <Elastic>(Easing.EaseInOut);

        var colorTweeningFunction = Tweener.CreateTweeningFunction <Linear>(Easing.EaseNone);

        _colorTweener        = new(.33f, 1, .33f.Seconds(), colorTweeningFunction);
        _colorTweener.Ended += () =>
        {
            _colorTweener.Reverse();
            _colorTweener.Reset();
        };
    }
Exemple #16
0
        private void UpdateEggs(DwarfTime gameTime)
        {
            if (Stats.LaysEggs)
            {
                if (EggTimer == null)
                {
                    EggTimer = new Timer(3600f + MathFunctions.Rand(-120, 120), false);
                }
                EggTimer.Update(gameTime);

                if (EggTimer.HasTriggered)
                {
                    if (!_speciesCounts.ContainsKey(Species) || _speciesCounts[Species] < _maxPerSpecies)
                    {
                        LayEgg();
                        EggTimer = new Timer(3600f + MathFunctions.Rand(-120, 120), false);
                    }
                }
            }
        }
Exemple #17
0
        void ghostEaten(AttractGhost ghost)
        {
            ghost.Alive = false;

            _pacMan.Visible = false;

            _ghostTimer.Pause();
            _pacTimer.Pause();

            showScore(ghost.Position, _ghostScore);

            _ghostScore *= 2;

            // ReSharper disable once HeapView.ObjectAllocation.Evident
            _ghostEatenTimer = new EggTimer(1.Seconds(), () =>
            {
                _ghostTimer.Resume();
                _pacTimer.Resume();
                _pacMan.Visible = true;
            });
        }
Exemple #18
0
        public TornGhostChaseAct(IMediator mediator, IGameSoundPlayer gameSoundPlayer)
        {
            _mediator        = mediator;
            _gameSoundPlayer = gameSoundPlayer;
            _finished        = false;

            var justOffScreen = new Vector2(250, 140);

            _ghostTimer = new EggTimer(4500.Milliseconds(), reverseChase);

            _pacTimer = new EggTimer(4800.Milliseconds(), () => { });

            _pacMan = new AttractScenePacMan
            {
                Direction = Directions.Left
            };

            _worm = new GeneralSprite(Vector2.Zero,
                                      new Size(22, 11),
                                      new Vector2(11, 5.5f),
                                      new Vector2(594, 132),
                                      new Vector2(626, 132),
                                      110.Milliseconds())
            {
                Visible = false
            };


            _blinky = new GeneralSprite(Vector2.Zero,
                                        new Size(14, 14),
                                        new Vector2(7.5f, 7.5f),
                                        new Vector2(618, 113),
                                        new Vector2(634, 113),
                                        110.Milliseconds());


            _pacPositions = new StartAndEndPos(justOffScreen, new Vector2(-70, justOffScreen.Y));

            _ghostStartAndEndPos = new StartAndEndPos(justOffScreen + new Vector2(50, 0), new Vector2(-40, justOffScreen.Y));
        }
Exemple #19
0
        ValueTask reverseChase()
        {
            _powerPillToEat.Visible = false;
            _ghostTimer             = new EggTimer(12.Seconds(), () => { });
            _pacTimer = new EggTimer(6.Seconds(), () => { });

            var levelStats     = new LevelStats(0);
            var frightSessions = new GhostFrightSession(levelStats.GetLevelProps());

            foreach (var eachGhost in _ghosts)
            {
                eachGhost.Direction.Update(Directions.Right);
                eachGhost.SetFrightSession(frightSessions);
                eachGhost.SetFrightened();

                _ghostPositions[eachGhost.NickName] = _ghostPositions[eachGhost.NickName].Reverse();
            }

            _pacPositions = _pacPositions.Reverse();

            _pacMan.Direction = Directions.Right;

            return(default);
Exemple #20
0
        public void StartStopTest()
        {
            bool fired = false;
            bool running = false;

            EggTimer timer = new EggTimer(2);

            timer.TimerExpired += new TimerExpiredHandler(delegate {
                fired = true;
            });

            timer.TimerStarted += new TimerStartedHandler(delegate {
                running = true;
            });

            timer.TimerStopped += new TimerStoppedHandler(delegate {
                running = false;
            });

            timer.Start();

            Assert.IsTrue(timer.IsRunning);
            Assert.IsTrue(running);

            Thread.Sleep(1100);

            Assert.IsTrue(timer.IsRunning);
            Assert.IsTrue(running);

            timer.Stop();

            Assert.IsFalse(fired, "timer expired early");
            Assert.IsFalse(running);
            Assert.IsFalse(timer.IsRunning);

            timer.Start();

            Assert.IsTrue(timer.IsRunning);
            Assert.IsTrue(running);

            Thread.Sleep(1100);

            Assert.IsTrue(fired, "timer did not expire in time");
            Assert.IsFalse(running);
            Assert.IsFalse(timer.IsRunning);
        }
Exemple #21
0
        public void ForcedExpirationTest()
        {
            bool fired = false;
            bool running = false;

            EggTimer timer = new EggTimer(2);

            timer.TimerExpired += new TimerExpiredHandler(delegate {
                fired = true;
            });

            timer.TimerStarted += new TimerStartedHandler(delegate {
                running = true;
            });

            timer.TimerStopped += new TimerStoppedHandler(delegate {
                running = false;
            });

            timer.Start();

            Assert.IsTrue(timer.IsRunning);
            Assert.IsTrue(running);

            Thread.Sleep(1100);

            Assert.IsTrue(timer.IsRunning);
            Assert.IsTrue(running);

            timer.Expire();

            Assert.IsTrue(fired, "timer did not expire after expire");
            Assert.IsFalse(timer.IsRunning);
            Assert.IsFalse(running);
            Assert.AreEqual(0, timer.Remaining);

            fired = false;

            Thread.Sleep(1100);

            Assert.IsFalse(fired, "timer expired again");
        }
		public CamelSpiderEgg() : base( 0x10D9 )
		{
			Movable = false;
			m_Timer = new EggTimer(this);
			m_Timer.Start();
		}
Exemple #23
0
        public ChaseSubAct()
        {
            _finished   = false;
            _tempTimers = new TimerList();

            _ghostScore = 200;

            _tempSprites = new TimedSpriteList();
            _ghosts      = new List <AttractGhost>();

            var justOffScreen = new Vector2(250, 140);

            _ghostEatenTimer = new EggTimer(0.Milliseconds(), () => { });
            _ghostTimer      = new EggTimer(5.Seconds(), async() => await reverseChase());
            _pacTimer        = new EggTimer(5.1f.Seconds(), () => { });

            _powerPillToEat = new PowerPill
            {
                Visible  = false,
                Position = new Vector2(30, justOffScreen.Y - 4)
            };

            _pillLegend = new Pill {
                Position = new Vector2(70, 178)
            };

            _powerPillLegend = new PowerPill {
                Position = new Vector2(66, 182)
            };

            _pacMan = new AttractScenePacMan {
                Direction = Directions.Left
            };

            var blinky = new AttractGhost(GhostNickname.Blinky, Directions.Left);
            var pinky  = new AttractGhost(GhostNickname.Pinky, Directions.Left);
            var inky   = new AttractGhost(GhostNickname.Inky, Directions.Left);
            var clyde  = new AttractGhost(GhostNickname.Clyde, Directions.Left);

            _ghosts.Add(blinky);
            _ghosts.Add(pinky);
            _ghosts.Add(inky);
            _ghosts.Add(clyde);

            var gap = new Vector2(16, 0);

            _pacPositions    = new StartAndEndPos(justOffScreen, new Vector2(30, justOffScreen.Y));
            _pacMan.Position = _pacPositions.Start;

            _ghostPositions = new Dictionary <GhostNickname, StartAndEndPos>();

            var startPos = justOffScreen + new Vector2(50, 0);
            var endPos   = new Vector2(50, justOffScreen.Y);

            blinky.Position = startPos;
            _ghostPositions[blinky.NickName] = new StartAndEndPos(startPos, endPos);

            startPos       = startPos + gap;
            endPos         = endPos + gap;
            pinky.Position = startPos;
            _ghostPositions[pinky.NickName] = new StartAndEndPos(startPos, endPos);

            startPos      = startPos + gap;
            endPos        = endPos + gap;
            inky.Position = startPos;
            _ghostPositions[inky.NickName] = new StartAndEndPos(startPos, endPos);

            startPos       = startPos + gap;
            endPos         = endPos + gap;
            clyde.Position = startPos;
            _ghostPositions[clyde.NickName] = new StartAndEndPos(startPos, endPos);

            _tempTimers.Add(new EggTimer(1.Seconds(), () => _legendVisible = true));
            _tempTimers.Add(new EggTimer(3.Seconds(), () =>
            {
                _powerPillToEat.Visible = true;
                _copyrightVisible       = true;
            }));

            _tempTimers.Add(new EggTimer(4500.Milliseconds(), () =>
            {
                _ghostsChasing = true;
            }));
        }
Exemple #24
0
        ///////////////////////////////////////////////////////////////////////
        private void TestTimerExpiration(int seconds)
        {
            bool fired = false;
            bool running = false;

            EggTimer timer = new EggTimer(seconds);

            timer.TimerExpired += new TimerExpiredHandler(delegate {
                fired = true;
            });

            timer.TimerStarted += new TimerStartedHandler(delegate {
                running = true;
            });

            timer.TimerStopped += new TimerStoppedHandler(delegate {
                running = false;
            });

            Assert.IsFalse(timer.IsRunning);
            Assert.AreEqual(seconds, timer.Remaining);

            timer.Start();

            // keep an eye on the timer and the flag...
            for (int sec = 0; sec < seconds; sec++) {
                Assert.IsFalse(fired, "timer expired early");
                Assert.IsTrue(timer.IsRunning);
                Assert.IsTrue(running);

                Thread.Sleep(1000);
            }

            // give the timer a little extra time (note: 250 ms is spec, but
            // we push it a little bit here to make sure we will hit the spec)
            Thread.Sleep(100);

            // we should certainly have expired by now...
            Assert.IsTrue(fired, "timer did not expire in time");

            // the timer should be dead, since it had expired
            Assert.IsFalse(timer.IsRunning);
            Assert.IsFalse(running);
            Assert.AreEqual(0, timer.Remaining);
        }
Exemple #25
0
 public CamelSpiderEgg() : base(0x10D9)
 {
     Movable = false;
     m_Timer = new EggTimer(this);
     m_Timer.Start();
 }