Пример #1
0
    public virtual void EndTurn()
    {
        TGMap tempMap = (TGMap)FindObjectOfType(typeof(TGMap));

        tempMap.tileDataMap.GetTile(currentTileIndex).IsTraversable = false;

        PathManager tempPathManager = (PathManager)FindObjectOfType(typeof(PathManager));

        tempPathManager.ClearPath();

        moveCharacter   = false;
        isCharacterTurn = false;
    }
Пример #2
0
    // Update is called once per frame
    protected virtual void Update()
    {
        float step = rotSpeed * Time.deltaTime;

        Vector3 targetDirection = new Vector3(pathList[pathIndex].Pos.x, transform.position.y, pathList[pathIndex].Pos.z) - transform.position; // This was setup with a characterPos variable. Let's see if this actually work for multiple characters
        Vector3 newDirection    = Vector3.RotateTowards(transform.forward, targetDirection, step, 0.0f);

        transform.rotation = Quaternion.LookRotation(newDirection);

        step = moveSpeed * Time.deltaTime;

        if (transform.position.y != pathList[pathIndex].Pos.y)
        {
            // This works for going up the object but not down. For now, we're going to not worry about his until we have an animation
            //transform.position = Vector3.MoveTowards(transform.position, new Vector3(transform.position.x, pathList[pathIndex].Pos.y, transform.position.z), step);
            transform.position = Vector3.MoveTowards(transform.position, pathList[pathIndex].Pos, step);
        }
        else
        {
            transform.position = Vector3.MoveTowards(transform.position, pathList[pathIndex].Pos, step);
        }

        if (transform.position == pathList[pathIndex].Pos && !isInMenu)
        {
            //TGMap tempMap = (TGMap)FindObjectOfType(typeof(TGMap));
            //tempMap.tileDataMap.GetTile(currentTileIndex).IsTraversable = true;

            pathIndex++;
            if (pathIndex != pathList.Count && isCharacterTurn)
            {
                currentTileIndex = pathList[pathIndex].Index;
            }
            else
            {
                PathManager tempPathManager = (PathManager)FindObjectOfType(typeof(PathManager));
                tempPathManager.ClearPath();
                moveCharacter = false;
            }

            //tempMap.tileDataMap.GetTile(currentTileIndex).IsTraversable = false;


            //_currentMovement++;

            //if (_pathIndex == _pathList.Count || _currentMovement == _maxMovement)
            //{
            //    _characterTile.IsTraversable = true;

            //    if (_pathIndex == _pathList.Count)
            //        _characterTile = _pathList[_pathIndex - 1];
            //    else
            //        _characterTile = _pathList[_pathIndex - 1];

            //    _characterTile.IsTraversable = false;

            //    GetComponent<Animation>().CrossFade("idle");
            //    Move = false;
            //    _characterState = STATE.IDLE;
            //    return;
            //}
        }
    }