Beispiel #1
0
            public override void Works(ObjectCtrl unit)
            {
                UnitCtrl unitCtrl = unit as UnitCtrl;

                if (target != null)
                {
                    //Debug.Log(Vector2.Distance(unitCtrl.Pos, target.Pos)+"/"+ (unitCtrl.Stat("Radius") + target.Radius + 0.1f));
                    if (Vector2.Distance(unitCtrl.Pos, target.Pos) > unitCtrl.Stat("Radius") + target.Radius + 0.1f)
                    {
                        unitCtrl.MoveTarget(target);
                    }
                    else
                    {
                        Debug.Log("wow");
                        if (target.Type == eTargetType.Building && unitCtrl.Job == eUnitJob.Worker)
                        {
                            BuildingCtrl building = target.transform.GetComponent <BuildingCtrl>();
                            if (building.BuildingState == eBuildingState.Construction)
                            {
                                unitCtrl.receiptOrder(new Build(target));
                            }
                            else
                            {
                                building.EnterBuilding(unitCtrl);
                            }
                            target = null;
                        }
                        unitCtrl.Stop();
                    }
                }
            }
Beispiel #2
0
 public void GetWork(BuildingCtrl workplace)
 {
     if (WorkSpaceCtrl)
     {
         Fired();
     }
     WorkSpaceCtrl = workplace;
     Owner.UseResource("WorkPopulation", 1);
 }
Beispiel #3
0
    public BuildingCtrl CreateBuilding(PlayerCtrl Owner, UnitCtrl Worker, BuildingInfo buildingInfo, Vector3 buildingPos)
    {
        foreach (string Cost in buildingInfo.Cost.Keys)
        {
            if (Cost == "time")
            {
                continue;
            }
            if (Owner.CurResource(Cost) - buildingInfo.Cost[Cost] < 0)
            {
                gameMng.interfaceMng.AlertText(Cost + "가 부족합니다");
                return(null);
            }
        }
        foreach (string Cost in buildingInfo.Cost.Keys)
        {
            if (Cost == "time")
            {
                continue;
            }
            Owner.UseResource(Cost, buildingInfo.Cost[Cost]);
        }
        GameObject   pre  = Resources.Load("Prefab/" + buildingInfo.Component) as GameObject;
        BuildingCtrl temp = Instantiate(pre, this.transform).GetComponent <BuildingCtrl>();

        temp.SetBuilding(this, buildingInfo, Owner, buildingPos);
        buildingList.Add(temp);

        foreach (MeshRenderer mesh in temp.transform.GetComponentsInChildren <MeshRenderer>())
        {
            if (mesh.transform.tag == "Unit")
            {
                mesh.material = Owner.playerMater;
            }
            if (mesh.transform.tag == "Interface")
            {
                if (Owner == gameMng.playerMng.CtrlPlayer)
                {
                    mesh.material = RangeMater[0];
                }
                if (Owner != gameMng.playerMng.CtrlPlayer)
                {
                    mesh.material = RangeMater[1];
                }
            }
        }
        Worker.receiptOrder(new GameSys.Order.Build(temp.Target));
        return(temp);
    }
Beispiel #4
0
 public void RemoveBuilding(BuildingCtrl building)
 {
     buildingList.Remove(building);
     building.StopAllCoroutines();
     Destroy(building.gameObject);
 }
Beispiel #5
0
 public void Fired()
 {
     WorkSpaceCtrl = null;
     Owner.GetResource("WorkPopulation", 1);
 }
Beispiel #6
0
 public void GetHome(BuildingCtrl home)
 {
     HomeCtrl = home;
 }
Beispiel #7
0
 /// <summary>
 /// 플레이어 유닛 해지 메서드
 /// </summary>
 /// <param name="unit"></param>
 public void UnregisterPlayerBuilding(BuildingCtrl building)
 {
     BuildingList.Remove(building);
     selectableObject.Remove(building);
 }
Beispiel #8
0
 /// <summary>
 /// 플레이어 유닛 등록 메서드
 /// </summary>
 /// <param name="unit"></param>
 public void RegisterPlayerBuilding(BuildingCtrl building)
 {
     BuildingList.Add(building);
 }
    public void GetObjectList(List <ObjectCtrl> objList)
    {
        string sName  = "";
        string sLeft  = "";
        string sRight = "";

        foreach (UnitBtn btn in unitBtnList)
        {
            btn.SetBtn(null);
        }
        foreach (UnitBtn btn in unitSmallBtnList)
        {
            btn.SetBtn(null);
        }
        if (objList.Count == 0)
        {
            GetInfo(sName, sLeft, sRight);
        }
        else if (objList.Count == 1)
        {
            sName = objList[0].Name;
            sLeft = "체력 : " + objList[0].curHealth + "/" + objList[0].Stat("Health") + "\n";

            GetInfo(sName, sLeft, sRight);

            if (objList[0] is UnitCtrl)
            {
            }
            else
            {
                BuildingCtrl building = objList[0] as BuildingCtrl;
                for (int i = 0; i < building.RegUnits.Count; i++)
                {
                    if (i >= 8)
                    {
                        break;
                    }
                    unitSmallBtnList[i].SetBtn(building.RegUnits[i]);
                }
            }
        }
        else
        {
            GetInfo(sName, sLeft, sRight);
            int nRow = 1;
            int nCol = 2;
            for (nRow = 1; objList.Count / nRow < nRow * 2; nRow++)
            {
            }
            nCol = nRow * 2;

            for (int i = 0; i < objList.Count; i++)
            {
                if (i >= 8)
                {
                    break;
                }
                unitBtnList[i].SetBtn(objList[i] as UnitCtrl);
            }
        }
    }