Пример #1
0
 public void ClearLightningSprites()
 {
     while (LightningSpriteList.Count > 0)
     {
         SpriteManager.RemoveSprite(LightningSpriteList.Last());
     }
 }
Пример #2
0
        void DoLastLightingSpriteResizeActivity()
        {
            var thisVector2     = new Vector2(this.X, this.Y);
            var lengthPerSprite = Lightning_Stream_Anim[0].Texture.Width *
                                  (Lightning_Stream_Anim[0].RightCoordinate -
                                   Lightning_Stream_Anim[0].LeftCoordinate);
            var thisToTarget = (LightningWeaponManager.LineEndpoint - thisVector2);

            var spriteCountFloat = thisToTarget.Length() / lengthPerSprite;
            var leftover         = spriteCountFloat - (int)spriteCountFloat;

            if (leftover != 0)
            {
                var lastSprite = LightningSpriteList.Last();

                var animationFrameWidth = Lightning_Stream_Anim[0].RightCoordinate -
                                          Lightning_Stream_Anim[0].LeftCoordinate;

                lastSprite.RightTextureCoordinate = lastSprite.LeftTextureCoordinate +
                                                    animationFrameWidth * leftover;


                var widthPerSprite = Lightning_Stream_Anim[0].Texture.Width *
                                     (Lightning_Stream_Anim[0].RightCoordinate -
                                      Lightning_Stream_Anim[0].LeftCoordinate);

                var widthHalf = widthPerSprite / 2.0f;

                int index = LightningSpriteList.Count - 1;
                var leftOfPreviousSprite = widthPerSprite * index;
                lastSprite.RelativeX = leftOfPreviousSprite + widthPerSprite * leftover / 2.0f;
            }
        }
Пример #3
0
        public void UpdateLightningSprites()
        {
            Vector2 target         = LightningWeaponManager.LineEndpoint;
            var     widthPerSprite = Lightning_Stream_Anim[0].Texture.Width *
                                     (Lightning_Stream_Anim[0].RightCoordinate -
                                      Lightning_Stream_Anim[0].LeftCoordinate);

            var widthHalf = widthPerSprite / 2.0f;

            var thisVector2      = new Vector2(this.X, this.Y);
            var thisToTarget     = (target - thisVector2);
            var spriteCountFloat = thisToTarget.Length() / widthPerSprite;

            var spriteCount = 1 + (int)spriteCountFloat;


            while (LightningSpriteList.Count < spriteCount)
            {
                var sprite = SpriteManager.AddSprite(Lightning_Stream_Anim);
                // eventually attach to the rotation object.
                sprite.TextureScale = 1;
                sprite.AttachTo(lightningAttachment);
                if (LightningSpriteList.Count > 0)
                {
                    sprite.TimeIntoAnimation = LightningSpriteList[0].TimeIntoAnimation;
                }
                LightningSpriteList.Add(sprite);
            }

            while (LightningSpriteList.Count > spriteCount)
            {
                SpriteManager.RemoveSprite(LightningSpriteList.Last());
            }

            for (int i = 0; i < LightningSpriteList.Count; i++)
            {
                var sprite = LightningSpriteList[i];
                sprite.UpdateToCurrentAnimationFrame();
                sprite.RelativeX = widthHalf + widthPerSprite * i;
            }



            lightningAttachment.RelativeRotationZ =
                (float)Math.Atan2(thisToTarget.Y, thisToTarget.X);

            LightningEndpointSprite.RelativeX = target.X - X;
            LightningEndpointSprite.RelativeY = target.Y - Y;

            DoLastLightingSpriteResizeActivity();
        }