コード例 #1
0
ファイル: TaskLauncher.cs プロジェクト: RTS-Game/RTS
        public int TabID;     //Current tab that the user is viewing

        void Start()
        {
            //get the building/unit components
            RefUnit     = gameObject.GetComponent <Unit>();
            RefBuilding = gameObject.GetComponent <Building>();

            //we expect the Task Launcher to be attached to either a building or a unit
            Assert.IsTrue(RefUnit != null || RefBuilding != null);

            TaskHolder = (RefUnit != null) ? TaskHolders.Unit : TaskHolders.Building; //set the task holder.

            //Get the other components:
            GameMgr      = GameManager.Instance;
            UIMgr        = GameMgr.UIMgr;
            TerrainMgr   = TerrainManager.Instance;
            SelectionMgr = GameMgr.SelectionMgr;
            ResourceMgr  = GameMgr.ResourceMgr;
        }
コード例 #2
0
        public int TabID;     //Current tab that the user is viewing

        //Called when the building/unit is ready to initialize the tasks
        public void OnTasksInit()
        {
            //get the building/unit components
            RefUnit     = gameObject.GetComponent <Unit>();
            RefBuilding = gameObject.GetComponent <Building>();

            //we expect the Task Launcher to be attached to either a building or a unit
            Assert.IsTrue(RefUnit != null || RefBuilding != null);

            TaskHolder = (RefUnit != null) ? TaskHolders.Unit : TaskHolders.Building; //set the task holder.

            //Get the other components:
            GameMgr      = GameManager.Instance;
            UIMgr        = GameMgr.UIMgr;
            TerrainMgr   = TerrainManager.Instance;
            SelectionMgr = GameMgr.SelectionMgr;
            ResourceMgr  = GameMgr.ResourceMgr;

            if (TasksList.Count > 0) //loop through all tasks
            {
                for (int i = 0; i < TasksList.Count; i++)
                {
                    TotalTasksAmount++;                                       //sum of the tasks
                    if (TasksList[i].UnitCreationSettings.Upgrades.Count > 0) //if a task has an upgrade
                    {
                        TotalTasksAmount++;                                   //add it to the total amount
                    }
                }
            }

            SetFactionInfo();

            FactionMgr.TaskLaunchers.Add(this); //add the task launcher here.

            SetTaskTypes();

            isActive = true;

            //Launch the delegate event:
            if (GameMgr.Events)
            {
                GameMgr.Events.OnTaskLauncherAdded(this);
            }
        }