Esempio n. 1
0
 public override void EndWork(WorkerUnit unit)
 {
     if (currentUnit == unit)
     {
         currentUnit = null;
     }
 }
Esempio n. 2
0
 void UnselectWorker()
 {
     if (selectedWorker != null)
     {
         selectedWorker.SetSelect(false);
     }
     selectedWorker = null;
 }
Esempio n. 3
0
    public static IUnitTask Create(WorkerUnit unit, Vector2 targetPoint)
    {
        MoveUnitTask unitTask = Create <MoveUnitTask>(unit);

        unitTask.targetPoint = targetPoint;

        return(unitTask);
    }
Esempio n. 4
0
    public static T Create <T>(WorkerUnit unit) where T : IUnitTask, new()
    {
        T task = new T();

        task.unit = unit;

        return(task);
    }
Esempio n. 5
0
 void TrainingUnit()
 {
     if (isTraining)
     {
         cancelUI.gameObject.SetActive(true);
         barUI.gameObject.SetActive(true);
         if (cancelUI.CheckClick())
         {
             cancelUI.SetClick(false);
             isTraining = false;
         }
         if (trainTimeNow >= trainTimeMax)
         {
             isTraining = false;
             GameObject      unit  = Instantiate(unitTrainNow, spawnPoint.transform.position, spawnPoint.transform.rotation) as GameObject;
             UnitGroupSystem group = unit.GetComponent <UnitGroupSystem>();
             if (group != null)
             {
                 group.SetOwner(build.GetOwner());
             }
             WorkerUnit worker = unit.GetComponent <WorkerUnit>();
             if (worker != null)
             {
                 worker.SetOwner(this.build.GetOwner());
             }
         }
         trainTimeNow += Time.deltaTime;
         barUI.SetProgress(trainTimeNow / trainTimeMax);
     }
     else
     {
         cancelUI.gameObject.SetActive(false);
         barUI.gameObject.SetActive(false);
         VRPlayerIndicator player = null;
         foreach (GameObject plays in GameObject.FindGameObjectsWithTag("Player"))
         {
             VRPlayerIndicator ind = plays.GetComponent <VRPlayerIndicator>();
             if (ind.GetPlayerNumber() == stat.GetOwner())
             {
                 player = ind;
             }
         }
         for (int i = 0; i < trainUI.Length; i++)
         {
             if (trainUI[i].CheckClick() && player.GetEther() >= trainCost[i])
             {
                 isTraining   = true;
                 unitTrainNow = trainUnit[i];
                 trainTimeMax = trainTime[i];
                 trainTimeNow = 0;
                 player.ChangeEther(-trainCost[i]);
                 barUI.SetProgress(0);
                 trainUI[i].SetClick(false);
                 Debug.Log("Start Training!!!");
             }
         }
     }
 }
Esempio n. 6
0
    public override bool TryBeginWork(WorkerUnit unit)
    {
        if (currentUnit == null || TryChangeUnit(unit))
        {
            currentUnit = unit;

            return(true);
        }

        return(false);
    }
Esempio n. 7
0
    public static IUnitTask Create(WorkerUnit unit, InterractiveObject interractiveObject)
    {
        if (interractiveObject == null)
        {
            return(null);
        }

        InterractiveObjectUnitTask unitTask = Create <InterractiveObjectUnitTask>(unit);

        unitTask.currentObject = interractiveObject;

        return(unitTask);
    }
Esempio n. 8
0
    public void Init(DishClientCore _core, bool _canControl)
    {
        core = _core;

        canControl = _canControl;

        trashContainer.Init(core);

        for (int i = 0; i < CookConst.RESULT_STATE.Length; i++)
        {
            GameObject go = GameObjectFactory.Instance.GetGameObject("Assets/Resource/prefab/resultContainer.prefab", null);

            go.transform.SetParent(dishResultContainer, false);

            (go.transform as RectTransform).anchoredPosition = new Vector2(i * dishResultGap, 0);

            DishResultContainer drc = go.GetComponent <DishResultContainer>();

            drc.Init(core, i, canControl);

            dishResultContainerArr[i] = drc;
        }

        for (int i = 0; i < CookConst.WORKER_NUM; i++)
        {
            GameObject go = GameObjectFactory.Instance.GetGameObject("Assets/Resource/prefab/workerUnit.prefab", null);

            WorkerUnit workerUnit = go.GetComponent <WorkerUnit>();

            workerArr[i] = workerUnit;

            workerUnit.Init(core, i);

            go = GameObjectFactory.Instance.GetGameObject("Assets/Resource/prefab/seat.prefab", null);

            go.transform.SetParent(seatContainer, false);

            (go.transform as RectTransform).anchoredPosition = new Vector2(i * seatGap, 0);

            SeatUnit seatUnit = go.GetComponent <SeatUnit>();

            seatUnit.Init(core, -i - 1, canControl);

            seatArr[i] = seatUnit;

            seatUnit.SetWorker(workerArr[i]);
        }
    }
Esempio n. 9
0
    public override bool TryBeginWork(WorkerUnit unit)
    {
        if (InvolvedUnitCountIsValid(involvedUnits.Count))
        {
            if (!involvedUnits.Contains(unit))
            {
                involvedUnits.Add(unit);
            }

            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 10
0
    public void ChangeWorkerPos(CommandChangeWorkerPos _command)
    {
        WorkerUnit workerUnit = workerArr[_command.workerIndex];

        SeatUnit seatUnit;

        if (_command.targetPos < 0)
        {
            seatUnit = seatArr[-_command.targetPos - 1];
        }
        else
        {
            seatUnit = dishList[_command.targetPos].dishWorkerBt;
        }

        seatUnit.SetWorker(workerUnit);
    }
Esempio n. 11
0
    public void SetWorker(WorkerUnit _workerUnit)
    {
        if (workerUnit != _workerUnit)
        {
            workerUnit = _workerUnit;

            if (workerUnit != null)
            {
                workerUnit.transform.SetParent(transform, false);

                (workerUnit.transform as RectTransform).anchoredPosition = Vector2.zero;

                if (workerUnit.container != null)
                {
                    workerUnit.container.SetWorker(null);
                }

                workerUnit.container = this;
            }
        }
    }
Esempio n. 12
0
    private void StartDrag()
    {
        hasDragCheck = true;

        if (downUnit is SeatUnit)
        {
            WorkerUnit worker = (downUnit as SeatUnit).GetWorker();

            if (worker != null)
            {
                dragUnit = worker;
            }
        }
        else if (downUnit is DishResultContainer)
        {
            DishResultUnit unit = (downUnit as DishResultContainer).result;

            if (unit != null)
            {
                dragUnit = unit;
            }
        }
        else if (downUnit is DishResultBt)
        {
            DishResultUnit unit = (downUnit as DishResultBt).dish.resultUnit;

            if (unit != null)
            {
                dragUnit = unit;
            }
        }

        if (dragUnit != null)
        {
            dragUnit.StartDrag();

            ClearSelectedUnitList();
        }
    }
Esempio n. 13
0
    void CheckUnitOBJ(GameObject hitObject)
    {
        UnitStatSystem unit = hitObject.GetComponent <UnitStatSystem>();

        if (unit != null)
        {
            Debug.Log("SELECT UNIT");
            if (unit.GetUnitType() == UnitStatSystem.UnitObjectType.Building)
            {
                Debug.Log("SELECT Building");
                BuildingSystem buil = hitObject.GetComponent <BuildingSystem>();
                if (player.GetPlayerNumber() == buil.GetOwner())
                {
                    Debug.Log("Select Own Building");
                    UnselectUnit();
                    UnselectWorker();
                    if (buil != selectedBuilding)
                    {
                        UnselectBuilding();
                        SelectBuilding(buil);
                    }
                }
            }
            if (unit.GetUnitType() == UnitStatSystem.UnitObjectType.Units)
            {
                WorkerUnit wor = unit.GetComponent <WorkerUnit>();
                if (wor != null)
                {
                    if (player.GetPlayerNumber() == wor.GetOwner())
                    {
                        UnselectUnit();
                        UnselectBuilding();
                        if (wor != selectedWorker)
                        {
                            UnselectWorker();
                            SelectWorker(wor);
                        }
                    }
                }
            }
            if (unit.GetOwner() != player.GetPlayerNumber() && selectedUnit != null)
            {
                if (!AllianceSystem.CheckAlly(player.GetPlayerNumber(), unit.GetOwner()))
                {
                    Debug.Log("ATTACK");
                    selectedUnit.SetAutoAttaack(true);
                    selectedUnit.SetTarget(unit.gameObject);
                }
            }
        }
        if (hitObject.tag == "Soldier Group")
        {
            Debug.Log("SELECT SOLDIER");
            UnitGroupSystem unitGro = hitObject.GetComponent <UnitGroupSystem>();
            if (player.GetPlayerNumber() == unitGro.GetOwner())
            {
                Debug.Log("Select own Soldier");
                UnselectBuilding();
                UnselectWorker();
                if (unitGro != selectedUnit)
                {
                    UnselectUnit();
                    SelectUnit(unitGro);
                }
            }
            if (unitGro.GetOwner() != player.GetPlayerNumber() && selectedUnit != null)
            {
                if (!AllianceSystem.CheckAlly(player.GetPlayerNumber(), unitGro.GetOwner()))
                {
                    Debug.Log("ATTACK");
                    selectedUnit.SetAutoAttaack(true);
                    selectedUnit.SetTarget(unitGro.gameObject);
                }
            }
        }
    }
Esempio n. 14
0
 public abstract void EndWork(WorkerUnit unit);
Esempio n. 15
0
 public abstract bool TryBeginWork(WorkerUnit unit);
Esempio n. 16
0
    public override void draw(SpriteBatch s)
    {
        base.draw(s);


        for (int i = 0; i < _playingButtons.Count - 1; i++)
        {
            if (_playingButtons[i]._drawTooltip == true)
            {
                switch (i)
                {
                default:
                    break;

                case 0:
                    s.DrawString(font, "Move units", ToolTipPos, Color.DarkOrange);
                    break;

                case 1:
                    Farm e = new Farm(null, new Vector2(0, 0), BuildingAndUnit.faction.Human);
                    { s.DrawString(font, "Produce Farm, Gold:" + e.GoldCost + "+ Lumber:" + e.LumberCost, ToolTipPos, Color.DarkOrange); }
                    break;

                case 2:
                    WorkerUnit w = new WorkerUnit(null);
                    { s.DrawString(font, "Produce Worker, Gold:" + w.GoldCost + "+ Food:" + w._foodCost, ToolTipPos, Color.DarkOrange); }
                    break;

                case 3:
                    s.DrawString(font, "Stop selected units", ToolTipPos, Color.DarkOrange);
                    break;

                case 4:
                    Barracks B = new Barracks(null, new Vector2(0, 0), BuildingAndUnit.faction.Human);
                    s.DrawString(font, "Barracks, Gold:" + B.GoldCost + "Lumber:" + B.LumberCost, ToolTipPos, Color.DarkOrange);
                    break;

                case 5:
                    BasicMeleeUnit b = new Footman(null, new Vector2(0, 0));
                    s.DrawString(font, "Footman, Gold:" + b.GoldCost + "Lumber:" + b.LumberCost + "Food:" + b.FoodCost, ToolTipPos, Color.DarkOrange);
                    break;

                case 6:
                    s.DrawString(font, "Attack", ToolTipPos, Color.DarkOrange);
                    break;

                case 7:
                    s.DrawString(font, "Chop trees", ToolTipPos, Color.DarkOrange);
                    break;

                case 8:
                    Archer a = new Archer(null, new Vector2(0, 0));
                    s.DrawString(font, "Archer, Gold:" + a.GoldCost + "Lumber:" + a.LumberCost + "Food:" + a.FoodCost, ToolTipPos, Color.DarkOrange);
                    break;

                case 9:
                    s.DrawString(font, " - ", ToolTipPos, Color.Black);
                    break;

                case 10:
                    //Barracks B = new Barracks(null, new Vector2(0, 0), BuildingAndUnit.faction.Human);
                    //s.DrawString(font, "Barracks, Gold:"+ B.GoldCost + "Lumber:" + B.LumberCost , ToolTipPos, Color.DarkOrange);
                    break;

                case 11:
                    s.DrawString(font, "- ", ToolTipPos, Color.Black);
                    break;

                case 12:
                    s.DrawString(font, " - ", ToolTipPos, Color.Black);
                    break;
                }
            }
        }

        _minimap.draw(s);
        s.Draw(_minimapBorder, new Vector2(0, GameEnvironment.getCamera().getScreenSize().Y - 300), Color.White);
        //foreach (BasicMeleeUnit q in hudUnits.OfType<BasicMeleeUnit>())

        if (hudUnits != null)
        {
            int i = 0;
            foreach (BuildingAndUnit e in hudUnits.OfType <BuildingAndUnit>())
            {
                if (e is ProductionBuilding)
                {
                    if ((e as ProductionBuilding)._producingUnit)
                    {
                        DrawingHelper.DrawRectangle(new Rectangle((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 60, 400, 20), s, Color.SaddleBrown, 2);
                        s.Draw(GameEnvironment.getAssetManager().GetSprite("Sprites/HUD/Healthbar"), new Rectangle((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 60, (int)(400 * (float)((float)(e as ProductionBuilding)._unitProductionTimer / (float)(e as ProductionBuilding)._unitProductionTime)), 20), Color.White);
                        //DrawingHelper.DrawRectangle(new Rectangle((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 60, (int)(400*(float)((float)(e as ProductionBuilding)._unitProductionTimer / (float)(e as ProductionBuilding)._unitProductionTime)), 20), s, Color.Green, 2);
                    }
                }

                e.Healthbar(s, new Vector2((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 120), 1);
                s.Draw(e.Sprite, new Rectangle((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 120, 64, 64), Color.White);
                i++;
                if (i > 9)
                {
                    break;
                }
            }
        }
    }
Esempio n. 17
0
    public void RefreshData(PlayerData _playerData)
    {
        Clear();

        playerData = _playerData;

        money.text = playerData.money.ToString();

        List <DishData> dishDataList = playerData.dish;

        for (int i = 0; i < dishDataList.Count; i++)
        {
            DishData dishData = dishDataList[i];

            GameObject go = GameObjectFactory.Instance.GetGameObject("Assets/Resource/prefab/dish.prefab", null);

            go.transform.SetParent(dishContainer, false);

            (go.transform as RectTransform).anchoredPosition = new Vector2(0, -i * dishGap);

            Dish dish = go.GetComponent <Dish>();

            dish.Init(core, dishData, i, canControl);

            dishList.Add(dish);
        }

        DishResult[] dishResultArr = playerData.result;

        for (int i = 0; i < CookConst.RESULT_STATE.Length; i++)
        {
            DishResultContainer dishResultContainer = dishResultContainerArr[i];

            dishResultContainer.SetData(dishResultArr);

            DishResult dishResult = dishResultArr[i];

            if (dishResult != null)
            {
                GameObject go = GameObjectFactory.Instance.GetGameObject("Assets/Resource/prefab/dishResult.prefab", null);

                DishResultUnit dishResultUnit = go.GetComponent <DishResultUnit>();

                dishResultUnit.Init(core, dishResult);

                dishResultContainer.SetResult(dishResultUnit);
            }
        }

        for (int i = 0; i < CookConst.WORKER_NUM; i++)
        {
            Worker worker = playerData.workers[i];

            WorkerUnit workerUnit = workerArr[i];

            if (worker.pos < 0)
            {
                SeatUnit seat = seatArr[-worker.pos - 1];

                seat.SetWorker(workerUnit);
            }
            else
            {
                dishList[worker.pos].SetWorker(workerUnit);
            }
        }
    }
Esempio n. 18
0
 public override void EndWork(WorkerUnit unit)
 {
     involvedUnits.Remove(unit);
 }
Esempio n. 19
0
 public virtual bool TryChangeUnit(WorkerUnit unit)
 {
     return(false);
 }
Esempio n. 20
0
 void SelectWorker(WorkerUnit wor)
 {
     selectedWorker = wor;
     selectedWorker.SetSelect(true);
 }
Esempio n. 21
0
 public UnitTaskManager(WorkerUnit unit)
 {
     this.unit = unit;
     this.unit.StartCoroutine(CoreThread());
 }
Esempio n. 22
0
 public void SetWorker(WorkerUnit _workerUnit)
 {
     dishWorkerBt.SetWorker(_workerUnit);
 }