Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        tiles          = GameObject.Find("GameManager").GetComponent <GameManagerBase>().getTiles();
        pathFinder     = GameObject.Find("GameManager").GetComponent <PathFinder>();
        inputManager   = GameObject.Find("GameManager").GetComponent <InputManager>();
        unitController = GetComponent <UnitController>();

        findCurrentPosition();
        findCurrentTile();
        setUnitHeight();

        currentTile.setTileOccupied(true);
    }
Ejemplo n.º 2
0
    private IEnumerator moveToNextTile(TileSelect nextTile)
    {
        float timePassed = 0;

        Vector3 currentPos = currentTile.transform.position;

        currentPos.y = currentTile.getHeight();

        Vector3 nextPos = nextTile.transform.position;

        nextPos.y = currentTile.getHeight();

        Vector3 pathToNext = nextPos - currentPos;

        while (timePassed <= timeToMove)
        {
            Vector3 newPos = currentPos + pathToNext * (timePassed / timeToMove);

            if (timePassed >= timeToMove / 2)
            {
                newPos.y = nextTile.getHeight();
            }

            transform.position = newPos;

            yield return(null);

            timePassed += Time.deltaTime;
        }

        nextPos.y          = nextTile.getHeight();
        transform.position = nextPos;

        currentTile.setTileOccupied(false);
        nextTile.setTileOccupied(true);

        currentTile = nextTile;
    }