Пример #1
0
        public void addPlayer(PlayerInfo player = null)
        {
            if (player == null)
                playerlist[count] = new PlayerInfo();
            else
                playerlist[count] = player;

            this.count++;
            this.activeSlot = count -1;
        }
        public CharacterSelectionScreen(Game game)
            : base(game)
        {
            // select Resource services
            spriteBatch = ResourceManager.GetInstance.spriteBatch;
            Content = ResourceManager.GetInstance.Content;

            // select spritefont
            playerNameFont = Content.Load<SpriteFont>(@"font\Arial_12px");

            // define components
            bgcomp1 = new BackgroundComponent(game, Content.Load<Texture2D>(@"gfx\background\background1"));
            bgcomp2 = new BackgroundComponent(game, Content.Load<Texture2D>(@"gfx\background\character_selection"));
            bgcomp3 = new BackgroundComponent(game, Content.Load<Texture2D>(@"gfx\background\frame2"));
            menu = new MenuComponent(game, Content.Load<SpriteFont>(@"font\Comic_Sans_18px"));

            // add components
            Components.Add(bgcomp1);
            Components.Add(bgcomp2);
            Components.Add(bgcomp3);

            // menu options
            menu.SetMenuItems(menuItems);
            menu.StartIndex = 0;
            menu.Position = new Vector2(665, 230);
            menu.NormalColor = Color.White;
            menu.HiliteColor = Color.Red;
            menu.MenuItemSpace = 25;
            menu.Rotation[2] = 0.25f;
            menu.Offset[2] = new Vector2(0, -5);
            menu.Offset[3] = new Vector2(-8, 23);
            menu.Offset[4] = new Vector2(-526, -22);
            menu.EndIndex = 3;

            // player sprite
            playersprite = new PlayerSprite(100, 123);
            player = new PlayerInfo();
            playersprite.Player = this.player;

            // player offsets
            for (int i = 0; i < 6; i++)
                this.spriteOfset[i] = playersprite.getoffset(i);

            // options
            option_board = Content.Load<Texture2D>(@"gfx\screens\screenobjects\option_board");
            screen_board = Content.Load<Texture2D>(@"gfx\screens\screenobjects\next_board");

            // slots
            slot = Content.Load<Texture2D>(@"gfx\screens\screenobjects\empty_character_slot");
        }
Пример #3
0
        private void incomingCharSelect(playerData playerdata)
        {
            bool found = false;
            for(int i = 0; i < PlayerStore.Instance.playerlist.Length; i++)
            {
                if (PlayerStore.Instance.playerlist[i] != null)
                {
                    if (PlayerStore.Instance.playerlist[i].Name == playerdata.Name) // avoid duplicates
                    {
                        found = true;
                        break;
                    }
                }
            }

            if (!found)
            {
                PlayerInfo player = new PlayerInfo();

                player.AccountID = playerdata.AccountID;
                player.CharacterID = playerdata.CharacterID;

                player.Name = playerdata.Name;
                player.skin_color = getColor(playerdata.skincol);
                player.faceset_sprite = playerdata.facespr;
                player.hair_sprite = playerdata.hairspr;
                player.hair_color = getColor(playerdata.hailcol);

                if (playerdata.armor != null)
                    if (ItemStore.Instance.item_list.FindAll(x => x.itemName == playerdata.armor).Count > 0)
                        player.equipment.addItem(ItemStore.Instance.item_list.Find(x => x.itemName == playerdata.armor));
                if (playerdata.weapon != null)
                    if (ItemStore.Instance.item_list.FindAll(x => x.itemName == playerdata.weapon).Count > 0)
                        player.equipment.addItem(ItemStore.Instance.item_list.Find(x => x.itemName == playerdata.weapon));
                if (playerdata.headgear != null)
                    if (ItemStore.Instance.item_list.FindAll(x => x.itemName == playerdata.headgear).Count > 0)
                        player.equipment.addItem(ItemStore.Instance.item_list.Find(x => x.itemName == playerdata.headgear));

                PlayerStore.Instance.addPlayer(player);
            }
        }
Пример #4
0
        public void ChangeJobClass(PlayerInfo activePlayer)
        {
            // Remove Current Player
            for (int i = 0; i < listEntity.Count; i++)
                if (listEntity[i] is PlayerSprite)
                    listEntity.Remove(listEntity[i]);

            // Switch playerSprite
            switch (activePlayer.Jobclass)
            {
                case "Bowman":
                    playerSprite = new Bowman(
                    (int)map.ObjectGroups["Hero"].Objects["hero"].X,
                    (int)map.ObjectGroups["Hero"].Objects["hero"].Y,
                    new Vector2(map.TileWidth, map.TileHeight));
                    break;
                case "Warrior":
                    playerSprite = new Warrior(
                    (int)map.ObjectGroups["Hero"].Objects["hero"].X,
                    (int)map.ObjectGroups["Hero"].Objects["hero"].Y,
                    new Vector2(map.TileWidth, map.TileHeight));
                    break;
                case "Magician":
                    playerSprite = new Magician(
                    (int)map.ObjectGroups["Hero"].Objects["hero"].X,
                    (int)map.ObjectGroups["Hero"].Objects["hero"].Y,
                    new Vector2(map.TileWidth, map.TileHeight));
                    break;
                case "Thief":
                    playerSprite = new Thief(
                    (int)map.ObjectGroups["Hero"].Objects["hero"].X,
                    (int)map.ObjectGroups["Hero"].Objects["hero"].Y,
                    new Vector2(map.TileWidth, map.TileHeight));
                    break;
                case "Pirate":
                    playerSprite = new Pirate(
                    (int)map.ObjectGroups["Hero"].Objects["hero"].X,
                    (int)map.ObjectGroups["Hero"].Objects["hero"].Y,
                    new Vector2(map.TileWidth, map.TileHeight));
                    break;
                default:
                    break;
            }

            // Add new player Instance to worldmap
            listEntity.Add(playerSprite);
        }
        public bool initize()
        {
            if (PlayerStore.Instance.Count < 6)
            {
                phase = Phase.Name;
                newPlayer = new PlayerInfo();
                playersprite.Player = this.newPlayer;

                // Equip Beginner Clothes + Knife
                if (newPlayer.equipment.item_list.FindAll(delegate(Item item)
                { return item.Slot == ItemSlot.Bodygear; }).Count == 0)
                    newPlayer.equipment.addItem(ItemStore.Instance.getItem(2301));
                if (newPlayer.equipment.item_list.FindAll(delegate(Item item)
                { return item.Slot == ItemSlot.Weapon; }).Count == 0)
                    newPlayer.equipment.addItem(ItemStore.Instance.getItem(1200));

                // Check player + equipment offsets
                for (int i = 0; i < 7; i++)
                    this.newPlayer.spriteOfset[i] = playersprite.getoffset(i);

                // initize properties
                for (int i = 0; i <= properties.Length - 1; i++)
                    properties[i].SelectedIndex = 0;

                keyboardiput.Activate(newPlayer.Name.ToString());

                return true;
            }
            else
            {
                return false;
            }
        }
Пример #6
0
        private void itemConsume(PlayerInfo Consumer)
        {
            Item selectedItem = itemlist.menuItemsnoDupes[itemlist.SelectedIndex];

            if (selectedItem.Type == ItemType.Consumable)
            {
                string script = selectedItem.Script;

                // remove beginning and ending spaces

                script = Regex.Replace(script, "{", "");
                script = Regex.Replace(script, "}", "");
                script = Regex.Replace(script, " ", "");

                // call static class that handles item scripts
                // use the script interpretter to read the content

                ScriptInterpreter.Instance.loadScript(script);
                ScriptInterpreter.Instance.StartReading = true;
                ScriptInterpreter.Instance.Property = null;
                ScriptInterpreter.Instance.Values.Clear();

                ScriptInterpreter.Instance.readScript();

                // clear script, reset to begin
                ScriptInterpreter.Instance.clearInstance();
            }

            itemRemove();

            itemOptions = false;
            itemSelection = true;
        }