示例#1
0
        public WhirlPool(EntityPreset preset, Player player)
            : base(preset, player, "whirlpool", 16, 16)
        {
            AddAnimation("whirl", CreateAnimFrameArray(0, 1), 6, true);
            AddAnimation("transition", CreateAnimFrameArray(3, 4, 4), 6, false);
            AddAnimation("whirl_red", CreateAnimFrameArray(4, 5), 6, true);

            if (GlobalState.FishermanDead)
            {
                Play("whirl_red");
            }
            else
            {
                Play("whirl");
            }

            if (GlobalState.CURRENT_MAP_NAME == "REDSEA")
            {
                teleportOffset = new Vector2(0, -36);
            }
        }
示例#2
0
        public SpaceFace(EntityPreset preset, Player p)
            : base(preset.Position, "space_npcs", 16, 16, Drawing.DrawOrder.BG_ENTITIES)
        {
            int[] anim;
            if (preset.Frame == 0)
            {
                anim = CreateAnimFrameArray(22, 23);
            }
            else
            {
                anim = CreateAnimFrameArray(20, 21);
            }

            AddAnimation("a", anim, 6);
            Play("a");

            waitTimer    = 0f;
            waitTimerMax = (float)(0.5 + 1.5 * GlobalState.RNG.NextDouble());

            _player = p;
        }
示例#3
0
        public Propelled(EntityPreset preset, Player p) : base(preset.Position, "moving_platform", 16, 16, Drawing.DrawOrder.VERY_BG_ENTITIES)
        {
            width = height = 10;
            CenterOffset();
            initial_pos = preset.Position;

            poof = new(Vector2.Zero, "moving_platform_poof", 16, 16, Drawing.DrawOrder.BG_ENTITIES);
            poof.AddAnimation("play", CreateAnimFrameArray(0, 1, 2, 3, 4), 12, false);
            poof.SetFrame(4);

            facing = (preset.Frame % 4) switch
            {
                0 => Facing.UP,
                1 => Facing.RIGHT,
                2 => Facing.DOWN,
                _ => Facing.LEFT
            };

            active = preset.Frame >= 4;
            UpdateFrame();
        }
示例#4
0
        public Shieldy(EntityPreset preset, Player player)
            : base(preset, preset.Position + new Vector2(2, 0), "shieldy", 16, 16, DrawOrder.ENTITIES)
        {
            Solid  = true;
            height = 10;
            width  = 10;

            offset = new Vector2(3, 4);

            AddAnimation("walk", CreateAnimFrameArray(1, 2, 1, 0), 5, true);
            //addAnimation("unhurt", [4], 7, true);
            AddAnimation("front_hit", CreateAnimFrameArray(16, 17, 18, 1), 12, false);
            AddAnimation("back_hit", CreateAnimFrameArray(13, 1), 12);

            Play("walk");

            State state = (State)preset.Frame;

            switch (state)
            {
            case State.LEFT:
                velocity = new Vector2(-_velocityMax, 0);
                break;

            case State.RIGHT:
                velocity = new Vector2(_velocityMax, 0);
                break;

            case State.UP:
                velocity = new Vector2(0, -_velocityMax);
                break;

            case State.DOWN:
                velocity = new Vector2(0, _velocityMax);
                break;

            default:
                break;
            }
        }
示例#5
0
        public HappyNPC(EntityPreset preset, Player p)
            : base(preset.Position, "happy_npcs", 16, 16, Drawing.DrawOrder.ENTITIES)
        {
            immovable = true;

            switch (preset.Frame)
            {
            case 0:
                SetWalkAnims(9);
                _dialogue = "hot";
                _npcType  = NpcType.Pace;
                break;

            case 1:
                SetWalkAnims(9);
                _dialogue = "dump";
                _npcType  = NpcType.Run;
                break;

            case 2:
                SetWalkAnims(0);
                _dialogue = "gold";
                _npcType  = NpcType.Run;
                break;

            case 3:
                SetWalkAnims(9);
                _dialogue = "drink";
                _npcType  = NpcType.Run;
                break;

            case 4:
                SetWalkAnims(0);
                _dialogue = "beautiful";
                _npcType  = NpcType.Pace;
                break;
            }
        }
示例#6
0
        public Gate(EntityPreset preset, Player p) : base(preset.Position, "gates", 16, 16, DrawOrder.ENTITIES)
        {
            //Hack to fix missing permanence in map
            preset.Permanence = Permanence.GLOBAL;

            _preset   = preset;
            _player   = p;
            immovable = true;

            ClosedFrame = 0;
            bool fast = true;

            if (GlobalState.CURRENT_MAP_NAME == "BLANK")
            {
                ClosedFrame = 8;
                fast        = false;
            }
            else if (GlobalState.CURRENT_MAP_NAME == "TRAIN")
            {
                ClosedFrame = 16;
                fast        = false;
            }
            AddAnimation("still", CreateAnimFrameArray(ClosedFrame));
            AddAnimation("close", CreateAnimFrameArray(ClosedFrame + 3, ClosedFrame + 2, ClosedFrame + 1, ClosedFrame), fast ? 10 : 8, false);
            AddAnimation("open", CreateAnimFrameArray(ClosedFrame, ClosedFrame + 1, ClosedFrame + 2, ClosedFrame + 3), fast ? 10 : 4, false);


            //Player holds down the gate when they stand on it on entering the screen
            HeldDown = p.Hitbox.Intersects(Hitbox);
            if (HeldDown && !ConditionSatisfied())
            {
                SetFrame(ClosedFrame + 3);
            }
            else
            {
                Play("still");
            }
        }
        public EyebossPreview(EntityPreset preset, Player p)
            : base(preset.Position, "eye_boss_water", 24, 24, Drawing.DrawOrder.ENTITIES)
        {
            AddAnimation("blink", CreateAnimFrameArray(0, 1, 2, 3, 2, 1, 0), 10, false);
            AddAnimation("open", CreateAnimFrameArray(3, 2, 1, 0), 5, false);
            AddAnimation("closed", CreateAnimFrameArray(3));
            Play("closed");

            immovable = true;

            opacity = 0;

            if (GlobalState.events.BossDefeated.Contains("HOTEL") || (GlobalState.events.GetEvent("EyebossPreviewPlayed") > 0 && GlobalState.RNG.NextDouble() > 0.3))
            {
                exists = false;
            }
            else
            {
                GlobalState.events.IncEvent("EyebossPreviewPlayed");
            }

            _stateLogic = StateLogic();
        }
示例#8
0
        public NexusPad(EntityPreset preset, Player player)
            : base(preset, player, "nexus_pad", 32, 32, null)
        {
            width  = 22;
            height = 18;
            offset = new Vector2(6, 4);

            Position      += new Vector2(6, 6);
            teleportOffset = new Vector2(10, 34);

            if (GlobalState.IsCell)
            {
                AddAnimation("on", CreateAnimFrameArray(3), 12, false);
                AddAnimation("off", CreateAnimFrameArray(2), 12, false);
            }
            else
            {
                AddAnimation("on", CreateAnimFrameArray(1), 12, false);
                AddAnimation("off", CreateAnimFrameArray(0), 12, false);
            }
            Play("off");

            GlobalState.events.ActivatedNexusPortals.Add(GlobalState.CURRENT_MAP_NAME);
        }
示例#9
0
        public SuburbKiller(EntityPreset preset, Player p)
            : base(preset.Position, "suburb_killers", 16, 16, Drawing.DrawOrder.ENTITIES)
        {
            _player = p;

            int off = GlobalState.RNG.Next(0, 7) * 9;

            AddAnimation("idle_d", CreateAnimFrameArray(off + 0), 1);
            AddAnimation("idle_r", CreateAnimFrameArray(off + 2), 1);
            AddAnimation("idle_u", CreateAnimFrameArray(off + 4), 1);
            AddAnimation("idle_l", CreateAnimFrameArray(off + 6), 1);

            AddAnimation("walk_d", CreateAnimFrameArray(off, off + 1), 4);
            AddAnimation("walk_r", CreateAnimFrameArray(off + 2, off + 3), 4);
            AddAnimation("walk_u", CreateAnimFrameArray(off + 4, off + 5), 4);
            AddAnimation("walk_l", CreateAnimFrameArray(off + 6, off + 7), 4);

            Play("idle_d");

            width  = height = 6;
            offset = new Vector2(5);

            Position += new Vector2(5);
        }
示例#10
0
        public FollowerBro(EntityPreset preset, Player p)
            : base(preset.Position, "follower_bro", 16, 24, Drawing.DrawOrder.ENTITIES)
        {
            _preset = preset;
            _player = p;

            AddAnimation("walk", CreateAnimFrameArray(1, 2, 1, 0), 4, true);
            SetFrame(0);
            opacity = 0;

            _state = new StateMachineBuilder()
                     .State("Hidden")
                     .Condition(() => _player.Position.Y - Position.Y < -20, (state) => state.Parent.ChangeState("Appearing"))
                     .End()
                     .State("Appearing")
                     .Enter((state) => { _player.dontMove = true; _preset.Alive = false; })
                     .Update((state, time) => opacity += 0.6f * time)
                     .Condition(() => opacity > 0.96f, (state) => state.Parent.ChangeState("Walk"))
                     .End()
                     .State("Walk")
                     .Enter((state) => { _player.dontMove = false; Play("walk"); })
                     .Update((state, time) => velocity = new Vector2((_player.Position.X > Position.X) ? 10 : -10, -10))
                     .Event <CollisionEvent <Player> >("Player", (state, _player) => state.Parent.ChangeState("Disappearing"))
                     .Condition(() => _player.Position.Y >= Position.Y, (state) => state.Parent.ChangeState("Wait"))
                     .End()
                     .State("Wait")
                     .Condition(() => _player.Position.Y < Position.Y, (state) => state.Parent.ChangeState("Walk"))
                     .End()
                     .State("Disappearing")
                     .Update((state, time) => opacity -= 0.6f * time)
                     .Condition(() => opacity <= 0, (state) => exists = false)
                     .End()
                     .Build();

            _state.ChangeState("Hidden");
        }
示例#11
0
        public BigGate(EntityPreset preset, Player p) : base(preset, "gate_green", 32, 16, Drawing.DrawOrder.ENTITIES)
        {
            _sentinel.Position = Position + new Vector2(11, -3);
            _sentinel.width    = 10;
            _player            = p;

            _state = new StateMachineBuilder()
                     .State <OpenState>("Open")
                     .Enter(s =>
            {
                s.state = openSequence();

                IEnumerator <string> openSequence()
                {
                    yield return("Start");

                    for (int i = 0; i <= 4; ++i)
                    {
                        GlobalState.screenShake.Shake(0.02f, 0.3f);
                        SoundManager.PlaySoundEffect("hit_ground_1");
                        SetFrame(i);
                        yield return($"Open {i}");
                    }
                    SoundManager.PlaySoundEffect("open");
                    _player.state = PlayerState.GROUND;
                    exists        = false;
                    yield break;
                }
            })
                     .Event("open", (s) =>
            {
                s.state.MoveNext();
            })
                     .End()
                     .Build();
        }
示例#12
0
 public HappyBriar(EntityPreset preset, Player p) : base(preset, p)
 {
     visible = false;
     state   = State();
 }
示例#13
0
 public WideUpDoor(EntityPreset preset, Player player)
     : base(preset, player, Facing.UP, 20)
 {
     width       = 80;
     Position.X -= 32;
 }
示例#14
0
 public TallRightDoor(EntityPreset preset, Player player)
     : base(preset, player)
 {
     height      = 80;
     Position.Y -= 32;
 }
示例#15
0
 public DownDoor(EntityPreset preset, Player player)
     : base(preset, player, Facing.DOWN, 16)
 {
 }
示例#16
0
 public UpDoor(EntityPreset preset, Player player)
     : base(preset, player, Facing.UP, 20)
 {
 }
示例#17
0
 public RightDoor(EntityPreset preset, Player player)
     : base(preset, player, Facing.RIGHT, 17)
 {
 }
示例#18
0
        public FirePillar(EntityPreset preset, Player p)
            : base(preset.Position, "fire_pillar", 16, 32, Drawing.DrawOrder.ENTITIES)
        {
            _base = new Entity(preset.Position + new Vector2(0, 16), "fire_pillar_base", 16, 16, Drawing.DrawOrder.VERY_BG_ENTITIES);
            _base.AddAnimation("dormant", CreateAnimFrameArray(0, 1), 6);
            _base.Play("dormant");

            AddAnimation("idle", CreateAnimFrameArray(0), 15);
            AddAnimation("emerge", CreateAnimFrameArray(1, 2, 3, 4), 8, false);
            AddAnimation("flame", CreateAnimFrameArray(3, 4), 10);
            AddAnimation("recede", CreateAnimFrameArray(5, 6, 0), 8, false);
            Play("idle");

            height      = 9;
            offset.Y   += 16;
            Position.Y += 16;

            _state = new StateMachineBuilder()
                     .State <IdleState>("Idle")
                     .Enter((s) =>
            {
                Play("idle");

                visible = true;
            })
                     .Event("goToEmerge", (s) =>
            {
                _state.ChangeState("Emerge");
            })
                     .End()
                     .State <EmergeState>("Emerge")
                     .Enter((s) =>
            {
                Play("emerge");
                Flicker(0.25f);
            })
                     .Event("goToFlame", (s) =>
            {
                _state.ChangeState("Flame");
            })
                     .End()
                     .State <FlameState>("Flame")
                     .Enter((s) =>
            {
                Play("flame");
                SoundManager.PlaySoundEffect("flame_pillar");
            })
                     .Event("goToRecede", (s) =>
            {
                _state.ChangeState("Recede");
            })
                     .Event <CollisionEvent <Player> >("Player", (s, p) => p.entity.ReceiveDamage(1))
                     .End()
                     .State <RecedeState>("Recede")
                     .Enter((s) =>
            {
                Play("recede");
            })
                     .Event("goToIdle", (s) =>
            {
                _state.ChangeState("Idle");
            })
                     .End()
                     .Build();

            _state.ChangeState("Idle");
        }
示例#19
0
 public WideDownDoor(EntityPreset preset, Player player)
     : base(preset, player, Facing.DOWN, 16)
 {
     width       = 80;
     Position.X -= 32;
 }
示例#20
0
        public Dog(EntityPreset preset, Player p)
            : base(preset, preset.Position, "dog", 16, 16, Drawing.DrawOrder.ENTITIES, 1)
        {
            width  = height = 12;
            offset = new Vector2(2);
            drag.X = 20;

            AddAnimation("stop", CreateAnimFrameArray(0));
            AddAnimation("walk", CreateAnimFrameArray(2, 3), 4);
            AddAnimation("alert", CreateAnimFrameArray(4, 5), 4);
            AddAnimation("attack", CreateAnimFrameArray(6, 7), 6);

            _activeRegion = new DogRegion(this);
            _target       = p;

            _isSuperDog = preset.TypeValue == "1";

            _hitTimer = 0;

            _state = new StateMachineBuilder()
                     .State <TimerState>("Pace")
                     .Enter((state) =>
            {
                state.Reset();
                state.AddTimer(1f, "MoveTimer");
                _activeRegion.exists = true;

                velocity = Vector2.Zero;
            })
                     .Event("MoveTimer", (state) =>
            {
                if (GlobalState.RNG.NextDouble() > 0.33)
                {
                    Play("walk");
                    velocity.X = pace_vel;
                    SetFlip();
                }
                else if (GlobalState.RNG.NextDouble() > 0.5)
                {
                    Play("walk");
                    velocity.X = -pace_vel;
                    SetFlip();
                }
                else
                {
                    Play("stop");
                    velocity.X = 0;
                }
            })
                     .Event("PlayerInArea", (state) =>
            {
                state.Parent.ChangeState("Alert");
            })
                     .Exit((state) =>
            {
                _activeRegion.exists = false;
            })
                     .End()
                     .State <TimerState>("Alert")
                     .Enter((state) =>
            {
                state.Reset();
                state.AddTimer(1f, "AlertTimer");

                velocity = Vector2.Zero;
                Play("alert");
                SoundManager.PlaySoundEffect("dog_bark");
            })
                     .Event("AlertTimer", (state) =>
            {
                state.Parent.ChangeState("Attack");
            })
                     .End()
                     .State <AttackState>("Attack")
                     .Enter((state) =>
            {
                state.attackPhase = 0;
                Vector2 tPos      = _target.Position;
                state.targetPos   = new Vector2(tPos.X - GlobalState.RNG.Next(38, 51), tPos.Y - 8);

                if (!_isSuperDog)
                {
                    state.attackPositions[0] = new Vector2(tPos.X + GlobalState.RNG.Next(30, 43), tPos.Y - 8);
                    state.attackPositions[1] = new Vector2(tPos.X - GlobalState.RNG.Next(38, 51), tPos.Y - 8);
                }

                MoveTowards(state.targetPos, state.AttackSpeed);

                Play("attack");

                SetFlip();
            })
                     .Event("AttackTimer", (state) =>
            {
                state.attackPhase++;

                if (state.attackPhase > (_isSuperDog ? 4 : 2))
                {
                    state.Parent.ChangeState("Pace");
                    return;
                }

                SoundManager.PlaySoundEffect("dog_dash");

                if (_isSuperDog)
                {
                    state.targetPos = _target.Position;

                    if (_target.Position.X > Position.X)
                    {
                        state.targetPos += new Vector2(25, 8);
                    }
                    else
                    {
                        state.targetPos -= new Vector2(28, 8);
                    }
                }
                else
                {
                    state.targetPos = state.AttackPos;
                }

                MoveTowards(state.targetPos, state.AttackSpeed);

                SetFlip();
            })
                     .End()
                     .Build();

            _state.ChangeState("Pace");
        }
示例#21
0
 void Warp(EntityPreset next)
 {
     GlobalState.PLAYER_WARP_TARGET = next.Position + new Vector2(8, 30);
     GlobalState.NEXT_MAP_NAME      = GlobalState.CURRENT_MAP_NAME;
     GlobalState.WARP = true;
 }
示例#22
0
        public FallingSpikeRoller(EntityPreset preset, Player p)
            : base(preset, preset.Frame)
        {
            _shadow = new RollerShadow(Position - offset, preset.Frame);

            visible = false;

            offset.Y = 80;

            layer = Drawing.DrawOrder.FG_SPRITES;

            _initPos = Position;

            _state = new StateMachineBuilder()
                     .State("Hidden")
                     .Event("PlayerOverlaps", (state) =>
            {
                _state.ChangeState("Fall");
            })
                     .End()
                     .State("Fall")
                     .Enter((state) =>
            {
                visible         = true;
                _shadow.visible = true;

                _shadow.Flicker(-1);

                SoundManager.PlaySoundEffect("fall_1");
            })
                     .Condition(() => MathUtilities.MoveTo(ref offset.Y, 0, 60), (state) => _state.ChangeState("Roll"))
                     .Exit((state) =>
            {
                _shadow.exists = false;
            })
                     .End()
                     .State("Roll")
                     .Enter((state) =>
            {
                CollisionOn = true;
                velocity    = vel;
                layer       = Drawing.DrawOrder.BG_ENTITIES;

                ChangedVelocity();

                Play("roll");

                SoundManager.PlaySoundEffect("hit_ground_1");
            })
                     .Condition(() => (_initPos - Position).Length() >= 112, (state) => _state.ChangeState("Stopped"))
                     .End()
                     .State("Stopped")
                     .Enter((state) =>
            {
                Play("idle");

                velocity = Vector2.Zero;

                SoundManager.PlaySoundEffect("hit_ground_1");
            })
                     .End()
                     .Build();

            _state.ChangeState("Hidden");
        }
示例#23
0
 public Stop_Marker(EntityPreset preset, Player p) : base(preset.Position, 16, 16, Drawing.DrawOrder.BG_ENTITIES)
 {
     visible = false;
 }
示例#24
0
        public GasGuy(EntityPreset preset, Player player)
            : base(preset, preset.Position, "gas_guy", 16, 24, DrawOrder.ENTITIES, 0.6f, true)
        {
            _player = player;

            AddAnimation("float", CreateAnimFrameArray(0, 1), 2, true);
            AddAnimation("release_gas", CreateAnimFrameArray(2), 20, true);
            Play("float");

            drag = new Vector2(30);

            soundDelay    = 0;
            soundDelayMax = (float)(1.5 + GlobalState.RNG.NextDouble());

            gasClouds = new EntityPool <Gas>(3, () => new Gas());

            _state = new StateMachineBuilder()
                     .State <TimerState>("InitialLatency")
                     .Enter((state) =>
            {
                state.Reset();
                state.AddTimer(1.5f, "StartTimer");
                _inDelay = true;
            })
                     .Event("StartTimer", (state) =>
            {
                _state.ChangeState("Normal");
            })
                     .Exit((state) =>
            {
                _inDelay = false;
            })
                     .End()
                     .State <TimerState>("Normal")
                     .Enter((state) =>
            {
                state.Reset();
                state.AddTimer(_didFirstShot ? 5f : 1f, "PreShootTimer");
                Play("float");
            })
                     .Event("PreShootTimer", (state) =>
            {
                Play("release_gas");
                _state.ChangeState("Shoot");
                _didFirstShot = true;
            })
                     .End()
                     .State <TimerState>("Shoot")
                     .Enter((state) =>
            {
                state.Reset();
                state.AddTimer(1.2f, "ShootTimer");
            })
                     .Event("ShootTimer", (state) =>
            {
                Play("shoot");
                _state.ChangeState("Normal");
                SoundManager.PlaySoundEffect("gasguy_shoot");
                gasClouds.Spawn((s) => s.Spawn(this, _player), 3, true);
            })
                     .End()
                     .Build();

            _state.ChangeState("InitialLatency");
        }
示例#25
0
 public Door(EntityPreset preset, Player player, string?sfx = "enter_door")
     : this(preset, player, "doors", 16, 16, sfx)
 {
 }
示例#26
0
 public LeftDoor(EntityPreset preset, Player player)
     : base(preset, player, Facing.LEFT, 16)
 {
 }
示例#27
0
 public GoQuestDoorBlocker(EntityPreset preset, Player p) : base(preset.Position, Drawing.DrawOrder.BACKGROUND)
 {
     visible     = false;
     doorBlocker = new(preset.Position, 16, 16);
     exists      = false;
 }
示例#28
0
        public Annoyer(EntityPreset preset, Player player)
            : base(preset.Position, "annoyer", 16, 16, DrawOrder.ENTITIES)
        {
            MapInteraction = false;
            _preset        = preset;
            _target        = player;
            Solid          = false;
            height         = 7;
            width          = 8;
            offset.X       = 3;
            offset.Y       = 2;

            explosion = new Explosion(Position)
            {
                exists = false
            };

            if (GlobalState.IsCell)
            {
                AddAnimation("flap", CreateAnimFrameArray(6, 7), 4, true);
            }
            else
            {
                int i = preset.Frame == T_SUPER ? 12 : 0;
                AddAnimation("flap", CreateAnimFrameArray(i, i + 1, i + 2, i + 3, i + 4, i + 5), 8, true);
            }
            Play("flap");

            if (preset.Frame == T_SUPER)
            {
                _health = 2;
            }

            fireballs = new EntityPool <Fireball>(preset.Frame == T_SUPER ? 4 : 0, () => new Fireball());

            _state = new StateMachineBuilder()
                     .State <ActiveState>("Active")
                     .Enter((state) => {
                velocity = Vector2.Zero;
                state.ChangeState(start_state);
                start_state = "Approach";         //TODO: Add way of entering nested states(see ChangeState in Hit, needs to go to Approach, not Wait)
            })
                     .Event <CollisionEvent <Player> >("Player", (state, p) => p.entity.ReceiveDamage(1))
                     .Event <CollisionEvent <Broom> >("Hit", (state, b) => {
                velocity = FacingDirection(b.entity.facing) * 150;
                if (velocity.Y < 0)
                {
                    velocity.X = GlobalState.RNG.Next(-30, 31);
                }
                _state.ChangeState("Hit");
            })

                     .Event("Fire", (state) => fireballs.Spawn((f) => f.Spawn(this, _target)))

                     .State <TimerState>("Wait")
                     .Enter((state) =>
            {
                state.Reset();
                state.AddTimer(0.25f, "ApproachCheck");
            })
                     .Event("ApproachCheck", (state) =>
            {
                if ((Position - _target.Position).Length() < 64)
                {
                    state.Parent.ChangeState("Approach");
                }
            })
                     .End()

                     .State("Approach")
                     .Update((state, time) => {
                MathUtilities.MoveTo(ref Position.X, ApproachTarget.X, 36);
                MathUtilities.MoveTo(ref Position.Y, ApproachTarget.Y, 36);
            })
                     .Condition(() => (Position - ApproachTarget).Length() < 2, (state) => state.Parent.ChangeState("Circle"))
                     .Exit((state) => velocity = Vector2.Zero)
                     .End()

                     .State <CirclingState>("Circle")
                     .Enter((state) => state.angle = 0)
                     .Update((state, time) =>
            {
                Position = _target.VisualCenter + new Vector2((float)Math.Cos(state.angle), (float)Math.Sin(state.angle)) * rotation_radius;
            })
                     .Event("Swoop", (state) => state.Parent.ChangeState("Swoop"))
                     .End()

                     .State <SwoopState>("Swoop")
                     .Enter((state) => state.target = Position + 3 * (_target.Position - Position))
                     .Update((state, time) => {   //TODO: make it possible for this to be a Condition
                if (MathUtilities.MoveTo(ref Position.X, state.target.X, 2.5f * 60) & MathUtilities.MoveTo(ref Position.Y, state.target.Y, 2.5f * 60))
                {
                    state.Parent.ChangeState("Approach");
                }
            })
                     .End()
                     .End()

                     .State <TimerState>("Hit")
                     .Enter((state) =>
            {
                SoundManager.PlaySoundEffect("player_hit_1");
                state.Reset();
                Flicker(0.2f);
                if (--_health <= 0)
                {
                    Solid = true;
                    state.AddTimer(0.25f, "Die");
                }
                else
                {
                    state.AddTimer(0.4f, "EndKnockback");
                }
            })
                     .Event("EndKnockback", (state) => _state.ChangeState("Active"))
                     .Event("Die", (state) => {
                exists             = _preset.Alive = false;
                explosion.exists   = true;
                explosion.Position = Position;
                SoundManager.PlaySoundEffect("hit_wall");
            })
                     .Exit((state) =>
            {
                Solid = false;
            })
                     .End()

                     .Build();
            _state.ChangeState("Active");
        }
示例#29
0
        public TeleGuy(EntityPreset preset, Player p)
            : base(preset, preset.Position, "teleport_guy", 16, 24, Drawing.DrawOrder.ENTITIES, 0.7f)
        {
            _player = p;

            offset.Y = 6;
            height   = 16;

            AddAnimation("idle_d", CreateAnimFrameArray(0, 1), 3);
            AddAnimation("idle_r", CreateAnimFrameArray(2, 3), 3); //DEFAULT: RIGHT
            AddAnimation("idle_u", CreateAnimFrameArray(4, 5), 3);
            AddAnimation("idle_l", CreateAnimFrameArray(2, 3), 3);
            AddAnimation("poof", CreateAnimFrameArray(6, 7, 8, 9), 12, false);
            AddAnimation("unpoof", CreateAnimFrameArray(8, 7, 6), 12, false);
            AddAnimation("dying", CreateAnimFrameArray(0));

            Play("idle_d");

            immovable = true;

            _state = new StateMachineBuilder()
                     .State("Idle")
                     .Event <CollisionEvent <Player> >("Player", (state, p) => p.entity.ReceiveDamage(1))
                     .Event <CollisionEvent <Broom> >("Broom", (state, b) =>
            {
                _state.ChangeState("Teleporting");
            })
                     .Update((state, time) =>
            {
                FaceTowards(_player.Position);

                PlayFacing("idle");
            })
                     .End()
                     .State <TimerState>("Teleporting")
                     .Enter((state) =>
            {
                state.Reset();

                SoundManager.PlaySoundEffect("teleguy_up");

                Play("poof");

                state.AddTimer(0.5f, "TeleportTimer");
            })
                     .Event("TeleportTimer", (state) =>
            {
                SoundManager.PlaySoundEffect("teleguy_down");

                atkPoint = Position;

                Teleport();

                Play("unpoof");

                _state.ChangeState("PreAttack");
            })
                     .End()
                     .State <TimerState>("PreAttack")
                     .Enter((state) =>
            {
                state.Reset();

                FaceTowards(_player.Position);

                state.AddTimer(0.5f, "PreAttackTimer");
            })
                     .Event("PreAttackTimer", (state) =>
            {
                PlayFacing("idle");

                _state.ChangeState("Attacking");
            })
                     .End()
                     .State <TimerState>("Attacking")
                     .Enter((state) =>
            {
                state.Reset();

                state.AddTimer(1.5f, "AttackTimer");

                MoveTowards(atkPoint, 60.0f);
            })
                     .Update((state, time) =>
            {
                if ((atkPoint - Position).Length() <= 1)
                {
                    Position = atkPoint;
                    velocity = Vector2.Zero;
                }
            })
                     .Event <CollisionEvent <Player> >("Player", (state, p) => p.entity.ReceiveDamage(1))
                     .Event <CollisionEvent <Broom> >("Broom", (state, b) =>
            {
                if (GlobalState.RNG.NextDouble() < 0.5f)
                {
                    _state.ChangeState("Teleporting");
                }
                else
                {
                    Die();

                    GlobalState.SpawnEntity(new Explosion(this));
                }
            })
                     .Event("AttackTimer", (state) =>
            {
                _state.ChangeState("Idle");
            })
                     .Exit((state) =>
            {
                velocity = Vector2.Zero;
            })
                     .End()
                     .Build();

            _state.ChangeState("Idle");
        }
示例#30
0
 public ElevatorMenu(EntityPreset e) : base(false)
 {
     parent_preset = e;
     SetLabels();
 }