Пример #1
0
        private async Task TranslateToTargetAsync(Vector3 target)
        {
            var start          = m_creatureTransform.position;
            var vectorToTarget = (target - m_creatureTransform.position);
            var maxMagnitude   = vectorToTarget.magnitude;
            var segments       = Mathf.FloorToInt(maxMagnitude / m_creature.Stats.MovementSpeed);

            for (int i = 0; i < segments; i++)
            {
                if (ShouldBreakMovement())
                {
                    break;
                }

                var atStart = m_creatureTransform.position;
                var atEnd   = atStart + (vectorToTarget.normalized * m_creature.Stats.MovementSpeed);
                m_environmentController.RevealPath(atStart, atEnd);
                await AnimationUtility.AnimateOverTime(
                    1000,
                    x =>
                {
                    var t = -(4f * Mathf.Pow(x - .5f, 2)) + 1;

                    var poss = Vector3.Lerp(atStart, atEnd, x);
                    poss.y  += t;

                    m_creatureTransform.position = poss;
                }
                    );

                m_creatureTransform.position = atEnd;

                await Task.Yield();
            }

            if (!ShouldBreakMovement())
            {
                var atStart2 = m_creatureTransform.position;
                var atEnd2   = target;
                await AnimationUtility.AnimateOverTime(
                    1000,
                    x =>
                {
                    var t = -(4f * Mathf.Pow(x - .5f, 2)) + 1;

                    var poss = Vector3.Lerp(atStart2, atEnd2, x);
                    poss.y  += t;

                    m_creatureTransform.position = poss;
                    m_environmentController.RevealPoint(poss);
                }
                    );

                m_creatureTransform.position = atEnd2;
            }
        }
Пример #2
0
    private async Task AnimateUpAsync(Transform trans)
    {
        m_animatingList.Add(trans);

        var tiles = trans.GetComponentsInChildren <Tile>(includeInactive: true);

        if (tiles != null)
        {
            for (int i = 0; i < tiles.Length; i++)
            {
                tiles[i].Show();
            }
        }

        var startPos = trans.position;
        var endPos   = startPos + (Vector3.up * NEGATIVE_DISTANCE);
        await AnimationUtility.AnimateOverTime(500, p => trans.position = Vector3.Lerp(startPos, endPos, m_curve.Evaluate(p)));

        m_animatingList.Remove(trans);
    }
Пример #3
0
 private async Task RotateToTargetAsync(Vector3 target)
 {
     var start = m_creatureTransform.rotation;
     var end   = Quaternion.LookRotation(target - m_creatureTransform.position, Vector3.up);
     await AnimationUtility.AnimateOverTime(200, p => m_creatureTransform.rotation = Quaternion.Slerp(start, end, p));
 }