コード例 #1
0
    void PlacingResourcesToMotherBase()
    {
        //暫時
        if (antMiningActivity == AntMiningActivityState.returnToBase)
        {
            inAttackRange = gameModel.instance.Vector2IntEquality(motherBase.instance.InMapV3Pos, InMapV3Pos);
            if (inAttackRange)
            {
                if (inventory > 0)
                {
                    //礦未用完就跟motherBase新路徑內容
                    motherBase.instance.addNewMinePath(pathRecord);
                }
                gameModel.instance.resource += inventory;
                inventory = 0;

                //清空記憶
                pathRecord = new WalkingPath();

                inAttackRange     = false;
                antMiningActivity = AntMiningActivityState.none;
                antActivity       = AntActivityState.WalkingAround;

                GetComponent <SpriteRenderer>().color = normalStateColor;
            }
        }
    }
コード例 #2
0
    void updateWorkJob()
    {
        if (antActivity == AntActivityState.ChasingEnemy || antMiningActivity == AntMiningActivityState.goingToMine || antMiningActivity == AntMiningActivityState.returnToBase || !isFriendly || inventory > 0)
        {
            return;
        }

        if (!targetMine)
        {
            targetMine = gameModel.instance.getSingleMineInRange(InMapV3Pos, 3);
        }


        if (targetMine)
        {
            if (antActivity == AntActivityState.WalkingAround)
            {
                //需要為目前地板留多一個足跡
                pathRecord.path.Add(InMapV3Pos);
            }
            antActivity       = AntActivityState.miningResource;
            antMiningActivity = AntMiningActivityState.goingToMine;
            setDestinationToMine();
        }


        else
        {
            //沒有礦物,又到達終點時
            if (pathCounter >= pathRecord.path.Count - 1)
            {
                targetMine        = null;
                antActivity       = AntActivityState.WalkingAround;
                antMiningActivity = AntMiningActivityState.none;
                GetComponent <SpriteRenderer>().color = normalStateColor;
            }
        }
    }
コード例 #3
0
    public void OnEndMining()
    {
        if (!this)
        {
            return;
        }

        //採集
        if (targetMine && inventory <= 0)
        {
            inventory += targetMine.OnBeMining(resourceCollectionAbility);

            //先設回記憶路徑最末端
            pathCounter             = pathRecord.path.Count - 1;
            pathRecord.serialNumber = targetMine.UID;
            returnBaseByRecordPath();


            antMiningActivity = AntMiningActivityState.returnToBase;
            inAttackRange     = false;
            targetMine        = null;

            //setDestinationToHeart();
            GetComponent <SpriteRenderer>().color = Color.green;
        }
        else
        {
            //根本沒有礦物
            inAttackRange     = false;
            targetMine        = null;
            antMiningActivity = AntMiningActivityState.returnToBase;
            GetComponent <SpriteRenderer>().color = Color.gray;
            pathCounter = pathRecord.path.Count - 1;
        }

        startLerpToDestination();
    }
コード例 #4
0
 void collectionResourceFromMine()
 {
     if (antMiningActivity == AntMiningActivityState.goingToMine)
     {
         inAttackRange = gameModel.instance.Vector2IntEquality(targetMine.InMapV3Pos, InMapV3Pos);
         if (inAttackRange)
         {
             //採集
             if (targetMine && inventory <= 0)
             {
                 OnStartMining();
             }
             else
             {
                 //根本沒有礦物
                 inAttackRange     = false;
                 targetMine        = null;
                 antMiningActivity = AntMiningActivityState.returnToBase;
                 GetComponent <SpriteRenderer>().color = Color.gray;
                 pathCounter = pathRecord.path.Count - 1;
             }
         }
     }
 }
コード例 #5
0
 public void OnStartMining()
 {
     antMiningActivity = AntMiningActivityState.mining;
     //globalUpdateManager.instance.registerUpdateDg(miningMethod);
     globalUpdateManager.instance.startGlobalTimer(miningNeedTime, OnEndMining);
 }