Esempio n. 1
0
        public void Hit()
        {
            if (!IsInvincible)
            {
                _lives--;
                _deadSound.Play();

                var yellow = new Color(0.8f, 0.8f, 0.4f);

                for (int i = 0; i < 1200; i++)
                {
                    float speed = 18f * (1f - 1 / GameRef.Rand.NextFloat(1f, 10f));
                    Color color = Color.Lerp(Color.White, yellow, GameRef.Rand.NextFloat(0, 1));
                    var   state = new ParticleState()
                    {
                        Velocity         = GameRef.Rand.NextVector2(speed, speed),
                        Type             = ParticleType.None,
                        LengthMultiplier = 1
                    };

                    GameRef.ParticleManager.CreateParticle(GameRef.LineParticle, Position, color, 190, 1.5f, state);
                }

                _timeBeforeRespawn = Config.PlayerTimeBeforeRespawn;
                IsInvincible       = true;
                CollisionBoxes.Add(_shieldCollisionCircle);
            }
        }
Esempio n. 2
0
        protected override void LoadContent()
        {
            base.LoadContent();

            Sprite        = GameRef.Content.Load <Texture2D>("Graphics/Entities/player");
            _bulletSprite = GameRef.Content.Load <Texture2D>("Graphics/Entities/player_bullet");
            _hitboxSprite = GameRef.Content.Load <Texture2D>("Graphics/Pictures/player_hitbox");
            CollisionBoxes.Add(new CollisionCircle(this, new Vector2(Sprite.Height / 6f, Sprite.Height / 6f), _hitboxRadius / 2f));

            _shieldSprite          = GameRef.Content.Load <Texture2D>("Graphics/Entities/shield");
            _shieldOrigin          = new Vector2(_shieldSprite.Width / 2f, _shieldSprite.Height / 2f);
            _shieldCollisionCircle = new CollisionCircle(this, Vector2.Zero, _shieldSprite.Width / 2f);

            _lifeIcon = GameRef.Content.Load <Texture2D>("Graphics/Pictures/life_icon");

            _bulletTimeBarLeft    = GameRef.Content.Load <Texture2D>("Graphics/Pictures/gauge_left");
            _bulletTimeBarContent = GameRef.Content.Load <Texture2D>("Graphics/Pictures/gauge_middle");
            _bulletTimeBarRight   = GameRef.Content.Load <Texture2D>("Graphics/Pictures/gauge_right");

            if (_shootSound == null)
            {
                _shootSound = GameRef.Content.Load <SoundEffect>(@"Audio/SE/hit");
            }
            if (_deadSound == null)
            {
                _deadSound = GameRef.Content.Load <SoundEffect>(@"Audio/SE/dead");
            }
        }
Esempio n. 3
0
 public Bullet(DnK gameRef, Texture2D sprite, Vector2 position, Vector2 direction, Vector2 velocity)
     : base(gameRef, sprite, position, direction, velocity)
 {
     Rotation  = (float)Math.Atan2(direction.Y, direction.X) - MathHelper.PiOver2;
     _distance = 0;
     WaveMode  = false;
     CollisionBoxes.Add(new CollisionCircle(this, Vector2.Zero, sprite.Width / 2f));
     Power = Improvements.ShootPowerData[PlayerData.ShootPowerIndex].Key;
 }
Esempio n. 4
0
        protected override void LoadContent()
        {
            Sprite = GameRef.Content.Load <Texture2D>("Graphics/Entities/boss_bullet_type3");
            CollisionBoxes.Add(new CollisionCircle(this, Vector2.Zero, Sprite.Height / 2f));
            Origin = new Vector2(Sprite.Height / 2f, Sprite.Height / 2f);
            _trail = GameRef.Content.Load <Texture2D>("Graphics/Pictures/trail");

            base.LoadContent();
        }
Esempio n. 5
0
 public BulletView(Texture2D sprite, Vector2 position, Vector2 direction, Vector2 velocity)
 {
     Position  = position;
     Sprite    = sprite;
     Velocity  = velocity;
     Direction = direction;
     Rotation  = (float)Math.Atan2(direction.Y, direction.X) - MathHelper.PiOver2;
     _distance = 0;
     WaveMode  = false;
     CollisionBoxes.Add(new CollisionCircle(this, Vector2.Zero, sprite.Width / 2f));
     Power = Improvements.ShootPowerData[PlayerData.ShootPowerIndex].Key;
 }
Esempio n. 6
0
        protected override void InitializeLogic()
        {
            var logicSet = new LogicSet(this);

            logicSet.AddAction(new ChangePropertyLogicAction(this, "Shake", true));
            logicSet.AddAction(new DelayLogicAction(1f));
            logicSet.AddAction(new ChangePropertyLogicAction(this, "Shake", false));
            logicSet.AddAction(new DelayLogicAction(1f));
            var logicSet2 = new LogicSet(this);

            logicSet2.AddAction(new ChaseLogicAction(m_target, Vector2.Zero, Vector2.Zero, true, 1f));
            var logicSet3 = new LogicSet(this);

            logicSet3.AddAction(new ChaseLogicAction(m_target, Vector2.Zero, Vector2.Zero, true, 1.75f));
            ThrowAdvancedProjectiles(logicSet3, true);
            var logicSet4 = new LogicSet(this);

            logicSet4.AddAction(new ChaseLogicAction(m_target, Vector2.Zero, Vector2.Zero, true, 1.75f));
            ThrowExpertProjectiles(logicSet4, true);
            var logicSet5 = new LogicSet(this);

            logicSet5.AddAction(new ChaseLogicAction(m_target, Vector2.Zero, Vector2.Zero, true, 1.25f));
            ThrowProjectiles(logicSet5, true);
            m_generalBasicLB.AddLogicSet(logicSet, logicSet2);
            m_generalAdvancedLB.AddLogicSet(logicSet, logicSet3);
            m_generalExpertLB.AddLogicSet(logicSet, logicSet4);
            m_generalMiniBossLB.AddLogicSet(logicSet, logicSet5);
            m_generalCooldownLB.AddLogicSet(logicSet, logicSet2);
            logicBlocksToDispose.Add(m_generalBasicLB);
            logicBlocksToDispose.Add(m_generalAdvancedLB);
            logicBlocksToDispose.Add(m_generalExpertLB);
            logicBlocksToDispose.Add(m_generalMiniBossLB);
            logicBlocksToDispose.Add(m_generalCooldownLB);
            base.InitializeLogic();
            CollisionBoxes.Clear();
            CollisionBoxes.Add(new CollisionBox((int)(-18f * ScaleX), (int)(-24f * ScaleY), (int)(36f * ScaleX),
                                                (int)(48f * ScaleY), 2, this));
            CollisionBoxes.Add(new CollisionBox((int)(-15f * ScaleX), (int)(-21f * ScaleY), (int)(31f * ScaleX),
                                                (int)(44f * ScaleY), 1, this));
            if (Difficulty == GameTypes.EnemyDifficulty.MINIBOSS)
            {
                (GetChildAt(0) as SpriteObj).ChangeSprite("GiantPortrait_Sprite");
                Scale = new Vector2(2f, 2f);
                AddChild(new SpriteObj("Portrait" + CDGMath.RandomInt(0, 7) + "_Sprite")
                {
                    OverrideParentScale = true
                });
                CollisionBoxes.Clear();
                CollisionBoxes.Add(new CollisionBox(-124, -176, 250, 354, 2, this));
                CollisionBoxes.Add(new CollisionBox(-124, -176, 250, 354, 1, this));
            }
        }
Esempio n. 7
0
        protected override void LoadContent()
        {
            Sprite    = GameRef.Content.Load <Texture2D>("Graphics/Entities/boss_core");
            _eyeOrbit = GameRef.Content.Load <Texture2D>("Graphics/Entities/eye_orbit");

            // TODO: Upadte AnimatedSprite class to take a "rectangle" order
            var animation = new Animation(6, 42, 38, 0, 0, 2);

            Origin          = new Vector2(21, 19);
            Scale           = new Vector2(1.5f, 1.5f);
            _animatedSprite = new AnimatedSprite(Sprite, animation, Position)
            {
                IsAnimating = false
            };
            CollisionBoxes.Add(new CollisionCircle(_parent, Vector2.Zero, 25));
            base.LoadContent();
        }
Esempio n. 8
0
 protected override void LoadContent()
 {
     Sprite = GameRef.Content.Load <Texture2D>("Graphics/Entities/base_turret");
     CollisionBoxes.Add(new CollisionCircle(this, Vector2.Zero, Sprite.Width / 2f));
 }
Esempio n. 9
0
        // Create multiple collision boxes from BossStructure
        private void ComputeCollisionBoxes()
        {
            CollisionBoxes.Clear();
            _collisionBoxesHp.Clear();

            // TODO: Handle the case where there is 2 vertices with Y = 0
            var vertices       = _structure.GetVertices();
            var bottomVertices = new List <Vector2>(); // the lowest vertex for each step
            var topVertices    = new List <Vector2>(); // the highest vertex for each step
            var currentStep    = 0f;

            for (var i = 0; i < vertices.Length; i++)
            {
                // Bottom part
                if (vertices[i].Y >= 0)
                {
                    if (vertices[i].X > currentStep)
                    {
                        bottomVertices.Add(vertices[i - 1]);
                        bottomVertices.Add(vertices[i]);
                    }
                }
                // Top part
                else
                {
                    if (vertices[i].X < currentStep)
                    {
                        topVertices.Add(vertices[i - 1]);
                        topVertices.Add(vertices[i]);
                    }
                }

                currentStep = vertices[i].X;
            }

            if (bottomVertices.Count != topVertices.Count)
            {
                // Left part
                if (bottomVertices.First().Y.Equals(0f))
                {
                    topVertices.Add(vertices[vertices.Length - 1]);
                    topVertices.Add(bottomVertices.First());
                    topVertices.Reverse();
                }
                // Right part
                else if (bottomVertices.Last().Y.Equals(0f))
                {
                    topVertices.Reverse();
                    topVertices.Add(bottomVertices.Last());
                }
            }
            else
            {
                topVertices.Reverse();
            }

            if (bottomVertices.Count != topVertices.Count)
            {
                return;
            }

            for (var i = 1; i < bottomVertices.Count; i += 2)
            {
                var boxVertices = new List <Vector2>
                {
                    bottomVertices[i],
                    bottomVertices[i - 1],
                    topVertices[i - 1],
                    topVertices[i]
                };

                var collisionBox = new CollisionConvexPolygon(this, Vector2.Zero, boxVertices);
                CollisionBoxes.Add(collisionBox);
                _collisionBoxesHp.Add(collisionBox, 100f);
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Triggers Collision resolution for PlayerActor's Update() method, and adds Rectangle for
 /// handling to the CollisionBoxes list
 /// </summary>
 /// <param name="collisionRectangle">Rectangle specifying the exact space of intersecting BoundingBoxes</param>
 public void HasCollided(Rectangle collisionRectangle)
 {
     IsColliding = true;
     CollisionBoxes.Add(collisionRectangle);
 }