Example #1
0
        private void ShowBuildSubMenu()
        {
            // Remove all old components
            ClearComponents();

            isInSubmenu = true;

            healthBars.Clear();

            // No entities? Then just exit
            if (currentEntities == null || currentEntities.Length == 0)
            {
                return;
            }

            if (currentEntities.Length == 1)
            {
                ShowSingleUI();
            }
            else
            {
                ShowMultiUI();
            }

            int buttonIndex = 0;

            if (ShowCancel)
            {
                UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Cancel");
                btn.OnMouseUpInside += (position) => { RebuildUI(); };
                SetButtonPosition(btn, 5);
                AddComponent(btn);

                buttonIndex++;
            }
        }
Example #2
0
        private void ShowBuildSubMenu()
        {
            // Remove all old components
             ClearComponents();

             isInSubmenu = true;

             healthBars.Clear();

             // No entities? Then just exit
             if (currentEntities == null || currentEntities.Length == 0)
            return;

             if (currentEntities.Length == 1)
            ShowSingleUI();
             else
            ShowMultiUI();

             int buttonIndex = 0;
             if (ShowCancel)
             {
            UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Cancel");
            btn.OnMouseUpInside += (position) => { RebuildUI(); };
            SetButtonPosition(btn, 5);
            AddComponent(btn);

            buttonIndex++;
             }
        }
Example #3
0
        private void RebuildUI()
        {
            // Remove all old components
             ClearComponents();

             isInSubmenu = false;

             healthBars.Clear();

             // No entities? Then just exit
             if (currentEntities == null || currentEntities.Length == 0)
            return;

             if (currentEntities.Length == 1)
            ShowSingleUI();
             else
            ShowMultiUI();

             int buttonIndex = 0;

             if (ShowMove)
             {
            UISpriteButton moveBtn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Move" + race);
            moveBtn.OnMouseUpInside += (position) => { SetMapUnitOrder(MapUnitOrder.Move); };
            SetButtonPosition(moveBtn, buttonIndex);
            AddComponent(moveBtn);

            buttonIndex++;
             }
             if (ShowStop)
             {
            UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Shield1" + (race == Race.Humans ? "" : "Orcs"));
            btn.OnMouseUpInside += (position) => { Stop(); };
            SetButtonPosition(btn, buttonIndex);
            AddComponent(btn);

            buttonIndex++;
             }
             if (ShowAttack)
             {
            UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Sword1");
            btn.OnMouseUpInside += (position) => { SetMapUnitOrder(MapUnitOrder.Attack); };
            SetButtonPosition(btn, buttonIndex);
            AddComponent(btn);

            buttonIndex++;
             }
             if (ShowRepair)
             {
            UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Repair");
            btn.OnMouseUpInside += (position) => { SetMapUnitOrder(MapUnitOrder.Repair); };
            SetButtonPosition(btn, buttonIndex);
            AddComponent(btn);

            buttonIndex++;
             }
             if (ShowHarvest)
             {
            UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Harvest");
            btn.OnMouseUpInside += (position) => { SetMapUnitOrder(MapUnitOrder.Harvest); };
            SetButtonPosition(btn, buttonIndex);
            AddComponent(btn);

            buttonIndex++;
             }
             if (ShowBuild)
             {
            UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Build");
            btn.OnMouseUpInside += (position) => { ShowBuildSubMenu(); };
            SetButtonPosition(btn, buttonIndex);
            AddComponent(btn);

            buttonIndex++;
             }
             if (ShowCancel)
             {
            UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Cancel");
            btn.OnMouseUpInside += (position) => { RebuildUI(); };
            SetButtonPosition(btn, 6);
            AddComponent(btn);

            buttonIndex++;
             }

             if (currentEntities.Length == 1)
            currentEntities[0].AddCustomUI(this);
        }
Example #4
0
        private void RebuildUI()
        {
            // Remove all old components
            ClearComponents();

            isInSubmenu = false;

            healthBars.Clear();

            // No entities? Then just exit
            if (currentEntities == null || currentEntities.Length == 0)
            {
                return;
            }

            if (currentEntities.Length == 1)
            {
                ShowSingleUI();
            }
            else
            {
                ShowMultiUI();
            }

            int buttonIndex = 0;

            if (ShowMove)
            {
                UISpriteButton moveBtn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Move" + race);
                moveBtn.OnMouseUpInside += (position) => { SetMapUnitOrder(MapUnitOrder.Move); };
                SetButtonPosition(moveBtn, buttonIndex);
                AddComponent(moveBtn);

                buttonIndex++;
            }
            if (ShowStop)
            {
                UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Shield1" + (race == Race.Humans ? "" : "Orcs"));
                btn.OnMouseUpInside += (position) => { Stop(); };
                SetButtonPosition(btn, buttonIndex);
                AddComponent(btn);

                buttonIndex++;
            }
            if (ShowAttack)
            {
                UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Sword1");
                btn.OnMouseUpInside += (position) => { SetMapUnitOrder(MapUnitOrder.Attack); };
                SetButtonPosition(btn, buttonIndex);
                AddComponent(btn);

                buttonIndex++;
            }
            if (ShowRepair)
            {
                UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Repair");
                btn.OnMouseUpInside += (position) => { SetMapUnitOrder(MapUnitOrder.Repair); };
                SetButtonPosition(btn, buttonIndex);
                AddComponent(btn);

                buttonIndex++;
            }
            if (ShowHarvest)
            {
                UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Harvest");
                btn.OnMouseUpInside += (position) => { SetMapUnitOrder(MapUnitOrder.Harvest); };
                SetButtonPosition(btn, buttonIndex);
                AddComponent(btn);

                buttonIndex++;
            }
            if (ShowBuild)
            {
                UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Build");
                btn.OnMouseUpInside += (position) => { ShowBuildSubMenu(); };
                SetButtonPosition(btn, buttonIndex);
                AddComponent(btn);

                buttonIndex++;
            }
            if (ShowCancel)
            {
                UISpriteButton btn = new UISpriteButton(new Sprite(WarFile.GetSpriteResource(361)), "Cancel");
                btn.OnMouseUpInside += (position) => { RebuildUI(); };
                SetButtonPosition(btn, 6);
                AddComponent(btn);

                buttonIndex++;
            }

            if (currentEntities.Length == 1)
            {
                currentEntities[0].AddCustomUI(this);
            }
        }