void Awake()
        {
            unit = GetComponent <RTSUnit>();

            unit.onMakeActiveUnit += (bool active) => {
                if (active)
                {
                    menu = RTSUI.active.ShowMenu();
                    for (int i = 0; i < items.Length; i++)
                    {
                        var item = items[i];
                        menu.AddItem(item.menuItem, () => {
                            if (queue.Count >= maxQueueSize)
                            {
                                return;
                            }
                            if (RTSManager.instance.GetPlayer(1).resources.GetResource(RTSUnit.Type.ResourceCrystal) < item.cost)
                            {
                                RTSManager.instance.audio.Play(RTSUI.active.notEnoughResources);
                            }
                            else
                            {
                                RTSManager.instance.GetPlayer(1).resources.AddResource(RTSUnit.Type.ResourceCrystal, -item.cost);
                                AddToQueue(item);
                            }
                        });
                    }
                }
                else if (menu != null)
                {
                    menu.Hide();
                }
            };
        }
示例#2
0
        void Awake()
        {
            unit = GetComponent <RTSUnit>();

            unit.onMakeActiveUnit += (bool active) => {
                if (active)
                {
                    menu = RTSUI.active.ShowMenu();
                    for (int i = 0; i < items.Length; i++)
                    {
                        var item = items[i];
                        menu.AddItem(item.menuItem, () => {
                            RTSUI.active.StartBuildingPlacement(item);
                        });
                    }
                }
                else if (menu != null)
                {
                    menu.Hide();
                }
            };
        }