Esempio n. 1
0
 /// <summary>
 /// Initializes the laser.
 /// </summary>
 /// <param name="origin">Origin of the local position of the laser in world space</param>
 /// <param name="originCharacter">Character who fired the laser</param>
 /// <param name="followOriginCharacter">If true, changes the origin of the laser to origin character's position</param>
 /// <param name="timeScale">Time scale to use</param>
 /// <param name="headDuration">Duration of the head. After the duration, the laser no longer extends</param>
 /// <param name="pointDuration">Duration of each point. After the duration, the point is removed from the laser's positions</param>
 /// <param name="headFunction"><see cref="SansyHuman.UDE.Util.Math.UDEMath.PolarTimeFunction"/> that draws a curve.
 /// The coordinate of the curve should be the relative coordinate from the <paramref name="origin"/></param>
 public void Initialize(Vector2 origin,
                        UDEBaseCharacter originCharacter,
                        bool followOriginCharacter,
                        UDETime.TimeScale timeScale,
                        float headDuration,
                        float pointDuration,
                        UDEMath.PolarTimeFunction headFunction)
 {
     Initialize(origin, originCharacter, followOriginCharacter, (UDEMath.CartesianCoord)headFunction(0), timeScale);
     InitializeInternal(headDuration, pointDuration);
     polarHeadFunction = headFunction;
     mode = HeadMoveMode.POLAR_FUNCTION;
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes the laser.
        /// </summary>
        /// <param name="origin">Origin of the local position of the laser in world space</param>
        /// <param name="originCharacter">Character who fired the laser</param>
        /// <param name="followOriginCharacter">If true, changes the origin of the laser to origin character's position</param>
        /// <param name="timeScale">Time scale to use</param>
        /// <param name="headDuration">Duration of the head. After the duration, the laser no longer extends</param>
        /// <param name="pointDuration">Duration of each point. After the duration, the point is removed from the laser's positions</param>
        /// <param name="headFunction"><see cref="SansyHuman.UDE.Util.Math.UDEMath.CartesianTimeFunction"/> that draws a curve.
        /// The coordinate of the curve should be the relative coordinate from the <paramref name="origin"/></param>
        public void Initialize(Vector2 origin,
                               UDEBaseCharacter originCharacter,
                               bool followOriginCharacter,
                               UDETime.TimeScale timeScale,
                               float headDuration,
                               float pointDuration,
                               UDEMath.CartesianTimeFunction headFunction)
        {
            if (initialized)
            {
                Debug.LogWarning("You tried to initialize laser that already initialized. Initialization is ignored.");
                return;
            }

            Initialize(origin, originCharacter, followOriginCharacter, headFunction(0), timeScale);
            InitializeInternal(headDuration, pointDuration);
            cartesianHeadFunction = headFunction;
            mode = HeadMoveMode.CARTESIAN_FUNCTION;
        }
Esempio n. 3
0
        private Vector2 maxHeadLocation; // Maximum location of the head.

        /// <summary>
        /// Initializes the laser.
        /// </summary>
        /// <param name="origin">Origin of the local position of the laser in world space</param>
        /// <param name="originCharacter">Character who fired the laser</param>
        /// <param name="followOriginCharacter">If true, changes the origin of the laser to origin character's position</param>
        /// <param name="initialLocalHeadLocation">Start position of the laser in local space</param>
        /// <param name="timeScale">Time scale to use</param>
        /// <param name="headVelocity">Velocity of the head</param>
        /// <param name="maxLaserLength">Maximum length of the laser</param>
        public void Initialize(Vector2 origin,
                               UDEBaseCharacter originCharacter,
                               bool followOriginCharacter,
                               Vector2 initialLocalHeadLocation,
                               UDETime.TimeScale timeScale,
                               Vector2 headVelocity,
                               float maxLaserLength)
        {
            if (initialized)
            {
                Debug.LogWarning("You tried to initialize laser that already initialized. Initialization is ignored.");
                return;
            }

            Initialize(origin, originCharacter, followOriginCharacter, initialLocalHeadLocation, timeScale);
            points.Add(initialLocalHeadLocation);
            laser.positionCount = 2;
            laser.SetPosition(1, points[1]);
            laserCollider.points = points.ToArray();

            this.headVelocity   = headVelocity;
            this.maxLaserLength = maxLaserLength;
            maxHeadLocation     = initialLocalHeadLocation + headVelocity * maxLaserLength / headVelocity.magnitude;
        }