예제 #1
0
    public void resetVisitor()
    {
        lastPoint   = targetPoint;
        targetPoint = null;
        var point = getAttractivePoint();

        targetPoint = point;
        agent.SetDestination(point.transform.position);
        wanderingTime = Random.Range(0, 30);

        StartCoroutine(waitForWander());

        currentState = visitorState.wandering;
    }
예제 #2
0
    private void findAttraction()
    {
        var gmScript        = gameManager.GetComponent <gameManagerScript>();
        var openAttractions = gmScript.attractionBuildings;

        if (openAttractions.Count > 0)
        {
            GameObject attractionBuilding = null;

            int attractiveWeight = 0;

            for (int i = 0; i < openAttractions.Count; i++)
            {
                attractiveWeight += openAttractions[i].attract;
            }

            int roll = Random.Range(0, attractiveWeight);


            for (int j = 0; j < openAttractions.Count; j++)
            {
                if (roll <= openAttractions[j].attract)
                {
                    attractionBuilding = openAttractions[j].building;
                    break;
                }

                roll -= openAttractions[j].attract;
            }

            targetPoint = attractionBuilding.GetComponent <buildingManager>().entrancePoint;
            agent.SetDestination(targetPoint.transform.position);
            currentState = visitorState.walkingToAttraction;
        }
        else
        {
            currentState = visitorState.lookingForAttraction;
            resetVisitor();
        }
    }
예제 #3
0
 void Start()
 {
     gameManager  = GameObject.FindGameObjectWithTag("gameManager");
     currentState = visitorState.wandering;
     resetVisitor();
 }