示例#1
0
        public static IEnumerator AnimateLinearMove(
            this MapUnit unit,
            HexCoords oldLoc,
            HexCoords newLoc,
            float moveTime)
        {
            unit.facing = oldLoc.FacingTo(newLoc);

            for (float timePassed = 0.0f;
                 timePassed < moveTime;
                 timePassed += Time.deltaTime)
            {
                unit.transform.position = Vector3.Lerp(
                    map[oldLoc].transform.position,
                    map[newLoc].transform.position,
                    timePassed / moveTime);

                yield return(null);
            }
        }
示例#2
0
        public static IEnumerator AnimateParabolicMove(
            this MapUnit unit,
            HexCoords oldLoc,
            HexCoords newLoc,
            float airTime,
            float peakHeight)
        {
            unit.facing = oldLoc.FacingTo(newLoc);

            for (float timePassed = 0.0f; timePassed < airTime; timePassed += Time.deltaTime)
            {
                Vector3 airPos = Vector3.Lerp(
                    map[oldLoc].transform.position,
                    map[newLoc].transform.position,
                    timePassed / airTime);

                airPos.y += ParabolicHeight(timePassed / airTime) * peakHeight;

                unit.transform.position = airPos;

                yield return(null);
            }
        }