コード例 #1
0
ファイル: BEGround.cs プロジェクト: Tracydrr/Tracydrr
        // when game started, set workers to working(upgrading)buildings
        public void SetWorkingBuildingWorker()
        {
            for (int i = 0; i < 10; ++i)
            {
                for (int j = 0; j < Buildings[i].Count; ++j)
                {
                    // exclude if building is not working
                    if (!Buildings[i][j].InUpgrading())
                    {
                        continue;
                    }

                    // get free worker
                    BEWorker Worker = BEWorkerManager.instance.GetAvailableWorker();
                    if (Worker != null)
                    {
                        AStarTile tile = GetBuidingAStarTile(Buildings[i][j]);
                        // set worker position to building
                        Worker.SetPosition(tile.x, tile.y);
                        // set worker state to work
                        Worker.SetWork(Buildings[i][j]);
                    }
                }
            }
        }
コード例 #2
0
 void Update()
 {
     // if path calc list has item
     // call worker's GetPath and remove from the list
     if (PathCalcList.Count != 0)
     {
         BEWorker worker = PathCalcList[0];
         worker.GetPath();
         PathCalcList.RemoveAt(0);
     }
 }
コード例 #3
0
        // add worker one by one
        public void AddWorker()
        {
            GameObject go = (GameObject)Instantiate(prefWorker, Vector3.zero, Quaternion.identity);

            go.transform.SetParent(trUnitRoot);
            go.transform.localScale = Vector3.one;
            int      tileX  = Random.Range(0, AStar.width);
            int      tileZ  = Random.Range(0, AStar.height);
            BEWorker script = go.GetComponent <BEWorker>();

            script.Init(this, tileX, tileZ);
            Workers.Add(script);
            //Debug.Log ("AddWorker "+go.transform.localPosition.ToString());
        }
コード例 #4
0
 // if worker need new destination
 // add worker to path calc list
 // to avoid call astar's path find function simultaneously
 public void RequestPath(BEWorker worker)
 {
     PathCalcList.Add(worker);
 }