Exemplo n.º 1
0
    public void Scare()
    {
        state = PerState.Afraid;

        ExitPark();
        //set target to nearest exit node
    }
Exemplo n.º 2
0
    public void Attract(Vector2 attractPoint)
    {
        //if in afraid state, ignore attract
        if (state == PerState.Afraid)
        {
            return;
        }

        state         = PerState.Attracted;
        targetCurrent = attractPoint;

        //set target to attractPoint
    }
Exemplo n.º 3
0
    //go to nearest park node and start wandering
    public void EnterPark()
    {
        nearestParkNode = new Vector2(100, 100);
        for (int y = 0; y < 5; y++)
        {
            for (int x = 0; x < 5; x++)
            {
                if ((nodeMesh.ParkMesh[x, y] - (Vector2)transform.position).sqrMagnitude < (nearestParkNode - (Vector2)transform.position).sqrMagnitude)
                {
                    nearestParkNode = nodeMesh.ParkMesh[x, y];
                    xIndex          = x;
                    yIndex          = y;
                }
            }
        }

        state         = PerState.Default;
        targetCurrent = nearestParkNode;
    }
Exemplo n.º 4
0
    public void ExitPark()
    {
        //seek nearest exit node
        nearestExitNode = new Vector2(100, 100);
        for (int i = 0; i < 25; i++)
        {
            //find the nearest exit node among all the exit nodes
            if ((nodeMesh.ExitMesh[i] - (Vector2)transform.position).sqrMagnitude < (nearestExitNode - (Vector2)transform.position).sqrMagnitude)
            {
                nearestExitNode = nodeMesh.ExitMesh[i];
            }
        }

        if (state != PerState.Afraid) //if not Afraid, set state to Leaving
        {
            state = PerState.Leaving;
        }

        targetCurrent = nearestExitNode;
    }
Exemplo n.º 5
0
    //find next node to walk to
    public void WanderPark()
    {
        //make list of valid nodes to visit
        //randomly select a node to visit
        //if node selected is (2,2): alien spotted
        possibleNext = new List <Vector2>();

        bool validPick = false;

        do
        {
            int randomChoice = randy.Next(0, 4);

            switch (randomChoice)
            {
            case 0:
                //add north node if it exists
                if (nodeMesh.ParkMesh[xIndex, yIndex - 1] != null)
                {
                    targetCurrent = nodeMesh.ParkMesh[xIndex, yIndex - 1];
                    validPick     = true;
                    yIndex       -= 1;
                }
                break;

            case 1:
                //add east node if it exists
                if (nodeMesh.ParkMesh[xIndex + 1, yIndex] != null)
                {
                    targetCurrent = nodeMesh.ParkMesh[xIndex + 1, yIndex];
                    validPick     = true;
                    xIndex       += 1;
                }
                break;

            case 2:
                //add south node if it exists
                if (nodeMesh.ParkMesh[xIndex, yIndex + 1] != null)
                {
                    targetCurrent = nodeMesh.ParkMesh[xIndex, yIndex + 1];
                    validPick     = true;
                    yIndex       += 1;
                }
                break;

            case 3:
                //add west node if it exists
                if (nodeMesh.ParkMesh[xIndex - 1, yIndex] != null)
                {
                    targetCurrent = nodeMesh.ParkMesh[xIndex - 1, yIndex];
                    validPick     = true;
                    xIndex       -= 1;
                }
                break;
            }
        } while (validPick == false);


        if (xIndex == 2 && yIndex == 2)
        {
            state = PerState.Suspicious;
        }
    }