Beispiel #1
0
    private void GetWaypointsForCurrentRack()
    {
        List <Vector3> best = new List <Vector3>();

        for (int i = 0; i < nStepsInWPPlanning; i++)
        {
            List <BoxCollider> boxes   = spawnBoxes[currentRack].ToList();
            List <Vector3>     current = new List <Vector3> (boxes.Count / 4);
            while (boxes.Count > 0)
            {
                int     rnd   = Random.Range(0, boxes.Count);
                Vector3 point = WeaponRack.GetRandomPointInBox(boxes[rnd]);
                current.Add(point);
                boxes.RemoveAt(rnd);

                int k = 0;
                while (k < boxes.Count)
                {
                    if (FullyVisible(boxes[k], point))
                    {
                        boxes.RemoveAt(k);
                    }
                    else
                    {
                        k++;
                    }
                }
            }
            if (best.Count == 0 || current.Count < best.Count)
            {
                best = current;
            }
        }
        best.Insert(0, transform.position);
        waypoints = SolveTSP(best);
        waypoints.RemoveAt(0);
    }
Beispiel #2
0
    private void ChangeState(int newState)
    {
        // Things to always do when exiting a state
        switch (state)
        {
        case APPROACHING_RACK:
            currentBox = 0;
            break;
        }

        // Things to always do when entering a state
        switch (newState)
        {
        case EXPLORING:
            exploreWP = WeaponRack.GetRandomPointInBox(spawnBoxes[currentRack][currentBox]);
            break;

        case ROTATING:
            timeOfRotateStart = Time.time;
            break;
        }

        state = newState;
    }
Beispiel #3
0
 private void Start()
 {
     wr = this.GetComponent <WeaponRack>();
 }