Example #1
0
    //sets destination to nearest village
    //when destination is reached gather resources

    private void Gathering(StateController controller)
    {
        //Debug.Log("GatherAction ?? " + destinationSet + "helo");
        //if(!destinationSet)
        SetVillageDestination(controller);
        // checking if navmesh agent is at destination
        if (ArrivedAtLocation(controller))
        {
            if (controller.targetLocation != null)
            {
                destinationSet = false;
                Village v = (Village)controller.targetLocation;
                v.AIGather(controller.self);
                // Debug.Log("enemy at targte destination of : " + controller.targetLocation.ToString());
                //clearing village CDlist if exceeds a random amount
                int rand = UnityEngine.Random.Range(1, controller.villageList.Count);
                if (controller.villageCDlist.Count > rand)
                {
                    controller.villageCDlist.Clear();
                }
                controller.villageCDlist.Add(v);
            }
        }
    }