示例#1
0
        public Entity(SerializationInfo info, StreamingContext cntxt)
            : base(info, cntxt)
        {
            Name = (string) info.GetValue("Entity_Name", typeof(string));
            Equipment = (Equipment) info.GetValue("Entity_Equipment", typeof(Equipment));
            Stats = (EntityStats) info.GetValue("Entity_Stats", typeof(EntityStats));
            XPValue = (int) info.GetValue("Entity_XPValue", typeof(int));
            facing = (Direction) info.GetValue("Entity_Facing", typeof(Direction));
            MAX_SPEED = (float) info.GetValue("Entity_MaxSpeed", typeof(float));
            msVel = (Vector2) info.GetValue("Entity_MsVel", typeof(Vector2));
            bounds = (EntityBounds) info.GetValue("Entity_EBounds", typeof(EntityBounds));
            State = (EntityState) info.GetValue("Entity_State", typeof(EntityState));

            // Init entity in loaded classes
            Stats.setEntity(this);
            EBounds.setEntity(this);
            Equipment.setEntity(this);

            // Un-saved values
            GScreen = (GameScreen) ScreenManager.getScreen(ScreenId.Game);
            lastHitPart = EntityPart.Body;
            jumpDelay = attackDelay = showHpTicks = 0;
            speedMultiplier = MAX_SPEED;
            pDrops = new PossibleDrop[0];
            sprite.setFrame(250, 3);
        }
示例#2
0
        public Entity(GameScreen screen, int x, int y, Sprite s, Func<Entity, TileMap, bool> ai, 
            int hp=75, double ap=1, int xp=6, float speed=1, PossibleDrop[] pDrops=null)
            : base(s, x, y)
        {
            this.ai = ai;
            GScreen = screen;
            Name = RName.newName();
            bounds = new EntityBounds(this, x, y, (int) TileMap.SPRITE_SIZE, 12, 14, 6, 24);
            State = EntityState.Standing;
            msVel = new Vector2(0, 0);
            facing = Direction.Right;
            jumpDelay = attackDelay = showHpTicks = 0;
            MAX_SPEED = speedMultiplier = speed;

            XPValue = xp;

            // Stats
            Equipment = new Equipment(this);
            Stats = new EntityStats(this, hp, (float) ap);

            // Initialize drops, if none given empty array
            this.pDrops = (pDrops == null) ? new PossibleDrop[0] : pDrops;

            // Due to a quirk in the code the frame count here must be one more than actual
            sprite.setFrame(250, 3);
            if (!sprite.hasSpriteParts(SpriteParts.Entity))
                throw new ArgumentException("The sprite passed is not an Entity sprite");
        }