Пример #1
0
 public static bool OpenChest(GameScreen gs, TileBlock b)
 {
     Item i = GameScreen.Items[ItemId.Gold].Clone();
     i.addToStack(ScreenManager.Rand.Next(6, 24));
     b.setTile(TileBlock.OPEN_CHEST);
     gs.TileMap.dropItem(i, gs.Player);
     return true;
 }
Пример #2
0
 public static bool NewTreasureRoom(GameScreen gs, TileBlock b)
 {
     if (gs.Player.Alive) {
         gs.setRoom(new TileMap(20, 5, MapType.Treasure, gs, gs.TileMap));
         gs.Player.moveTo(new Vector2(0, TileMap.SPRITE_SIZE * 3));
     }
     return true;
 }
Пример #3
0
        public static bool WallHeal(GameScreen gs, TileBlock b)
        {
            if (gs.Player.Stats.HpPercent != 1) {
                gs.Player.heal((int) (gs.Player.Stats.MaxHp * 0.1));
                b.setTile(TileBlock.EMPTYMAGIC_WALL);
            }

            return true;
        }
Пример #4
0
 public static bool MapGoBack(GameScreen gs, TileBlock b)
 {
     if (gs.TileMap.OldMap != null) {
         gs.setRoom(gs.TileMap.OldMap);
         gs.Player.moveTo(gs.TileMap.LeavePoint);
     } else {
         gs.newMainRoom();
     }
     return true;
 }
Пример #5
0
        public Player(GameScreen screen, int x, int y, String name, Sprite s)
            : base(screen, x, y, s, null, 90, 1)
        {
            this.xp = 0;
            this.Name = name;
            this.RoomCount = 0;

            myAttacks = new List<Attack>();
            items = new List<Item>(12);
        }
Пример #6
0
 public static Entity Wraith(int x, int y, GameScreen screen, float scalar=1)
 {
     return new Entity(screen, x, y, screen.SprEntity[EntitySpriteId.Wraith], EntityAIs.Wraith, (int) (45 * scalar), 0.9 * scalar, (int) (8 * scalar), 0.85f,
         new PossibleDrop[] {
             new PossibleDrop(GameScreen.Items[ItemId.SmallPotion], 0.05),
             new PossibleDrop(GameScreen.Items[ItemId.Key], 0.01),
             new PossibleDrop(GameScreen.Items[ItemId.BronzeBody], 0.03),
             new PossibleDrop(GameScreen.Items[ItemId.Gold], 0.25)
         });
 }
Пример #7
0
 public static Entity Warlock(int x, int y, GameScreen screen, float scalar=1)
 {
     return new Entity(screen, x, y, screen.SprEntity[EntitySpriteId.Warlock], EntityAIs.Basic, (int) (60 * scalar), 0.9 * scalar, (int) (6 * scalar), 1f,
         new PossibleDrop[] {
             new PossibleDrop(GameScreen.Items[ItemId.SmallPotion], 0.05),
             new PossibleDrop(GameScreen.Items[ItemId.BronzeHead], 0.03),
             new PossibleDrop(GameScreen.Items[ItemId.BronzeLegs], 0.03),
             new PossibleDrop(GameScreen.Items[ItemId.Gold], 0.25)
         });
 }
Пример #8
0
 public static bool NewMainRoom(GameScreen gs, TileBlock b)
 {
     int idx = gs.Player.getItemIndex(ItemId.Key);
     if (gs.Player.Alive && idx >= 0) {
         gs.Player.addXP(20);
         gs.Player.heal(10);
         gs.Player.removeItem(idx);
         gs.newMainRoom();
     }
     return true;
 }
Пример #9
0
 public static Entity Skeleton_King(int x, int y, GameScreen screen, float scalar=1)
 {
     String name = RName.newCoolName();
     Entity e = new Entity(screen, x, y, screen.SprEntity[EntitySpriteId.Skeleton_King], EntityAIs.Skeleton_King, 120, 1.5, 20, 1.1f,
         new PossibleDrop[] {
             new PossibleDrop(new Item(GameScreen.Items[ItemId.IronHead], name + "'s Helm"), 0.1),
             new PossibleDrop(new Item(GameScreen.Items[ItemId.IronBody], name + "'s Platebody"), 0.1),
             new PossibleDrop(new Item(GameScreen.Items[ItemId.IronLegs], name + "'s Legs"), 0.1),
             new PossibleDrop(GameScreen.Items[ItemId.SmallPotion], 0.33),
             new PossibleDrop(GameScreen.Items[ItemId.Gold], 0.5)
         });
     e.Name = name;
     return e;
 }
Пример #10
0
        public TileMap(int width, int height, MapType type, GameScreen screen, TileMap oldMap)
        {
            this.GScreen = screen;
            this.Width = width;
            this.Height = height;
            this.OldMap = oldMap;

            // Init
            numEntities = 0;
            DeadEntities = new List<Entity>();

            Map = new List<TileBlock>();
            Entities = new List<Entity>();
            GameObjects = new List<GameObject>();
            Attacks = new List<Attack>();
            HitTexts = new List<HitText>();

            switch (type) {
            case MapType.Treasure:
                setBackground(GameScreen.Backgrounds[BackgroundId.Cave1]);
                for (int w = 0; w < width; w++) {
                    for (int h = 0; h < height; h++) {
                        if (h == height - 2 && w == 0) {
                            Map.Add(TileBlock.IRON_DOOR.Clone().addEvent(TileBlockEvent.MapGoBack));
                        } else if (h == 0 || h == height - 1) {
                            Map.Add(TileBlock.STONE_WALL.Clone());
                        } else if (w > 2 && w < width - 2 && h == height - 2 && ScreenManager.Rand.Next(width / 3) == 0) {
                            Map.Add(TileBlock.CLOSED_CHEST.Clone());
                        } else {
                            Map.Add(TileBlock.NONE.Clone());
                        }
                    }
                }
                break;
            case MapType.Hall:
            default: // Hall Way
                setBackground(GameScreen.Backgrounds[BackgroundId.Cave1]);
                int specialCount = 0;
                for (int w = 0; w < width; w++)
                    for (int h = 0; h < height; h++) {
                        if (h == height - 2 && w == width - 1) {
                            Map.Add(TileBlock.DOOR.Clone());
                            addRandomEntity(w * SPRITE_SIZE, h * SPRITE_SIZE, screen);
                        } else if (h == 0 || h == height - 1) {
                            Map.Add(TileBlock.STONE_WALL.Clone());
                        } else if (w > 3 && w < width - 2 && h == height - 2 && ScreenManager.Rand.Next(25) == 0) {
                            Map.Add(TileBlock.STONE_WALL.Clone());
                        } else if (w > 3 && w < width - 2 && h == height - 2 && ScreenManager.Rand.Next(25) == 0) {
                            Map.Add(TileBlock.STONE2_WALL.Clone());
                        } else if (specialCount == 0 && w > 2 && h == height - 2 && ScreenManager.Rand.Next(150) == 0) {
                            specialCount++;
                            Map.Add(TileBlock.HPPOOL.Clone());
                        } else if (specialCount == 0 && w > 2 && h == height - 2 && ScreenManager.Rand.Next(200) == 0) {
                            specialCount++;
                            Map.Add(TileBlock.IRON_DOOR.Clone().addEvent(TileBlockEvent.NewTreasureRoom));
                        } else {
                            Map.Add(TileBlock.NONE.Clone());

                            if (h == height - 2 && w > 4 && ScreenManager.Rand.Next(12) == 0)
                                addRandomEntity(w * SPRITE_SIZE, h * SPRITE_SIZE, screen);
                        }
                    }
                break;
            }
        }
Пример #11
0
        public void addRandomEntity(int x, int y, GameScreen screen)
        {
            Entity e;
            int rand = ScreenManager.Rand.Next(500);
            if (rand < 10)
                e = EntityFactory.Skeleton_King(x, y, screen, 1 + (screen.Player.RoomCount/30f)); // After 30 rooms twice as hard
            else if (rand < 255)
                e = EntityFactory.Wraith(x, y, screen, 1 + (screen.Player.RoomCount/30f));
            else
                e = EntityFactory.Warlock(x, y, screen, 1 + (screen.Player.RoomCount/30f));

            addEntity(e);
        }
Пример #12
0
 public static bool Nothing(GameScreen gs, TileBlock b)
 {
     return false;
 }
Пример #13
0
        public void interact(GameScreen gs)
        {
            // Give player all items on this tile
            foreach (GameObject o in gameObjects) {
                if (o is EItem) {
                    bool added = gs.Player.addItem(((EItem) o).Item);
                    if (added) {
                        o.SlatedToRemove = true;
                    }
                }
            }

            var rmnEvents = new Queue<Func<GameScreen,TileBlock,bool>>(intEvents.Count);
            // Run the last event added first
            foreach (var evnt in intEvents) {
                bool remove = evnt(gs, this);
                if (!remove) {
                    rmnEvents.Enqueue(evnt);
                }
            }
            // Set the events to the remaining events
            intEvents = rmnEvents;

            // Remove game objects marked for removal
            clearObjects(new Predicate<GameObject>(TileMap.DoRemoveGameObject));
        }
Пример #14
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);
        }
Пример #15
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");
        }