Example #1
0
 /// <summary>
 /// Creates and adds stomp particles where the entity is.
 /// </summary>
 /// <param name="count"></param>
 public void CreateStompParticles(int count)
 {
     if (_stompParticleTimer.TimeElapsedInMilliSeconds > 100)
     {
         for (int i = 0; i < count; i++)
         {
             ParticleSystem.Add(ParticleType.Smoke, new Vector2(CalcHelper.GetRandomX(GetCollRectangle()), GetCollRectangle().Bottom), new Vector2(TMBAW_Game.Random.Next(-5, 5) / 10f, -TMBAW_Game.Random.Next(1, 5) / 10f), Color.White);
         }
         _stompParticleTimer.Reset();
     }
 }
Example #2
0
        public void OnJumpAction(Player player)
        {
            float jumpAcc = JumpAcc;

            if (player.IsDucking)
            {
                player.WantsToMoveDownPlatform = true;
                player.AddAnimationToQueue("fall");
                return;
            }
            if (player.IsClimbing)
            {
                if (player.IsInteractPressed())
                {
                    return;
                }
                player.IsClimbing = false;
                player.IsJumping  = false;

                if (player.IsMoveDownPressed())
                {
                    jumpAcc = 0;
                }
            }
            if (!player.IsJumping)
            {
                player.Sounds.GetSoundRef("jump").Play();
                player.IsJumping = true;
                player.SetVelY(jumpAcc);
                player.ChangePosBy(0, -1);
                player.AddAnimationToQueue("jump");
                player.CollidedWithTileBelow += OnTouchGround;
                _lastJumpTimer.Reset();
                player.GravityStrength = TMBAW_Game.Gravity * .5f;

                if (jumpAcc != 0)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        ParticleSystem.Add(ParticleType.Smoke, new Vector2(CalcHelper.GetRandomX(player.GetCollRectangle()), player.GetCollRectangle().Bottom), new Vector2(TMBAW_Game.Random.Next((int)player.GetVelocity().X - 1, (int)player.GetVelocity().X + 1) / 10f, -TMBAW_Game.Random.Next(1, 10) / 10f), Color.White);
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Deals a certain amount of damage to the entity.
        /// </summary>
        /// <param name="damageDealer">Can be null.</param>
        /// <param name="damage"></param>
        public virtual void TakeDamage(Entity damageDealer, int damage)
        {
            if (TMBAW_Game.CurrentGameMode == GameMode.Play)
            {
                if (IsTakingDamage || IsPlayingDeathAnimation || !CanTakeDamage)
                {
                    return;
                }

                if (this is Player)
                {
                    Overlay.ColoredCorners.FlashColor(Color.Red);
                }

                // Main.TimeFreeze.AddFrozenTime(damage*3);

                IsTakingDamage = true;
                Health        -= damage;
                ParticleSystem.Add("-" + damage, Center, new Vector2(TMBAW_Game.Random.Next(0, 2) * -2 + 1, -15), new Color(255, 108, 108));
                _hitRecentlyTimer.ResetAndWaitFor(500);
                _hitRecentlyTimer.SetTimeReached += HitByPlayerTimer_SetTimeReached;

                //Creates damage particles.
                int particleCount = damage / 2;
                if (particleCount > 100)
                {
                    particleCount = 100;
                }
                for (int i = 0; i < particleCount; i++)
                {
                    ParticleSystem.Add(ParticleType.Round_Common, CalcHelper.GetRandXAndY(CollRectangle), null, Color.Red);
                }

                //if (damageDealer == null)
                //    return;

                //Velocity.Y = -8f;
                //Velocity.X = (Weight / 2f);
                //if (!damageDealer.IsFacingRight)
                //    Velocity.X *= -1;

                HasTakenDamage?.Invoke();
            }
        }
Example #4
0
        /// <summary>
        /// Creates death particles and calls event to do other death related things.
        /// </summary>
        private void DeathAnimationEnded()
        {
            _deathAnimationTimer.SetTimeReached -= DeathAnimationEnded;
            IsDead = true;

            for (int i = 0; i < 20; i++)
            {
                ParticleSystem.Add(ParticleType.Smoke, CalcHelper.GetRandXAndY(CollRectangle), new Vector2(0, -TMBAW_Game.Random.Next(1, 5) / 10f), Color.White);
            }

            //Rectangle[] desinRectangles;
            //GetDisintegratedRectangles(out desinRectangles);
            //foreach (Rectangle rect in desinRectangles)
            //{
            //    EntityTextureParticle par = new EntityTextureParticle(CalcHelper.GetRandomX(CollRectangle), CalcHelper.GetRandomY(CollRectangle), rect, new Vector2(Main.Random.Next(-5, 5) / 10f, -Main.Random.Next(-5, 5) / 10f), this);
            //    GameWorld.ParticleSystem.Add(par);
            //}

            HasFinishedDying?.Invoke(this);
        }
Example #5
0
 /// <summary>
 /// Gets the entity' tile index. The tile index is used to determine an entity's position in the map.
 /// </summary>
 ///
 /// <returns></returns>
 public int GetTileIndex()
 {
     return(CalcHelper.GetIndexInGameWorld(CollRectangle.Center.X, CollRectangle.Center.Y));
     //if (GameWorld.WorldData == null) return -1;
     //return (int)(CollRectangle.Center.Y / AdamGame.Tilesize * GameWorld.WorldData.LevelWidth) + (int)(CollRectangle.Center.X / AdamGame.Tilesize);
 }