示例#1
0
        private ItemOnFloor GenerateItem(EItemType itemType)
        {
            ItemOnFloor item = null;

            switch (itemType)
            {
            case EItemType.PARCHMENT:
                item = new ItemOnFloor(Content.Load <Texture2D>("Images/Parchment"), itemType);
                break;

            case EItemType.KEY_1:
                item = new ItemOnFloor(Content.Load <Texture2D>("Images/Key1"), itemType);
                break;

            case EItemType.KEY_2:
                item = new ItemOnFloor(Content.Load <Texture2D>("Images/Key2"), itemType);
                break;

            default:
                break;
            }

            if (item != null)
            {
                item.Position = map.GetRandomFreePosition(0, map.Width - 1, 0, map.Height - 1);
                item.IsActive = false;
                return(item);
            }

            return(null);
        }
示例#2
0
        void InitGame()
        {
            if (listEntities != null)
            {
                listEntities.Clear();
            }

            if (uiItems != null)
            {
                foreach (var item in uiItems)
                {
                    item.IsActive = false;
                }
            }

            currentItemType = EItemType.NONE;

            // init the player position with the one in the map
            player.Position  = map.PlayerPosition;
            player.AnimState = Player.EAnimState.WALK_DOWN;

            npc          = new Sprite(Content.Load <Texture2D>("Images/Npc"));
            npc.Position = map.NpcPosition;
            npc.IsActive = false;

            ItemOnFloor parchment = GenerateItem(EItemType.PARCHMENT);

            listEntities.Add(parchment);
            parchment.IsActive = false;

            listEntities.Add(npc);
            listEntities.Add(player);

            victoryText.IsActive = false;
            bWin = false;
            map.EnableDarkMode = true;
        }