コード例 #1
0
ファイル: Player.cs プロジェクト: Fuzzinator/Fallout-Remaster
    protected override IEnumerator MoveCreature()
    {
        yield return(null);

        _hexMaker = HexMaker.Instance;

        var pathToTake = TargetPath.ToArray();

        TargetPath.Clear();

        var count = pathToTake.Length;

        for (var i = 0; i < count; i++)
        {
            var coord = pathToTake[i];
            if (coord.index == _currentLocation)
            {
                continue;
            }

            if (!coord.IsWalkable)
            {
                yield break;
            }

            if (CombatManager.Instance.CombatMode)
            {
                var willMove = TryDecrementAP(1, ActionType.Move);
                if (!willMove)
                {
                    break;
                }
            }

            var t = transform;

            var currentPos   = t.position;
            var currentCoord = _hexMaker.Coords[_currentLocation];

            var currentRot     = t.rotation;
            var targetRotation = GetTargetRotation(currentCoord, coord, out var targetDir);

            var rotLerp = 0f;
            for (var f = 0f; f < 1; f += MoveSpeed * Time.deltaTime)
            {
                if (rotLerp < 1)
                {
                    transform.rotation = Quaternion.Lerp(currentRot, targetRotation, rotLerp);
                    rotLerp           += _rotationSpeed * Time.deltaTime;
                }
                else
                {
                    transform.rotation = targetRotation;
                }

                transform.position = Vector3.Lerp(currentPos, coord.pos, f);
                _shaderUpdater.UpdateShaders();
                yield return(null);
            }

            LeaveCoordinate();

            transform.position = coord.pos;

            EnterCoordinate(coord);
            _facingDir = targetDir;
        }
    }