Example #1
0
File: GUI.cs Project: JJJohan/RTS
        public static void InitGUI()
        {
            // Init
            m_resolution = new Vector2(Screen.width, Screen.height);

            // Area Selection Texture
            m_guiSelect = (Texture2D)UnityEngine.Resources.Load("Textures/gray");

            // Side Panel
            m_sidePanel = new SidePanel();
            m_sidePanel.BuildingEvent += new SidePanel.BuildingHandler(Main.CreateBuildingGhost);
        }
Example #2
0
 public void QueueUnit(SidePanel a_sidePanel, UnitArgs a_events)
 {
     if (a_events.create)
     {
         QueuedUnit unit = new QueuedUnit();
         unit.prefab = a_events.prefab;
         unit.buildTime = a_events.prefab.buildTime;
         unit.percentage = 0f;
         m_queue.Add(unit);
     }
     else
     {
         for (int i = m_queue.Count - 1; i >= 0; --i)
         {
             if (m_queue[i].prefab.ID == a_events.prefab.ID)
             {
                 m_queue.Remove(m_queue[i]);
                 break;
             }
         }
     }
 }
Example #3
0
File: Main.cs Project: JJJohan/RTS
        // Create a ghost building to show where it is being placed.
        public static void CreateBuildingGhost(SidePanel a_sidePanel, BuildingArgs a_events)
        {
            int cost = a_events.prefab.cost;
            if (InputHandler.m_cursorBuilding)
                cost += InputHandler.m_cursorBuilding.GetComponent<GhostBuilding>().m_prefab.cost;
            if (cost > m_res.funds)
                return;

            // Discard any previous ghost object.
            if (InputHandler.m_cursorBuilding != null)
            {
                m_res.funds += InputHandler.m_cursorBuilding.GetComponent<GhostBuilding>().m_prefab.cost;
                UnityEngine.Object.Destroy(InputHandler.m_cursorBuilding);
            }

            // Instantiate the ghost.
            m_res.funds -= cost;
            InputHandler.m_cursorMode = Cursor.BUILD;
            InputHandler.m_selectionType = Selection.NONE;
            InputHandler.m_cursorBuilding = new GameObject();
            GhostBuilding script = InputHandler.m_cursorBuilding.AddComponent<GhostBuilding>();
            script.Create(a_events.prefab);
        }