示例#1
0
    void Start()
    {
        movement         = Vector3.zero;
        manager          = GetComponent <PlayerManager> ();
        moveAmount       = manager.Graph.VertexDistance;
        nav              = GetComponent <UnityEngine.AI.NavMeshAgent> ();
        standSpeed       = nav.speed;
        audioSource      = GetComponent <AudioSource>();
        audioSource.loop = true;
        currVertexIndex  = manager.Graph.GetIndexFromPosition(transform.position);
        lastVertexIndex  = currVertexIndex;
        playerName       = gameObject.name;
        manager.Graph.vertices [currVertexIndex].occupiedBy = playerName;
        manager.Graph.vertices [currVertexIndex].occupied   = true;
        manager.Graph.vertices[currVertexIndex].NotifyParentOrChild();
        Vector3 forwardDir = transform.forward.normalized;

        if (forwardDir == Vector3.forward)
        {
            direction = Enums.directions.up;
        }
        else if (forwardDir == Vector3.back)
        {
            direction = Enums.directions.down;
        }
        else if (forwardDir == Vector3.left)
        {
            direction = Enums.directions.left;
        }
        else if (forwardDir == Vector3.right)
        {
            direction = Enums.directions.right;
        }
    }
示例#2
0
    void Start()
    {
        movement   = Vector3.zero;
        manager    = GetComponent <PlayerManager> ();
        moveAmount = manager.Graph.VertexDistance;
        nav        = GetComponent <UnityEngine.AI.NavMeshAgent> ();
        //transform.position = new Vector3(transform.position.x, 1.0f, transform.position.z);
        currVertexIndex = manager.Graph.GetIndexFromPosition(transform.position);
        lastVertexIndex = currVertexIndex;
        playerName      = gameObject.name;
        manager.Graph.vertices [currVertexIndex].occupiedBy = playerName;
        manager.Graph.vertices [currVertexIndex].occupied   = true;
        Vector3 forwardDir = transform.forward.normalized;

        if (forwardDir == Vector3.forward)
        {
            direction = Enums.directions.up;
        }
        else if (forwardDir == Vector3.back)
        {
            direction = Enums.directions.down;
        }
        else if (forwardDir == Vector3.left)
        {
            direction = Enums.directions.left;
        }
        else if (forwardDir == Vector3.right)
        {
            direction = Enums.directions.right;
        }
    }
示例#3
0
    /*
     *      Sets direction to move in
     *      @param dir - direction to move in
     */
    public void MoveUntilStop(Enums.directions dir)
    {
        direction = dir;
        switch (dir)
        {
        case Enums.directions.left:
            movement.Set(-moveAmount, 0.0f, 0.0f);
            break;

        case Enums.directions.right:
            movement.Set(moveAmount, 0.0f, 0.0f);
            break;

        case Enums.directions.up:
            movement.Set(0.0f, 0.0f, moveAmount);
            break;

        case Enums.directions.down:
            movement.Set(0.0f, 0.0f, -moveAmount);
            break;
        }
    }