예제 #1
0
        private void OnMouseDown()
        {
            if (UIManager.IsActive)
            {
                return;
            }
            SetColor(m_clicked);
            MENU_FLAGS flags = building == null ? MENU_FLAGS.BUILD : building.Flags;

            EventSystem.RemoveListener <Event_UIBuild>(OnBuild);
            EventSystem.RemoveListener <Event_UIUpgrade>(OnUpgrade);
            EventSystem.RemoveListener <Event_UIWorker>(OnWorker);

            List <GameObject> prefabs = new List <GameObject>();

            if (IsFlagSet(flags, MENU_FLAGS.BUILD))
            {
                prefabs.Add(GameObject.Instantiate(Resources.Load("Prefabs/Build")) as GameObject);
                EventSystem.AddListener <Event_UIBuild>(OnBuild);
            }
            if (IsFlagSet(flags, MENU_FLAGS.UPGRADE))
            {
                prefabs.Add(GameObject.Instantiate(Resources.Load("Prefabs/Upgrade")) as GameObject);
                EventSystem.Dispatch(new Event_UIUpgrade());
            }
            if (IsFlagSet(flags, MENU_FLAGS.WORKER))
            {
                prefabs.Add(GameObject.Instantiate(Resources.Load("Prefabs/Worker")) as GameObject);
            }

            EventSystem.Dispatch(new Event_BuildMenu(prefabs.ToArray()));
            Debug.Log("Mouse down");
        }
예제 #2
0
        public Building(Sprite level1, Sprite level2, Sprite level3, RESOURCE_TYPE type, MENU_FLAGS menuFlags, bool isConnected)
        {
            m_sprites    = new Sprite[3];
            m_sprites[0] = level1;
            m_sprites[1] = level2;
            m_sprites[2] = level3;

            m_workerCats   = new bool[3];
            m_resourceType = type;

            IsConnected = isConnected;
            m_flags     = menuFlags;

            EventSystem.AddListener <Event_DayEnded>(OnDayEnded);
        }
예제 #3
0
 private void RemoveFlag(MENU_FLAGS flag)
 {
     m_flags &= (~flag);
 }
예제 #4
0
 private void AddFlag(MENU_FLAGS flag)
 {
     m_flags |= flag;
 }
예제 #5
0
 private bool IsFlagSet(MENU_FLAGS flags, MENU_FLAGS flag)
 {
     return((flags & flag) == flag);
 }