void Update()
        {
            int currentCapacity = foragerMemory.info.currentCapacity;

            if (currentCapacity != 30)
            {
                if (ForagerMemory.openlist.Count == 0)
                {
                    foragerExplore.Explore();
                }
                else
                {
                    FoodInfo info = foragerMemory.PickBestFood();
                    foragerMovement.GoTo(info.position);
                    foragerMemory.currentAction = "Go to food";
                }
            }
            else
            {
                foragerMovement.GoTo(foragerMemory.hivePos);
                foragerMemory.currentAction = "Go home";
            }
        }
Example #2
0
        public void Explore()
        {
            foragerMemory.currentAction = "Explore";
            int     x   = (int)gameObject.transform.position.x;
            int     y   = (int)gameObject.transform.position.z;
            Vector3 tmp = new Vector3(x, foragerMovement.transform.position.y, y);

            try{
                if (((foragerMovement.transform.position - tmp).magnitude) < delete_radius && wanderpoint[x + size, y + size] != 0)
                {
                    wanderpoint[x + size, y + size] = 0;
                }
            }catch {}
            //print("update3");

            if (foragerMovement.isArrive())
            {
                bool index0 = true;
                while (index0)
                {
                    //int index = Random.Range(0, 2500);
                    int index = wanderDest();
                    //print(index);
                    int index_x = index / ((size + 1) * 2);
                    int index_y = index % ((size + 1) * 2);
                    //print((index_x-24) + " " + (index_y-24));
                    if (wanderpoint[index_x, index_y] != 0)
                    {
                        Vector3 pos = new Vector3(index_x - size, 0, index_y - size);
                        //print (pos);
                        foragerMovement.GoTo(pos);
                        //print (pos);
                        wanderpoint[index_x, index_y] = 0;
                        index0 = false;
                    }
                }
            }
        }