Пример #1
0
        public SuburbWalker(EntityPreset preset, Player p) : base(preset.Position, "suburb_walkers", 16, 16, Drawing.DrawOrder.ENTITIES)
        {
            _preset = preset;

            int off = preset.Frame * 9;

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

            velocity = Vector2.UnitY * 20;
            Play("walk_d");

            walk_t_max = 1f + (float)GlobalState.RNG.NextDouble();
            walk_t     = walk_t_max;

            blood = new(Vector2.Zero, "suburb_walkers", 16, 16, Drawing.DrawOrder.BG_ENTITIES);
            blood.AddAnimation("a", CreateAnimFrameArray(63, 64, 65, 66), 3, false);
            blood.Play("a");
            blood.exists = false;

            if (_preset.Alive == false)
            {
                velocity = Vector2.Zero;
                Play("dead");
                SpawnBlood();
            }
        }
    bool PrepareMove(Entity player, ICollection <Entity> entitiesInSpot)
    {
        if (entitiesInSpot.ContainsComponent(ComponentIds.AIMove))
        {
            // enemy there, can't do anything
            return(false);
        }

        // handle walls
        Entity wall = null;

        if (entitiesInSpot.ContainsComponent(ComponentIds.Destructible, out wall))
        {
            wall.DamageDestructible();
            pool.PlayAudio(player.audioAttackSource);

            if (player.hasView)
            {
                player.AddAnimation(Animation.playerChop);
            }
            // nothing to do now that we've chopped
            return(false);
        }

        // otherwise we can move
        return(true);
    }
Пример #3
0
        private void LoadAnimations(ContentReader input, Entity entity, int animationCount)
        {
            for (int i = 0; i < animationCount; i++)
            {
                // i on id
                string name    = input.ReadString();
                int    length  = input.ReadInt32();
                bool   looping = input.ReadBoolean();

                int mainlineKeysCount = input.ReadInt32();
                int timelineCount     = input.ReadInt32();
                SpriterAnimation anim = new SpriterAnimation(
                    new Mainline(mainlineKeysCount),
                    i,
                    name,
                    length,
                    looping,
                    timelineCount
                    );
                entity.AddAnimation(anim);

                LoadMainlineKeys(input, anim.Mainline, mainlineKeysCount);
                LoadTimelines(input, anim, entity, timelineCount);
                anim.Prepare();
            }
        }
Пример #4
0
        public Tentacle(int index) : base(Vector2.Zero, "red_boss_warning", 10, 10, Drawing.DrawOrder.ENTITIES)
        {
            AddAnimation("move", CreateAnimFrameArray(0, 1), 8);
            Play("move");
            t_index   = index;
            immovable = true;

            tentacle = new(Vector2.Zero, "red_boss_tentacle", 10, 64, Drawing.DrawOrder.ENTITIES);
            tentacle.AddAnimation("move", CreateAnimFrameArray(0, 1), 8);
            tentacle.Play("move");
            tentacle.exists = false;
        }
Пример #5
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();
        }
Пример #6
0
    void Attack(Entity entity)
    {
        _processing = true;
        sound(entity);
        entity.AddAnimation(entity.view.gameObject.tag + Res.animations.Attack);
        var x = entity.view.gameObject.transform.position.x + entity.attack.dir.x;
        var y = entity.view.gameObject.transform.position.y + entity.attack.dir.y;

        _pool.gameBoardCache.grid[(int)x, (int)y].IsGetHit(true);
        entity.delay(0.1f, () =>
        {
            TestLoadConfig.log.Trace(string.Format("{0} AttackComponent remove.", entity.view.gameObject.name));
            entity.RemoveAttack();
            if (_attackEntities.Count > 0)
            {
                Attack(_attackEntities.Dequeue());
            }
            else
            {
                _processing = false;
            }
        });
    }
    bool PrepareMove(Entity enemy, ICollection <Entity> entitiesInSpot)
    {
        // handle player
        Entity player;

        if (enemy.hasFoodDamager &&
            entitiesInSpot.ContainsComponent(ComponentIds.Controllable, out player))
        {
            pool.AddToFoodBag(-enemy.foodDamager.points);
            pool.PlayAudio(enemy.audioAttackSource);
            enemy.AddAnimation(Animation.enemyAttack);
            player.AddAnimation(Animation.playerHit);
            // can't move
            return(false);
        }

        if (entitiesInSpot.Count == 1 &&
            entitiesInSpot.ContainsComponent(ComponentIds.Food))
        {
            return(true);
        }

        return(false);
    }
Пример #8
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");
        }