Esempio n. 1
0
        public void Update(float delta)
        {
            if (!alive)
            {
                return;
            }

            position += velocity * delta;
            velocity  = ExtensionMethods.MoveTowards(velocity, Vector2.Zero, damping * delta);

            if (Time.time > killTime)
            {
                alive = false;
            }
        }
Esempio n. 2
0
        public override void Update()
        {
            lifeTime -= Time.deltatime;
            if (lifeTime <= 0)
            {
                Destroy();
            }
            position += moveDir;
            meshes[0].RotateVertices(spin, ExtensionMethods.GetPolyCenter(meshes[0].vertices));
            meshes[0].Scale(0.03f);
            //Move current color towards 0
            colorCurrent = ExtensionMethods.MoveTowards(colorCurrent, Vector3.Zero, Time.deltatime * (1f / lifeTime));

            //Convert vector3 back to color
            meshes[0].color = colorCurrent.ToColor();
        }
Esempio n. 3
0
        private void LocomotionUpdate(float delta)
        {
            lts_current = ExtensionMethods.MoveTowards(lts_current, lts_target, acceleration * delta);
            rts_current = ExtensionMethods.MoveTowards(rts_current, rts_target, acceleration * delta);
            as_current  = ExtensionMethods.MoveTowards(as_current, as_target, aimAcceleration * delta);

            //Rotate Tower
            meshes[2].Rotate(as_current * delta);
            meshes[3].Rotate(as_current * delta);

            //Rotate
            forward = forward.Rotate((lts_current - rts_current) * delta * turnFactor);

            //Move
            position += forward * (lts_current + rts_current) * delta;

            //Track marks
            currentGap += (position - prevPos).Length;

            if (currentGap >= trackGap)
            {
                if (Vector2.Dot(forward, position - prevPos) > 0)
                {
                    // forward
                    new TrackMarks(position - forward * 2f + right * 1f, -right, 0.8f, meshes[0].color, 5f);
                    new TrackMarks(position - forward * 2f + -right * 1f, right, 0.8f, meshes[0].color, 5f);
                }
                else
                {
                    // backward
                    new TrackMarks(position + forward * 2f + right * 1f, -right, 0.8f, meshes[0].color, 5f);
                    new TrackMarks(position + forward * 2f + -right * 1f, right, 0.8f, meshes[0].color, 5f);
                }

                currentGap = 0f;
            }

            prevPos = position;
        }