Beispiel #1
0
        public SpriteObj DisplayEffect(Vector2 position, string spriteName)
        {
            var proj = m_resourcePool.CheckOut();

            proj.ChangeSprite(spriteName);
            proj.TextureColor = Color.White;
            proj.Visible      = true;
            proj.Position     = position;
            proj.PlayAnimation(false);
            return(proj);
        }
Beispiel #2
0
        public void AddIcon(ProjectileObj projectile)
        {
            var projectileIconObj = m_resourcePool.CheckOut();

            projectileIconObj.Visible            = true;
            projectileIconObj.ForceDraw          = true;
            projectileIconObj.AttachedProjectile = projectile;
            projectile.AttachedIcon = projectileIconObj;
        }
Beispiel #3
0
        public void FireProjectile(byte type)
        {
            var energonProjectileObj = m_projectilePool.CheckOut();

            energonProjectileObj.SetType(type);
            PhysicsMngr.AddObject(energonProjectileObj);
            energonProjectileObj.Target       = m_target;
            energonProjectileObj.Visible      = true;
            energonProjectileObj.Position     = Position;
            energonProjectileObj.CurrentSpeed = ProjectileSpeed;
            energonProjectileObj.Flip         = Flip;
            energonProjectileObj.Scale        = ProjectileScale;
            energonProjectileObj.Opacity      = 0.8f;
            energonProjectileObj.Damage       = Damage;
            energonProjectileObj.PlayAnimation();
        }
Beispiel #4
0
        public void DisplayNumberStringText(int amount, string text, Color color, Vector2 position)
        {
            var textObj = m_resourcePool.CheckOut();

            textObj.Font     = Game.JunicodeFont;
            textObj.FontSize = 14f;
            textObj.Text     = amount + " " + text;
            var width = textObj.Width;

            m_resourcePool.CheckIn(textObj);
            var textObj2 = m_resourcePool.CheckOut();

            textObj2.Font         = Game.HerzogFont;
            textObj2.Text         = amount.ToString();
            textObj2.Align        = Types.TextAlign.Left;
            textObj2.FontSize     = 18f;
            textObj2.TextureColor = color;
            textObj2.Position     = new Vector2(position.X - width / 2f, position.Y - textObj2.Height / 2f);
            textObj2.Visible      = true;
            var textObj3 = m_resourcePool.CheckOut();

            textObj3.Font         = Game.JunicodeFont;
            textObj3.Text         = " " + text;
            textObj3.FontSize     = 14f;
            textObj3.Align        = Types.TextAlign.Left;
            textObj3.TextureColor = color;
            textObj3.Position     = textObj2.Position;
            textObj3.X           += textObj2.Width;
            textObj3.Y           -= 5f;
            textObj3.Visible      = true;
            Tween.By(textObj2, 0.3f, Quad.EaseOut, "Y", "-60");
            Tween.To(textObj2, 0.2f, Linear.EaseNone, "delay", "0.5", "Opacity", "0");
            Tween.AddEndHandlerToLastTween(this, "DestroyText", textObj2);
            Tween.By(textObj3, 0.3f, Quad.EaseOut, "Y", "-60");
            Tween.To(textObj3, 0.2f, Linear.EaseNone, "delay", "0.5", "Opacity", "0");
            Tween.AddEndHandlerToLastTween(this, "DestroyText", textObj3);
        }
Beispiel #5
0
        public ProjectileObj FireProjectile(ProjectileData data)
        {
            if (data.Source == null)
            {
                throw new Exception("Cannot have a projectile with no source");
            }
            var projectileObj = m_projectilePool.CheckOut();

            projectileObj.Reset();
            projectileObj.LifeSpan = data.Lifespan;
            var source = data.Source;

            projectileObj.ChaseTarget = data.ChaseTarget;
            projectileObj.Source      = source;
            projectileObj.Target      = data.Target;
            projectileObj.UpdateHeading();
            projectileObj.TurnSpeed               = data.TurnSpeed;
            projectileObj.CollidesWithTerrain     = data.CollidesWithTerrain;
            projectileObj.DestroysWithTerrain     = data.DestroysWithTerrain;
            projectileObj.DestroysWithEnemy       = data.DestroysWithEnemy;
            projectileObj.FollowArc               = data.FollowArc;
            projectileObj.Orientation             = MathHelper.ToRadians(data.StartingRotation);
            projectileObj.ShowIcon                = data.ShowIcon;
            projectileObj.IsCollidable            = data.IsCollidable;
            projectileObj.CollidesWith1Ways       = data.CollidesWith1Ways;
            projectileObj.DestroyOnRoomTransition = data.DestroyOnRoomTransition;
            projectileObj.CanBeFusRohDahed        = data.CanBeFusRohDahed;
            projectileObj.IgnoreInvincibleCounter = data.IgnoreInvincibleCounter;
            projectileObj.WrapProjectile          = data.WrapProjectile;
            var num = 0f;

            if (data.Target != null)
            {
                var num2 = data.Target.X - source.X;
                var num3 = data.Target.Y - source.Y - data.SourceAnchor.Y;
                if (source.Flip == SpriteEffects.FlipHorizontally)
                {
                    num   = 180f - num;
                    num2 += data.SourceAnchor.X;
                    num   = MathHelper.ToDegrees((float)Math.Atan2(num3, num2));
                    num  -= data.AngleOffset;
                }
                else
                {
                    num   = MathHelper.ToDegrees((float)Math.Atan2(num3, num2));
                    num2 -= data.SourceAnchor.X;
                    num  += data.AngleOffset;
                }
            }
            else
            {
                num = data.Angle.X + data.AngleOffset;
                if (data.Angle.X != data.Angle.Y)
                {
                    num = CDGMath.RandomFloat(data.Angle.X, data.Angle.Y) + data.AngleOffset;
                }
                if (source.Flip != SpriteEffects.None && source.Rotation != 0f)
                {
                    num -= 180f;
                }
                else if (source.Flip != SpriteEffects.None && source.Rotation == 0f)
                {
                    num = 180f - num;
                }
            }
            if (!data.LockPosition)
            {
                projectileObj.Rotation = num;
            }
            num = MathHelper.ToRadians(num);
            projectileObj.Damage = data.Damage;
            m_levelScreen.PhysicsManager.AddObject(projectileObj);
            projectileObj.ChangeSprite(data.SpriteName);
            projectileObj.RotationSpeed = data.RotationSpeed;
            projectileObj.Visible       = true;
            if (source.Flip != SpriteEffects.None)
            {
                projectileObj.X = source.AbsX - data.SourceAnchor.X;
            }
            else
            {
                projectileObj.X = source.AbsX + data.SourceAnchor.X;
            }
            projectileObj.Y          = source.AbsY + data.SourceAnchor.Y;
            projectileObj.IsWeighted = data.IsWeighted;
            var vector = new Vector2((float)Math.Cos(num), (float)Math.Sin(num));
            var num4   = data.Speed.X;

            if (data.Speed.X != data.Speed.Y)
            {
                num4 = CDGMath.RandomFloat(data.Speed.X, data.Speed.Y);
            }
            projectileObj.AccelerationX = vector.X * num4;
            projectileObj.AccelerationY = vector.Y * num4;
            projectileObj.CurrentSpeed  = num4;
            if (source is PlayerObj)
            {
                if (projectileObj.LifeSpan == 0f)
                {
                    projectileObj.LifeSpan = (source as PlayerObj).ProjectileLifeSpan;
                }
                projectileObj.CollisionTypeTag = 2;
                projectileObj.Scale            = data.Scale;
            }
            else
            {
                if (projectileObj.LifeSpan == 0f)
                {
                    projectileObj.LifeSpan = 15f;
                }
                projectileObj.CollisionTypeTag = 3;
                projectileObj.Scale            = data.Scale;
            }
            if (data.Target != null && data.Source.Flip == SpriteEffects.FlipHorizontally && data.ChaseTarget)
            {
                projectileObj.Orientation = MathHelper.ToRadians(180f);
            }
            if (data.Source is PlayerObj && (Game.PlayerStats.Traits.X == 22f || Game.PlayerStats.Traits.Y == 22f))
            {
                projectileObj.AccelerationX *= -1f;
                if (!data.LockPosition)
                {
                    if (data.Source.Flip == SpriteEffects.FlipHorizontally)
                    {
                        projectileObj.Flip = SpriteEffects.None;
                    }
                    else
                    {
                        projectileObj.Flip = SpriteEffects.FlipHorizontally;
                    }
                }
            }
            projectileObj.PlayAnimation();
            return(projectileObj);
        }
 public RogueAPI.Projectiles.ProjectileObj CheckOut()
 {
     return(m_projectilePool.CheckOut());
 }