Exemple #1
0
        public TeamManagement(string name, GUIComponent parent, int rx, int ry) : base(name, parent, rx, ry)
        {
            background = Global.content.Load <Texture2D>("TeamManagementBackground");
            frame      = Global.content.Load <Texture2D>("TeamManagementFrame");
            font16     = Global.content.Load <SpriteFont>("neodgm12");
            full       = false;
            player     = Global.world.GetPlayer();

            // Prepare hero socket
            frontGroup  = new DragSocketGroup("HeroFrontGroup", this, FRONTSTART_X, FRONTSTART_Y, Player.HEROFRONT_MAX);
            behindGroup = new DragSocketGroup("HeroBehindGroup", this, FRONTSTART_X, BEHINDSTART_Y, Player.HEROBEHIND_MAX);
            storedGroup = new DragSocketGroup("HeroStoredGroup", this, STORESTART_X, STORESTART_Y, Player.HEROSTORED_MAX);
            components.Add(frontGroup);
            components.Add(behindGroup);
            components.Add(storedGroup);

            for (int i = 0; i < Player.HEROSTORED_MAX; i++)
            {
                storedGroup.AddSocket(i, new HeroSummarySocket("HeroStored", this, STORE_GAP * i, 0,
                                                               new string[] { "HeroFront", "HeroBehind" }));
            }

            // Prepare item socket
            itemGroup = new DragSocketGroup("ItemGroup", this, ITEMSTART_X, ITEMSTART_Y, Player.ITEM_MAX);
            components.Add(itemGroup);

            for (int row = 0; row < Player.ITEM_HEIGHT; row++)
            {
                for (int col = 0; col < Player.ITEM_WIDTH; col++)
                {
                    itemGroup.AddSocket(col + row * Player.ITEM_WIDTH, new ItemSocket("ItemSocket", this,
                                                                                      ITEM_GAP * col, ITEM_GAP * row, col, row));
                }
            }

            // Prepare skill icons
            skills = new SkillIcon[5];
            for (int i = 0; i < Player.SKILL_MAX; i++)
            {
                skills[i] = new SkillIcon("Skill" + i, this, SKILLSTART_X + SKILL_GAP * i, SKILLSTART_Y);
                components.Add(skills[i]);
            }
        }
Exemple #2
0
        private void SetHeros()
        {
            // Set sockets
            for (int i = 0; i < Player.HEROFRONT_MAX; i++)
            {
                if (i < player.HeroFrontAmount + 1)
                {
                    frontGroup.AddSocket(i, new HeroSummarySocket("HeroFront", this, TEAM_GAP * i, 0,
                                                                  new string[] { "HeroBehind", "HeroStored" }));
                }
                else
                {
                    frontGroup.RemoveSocket(i);
                }
            }
            for (int i = 0; i < Player.HEROBEHIND_MAX; i++)
            {
                if (i < player.HeroBehindAmount + 1)
                {
                    behindGroup.AddSocket(i, new HeroSummarySocket("HeroBehind", this, TEAM_GAP * i, 0,
                                                                   new string[] { "HeroFront", "HeroStored" }));
                }
                else
                {
                    behindGroup.RemoveSocket(i);
                }
            }

            // Fill HeroSummarys
            List <HeroSummary> currentList = new List <HeroSummary>();

            foreach (GUIComponent component in frontGroup)
            {
                if (component is HeroSummary)
                {
                    currentList.Add((HeroSummary)component);
                }
            }
            foreach (GUIComponent component in behindGroup)
            {
                if (component is HeroSummary)
                {
                    currentList.Add((HeroSummary)component);
                }
            }
            foreach (GUIComponent component in storedGroup)
            {
                if (component is HeroSummary)
                {
                    currentList.Add((HeroSummary)component);
                }
            }

            frontCount = 0; behindCount = 0; storedCount = 0;
            foreach (Hero hero in player.heros)
            {
                bool exist = false;
                foreach (HeroSummary summary in currentList)
                {
                    if (summary.hero == hero) // If herosummary is exist, move it on right place.
                    {
                        exist = true;
                        if (summary.parent.name != "Hero" + hero.defaultFighterState.ToString())
                        {
                            ChangeSummaryGroup(summary, hero.defaultFighterState);
                        }
                        switch (hero.defaultFighterState)
                        {
                        case FighterState.Front: frontCount++; break;

                        case FighterState.Behind: behindCount++; break;

                        case FighterState.Stored: storedCount++; break;

                        default: throw new Exception("Invalid Hero State.");
                        }
                    }
                }
                if (!exist) // If doesn't exist, Create one.
                {
                    switch (hero.defaultFighterState)
                    {
                    case FighterState.Front:
                        frontGroup.SetContent(frontCount,
                                              new HeroSummary(hero.name + "Summary", null, 0, 0, hero), true);
                        frontCount++; break;

                    case FighterState.Behind:
                        behindGroup.SetContent(behindCount,
                                               new HeroSummary(hero.name + "Summary", null, 0, 0, hero), true);
                        behindCount++; break;

                    case FighterState.Stored:
                        storedGroup.SetContent(storedCount,
                                               new HeroSummary(hero.name + "Summary", null, 0, 0, hero), true);
                        storedCount++; break;
                    }
                }
            }
        }