Пример #1
0
        public void OnDeath(PlayingScreen p)
        {
            if (IsPlayer)
            {
                //addScreen.DeathScreen();
                IsTriggeredDeath = true;
                return;
            }
            Nemesis.ModifyResourceValue("xp", MaxExp);
            var rnd = Rng.Noxt(3);

            if (rnd == 1)
            {
                p.ScreenManager.GetScreen <PlayingScreen>().items.Add(new Usable(UsableType.HealthPot, PlayingScreen.itemSheet)
                {
                    Position = new Vector2(Position.X + Rng.Noxt(-10, 10), Position.Y + Rng.Noxt(-10, 10))
                });
            }
            if (rnd == 2)
            {
                p.ScreenManager.GetScreen <PlayingScreen>().items.Add(new Usable(UsableType.ManaPot, PlayingScreen.itemSheet)
                {
                    Position = new Vector2(Position.X + Rng.Noxt(-10, 10), Position.Y + Rng.Noxt(-10, 10))
                });
            }

            IsTriggeredDeath = true;
        }
Пример #2
0
        public void Update(GameTime gameTime, PlayingScreen p)
        {
            foreach (var item in enemies)
            {
                item.Update(gameTime, p);
                item.UpdateMovement(gameTime);
            }

            enemies.RemoveAll(e => !e.IsAlive);
        }
Пример #3
0
        public virtual void Update(GameTime gameTime, PlayingScreen p)
        {
            Delta = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (BeingPushed)
            {
                Position += Delta * Speed * PushDirection * -VelocityForce;
            }
            else if (!IsDead)
            {
                Position += Delta * Speed * Direction;
            }
            AttackCooldown -= Delta;

            HealthBar.Update(Health, MaxHealth, HealthBar.BarWidth, Position, Size);

            //if (NemesisTimer > 0)
            //    NemesisTimer = (int)extras.AddEverySecond(gameTime, NemesisTimer, -1, 1f);
            //else Nemesis = null;

            if (IsHit)
            {
                IsHitTimer--;
                if (IsHitTimer < 0)
                {
                    IsHit = false;
                    if (IsPlayer)
                    {
                        IsHitTimer = 20;
                    }
                    else
                    {
                        IsHitTimer = 10;
                    }
                }
            }
            if (IsInCombat)
            {
                IsInCombatTimer -= Delta;
                if (IsInCombatTimer < 0)
                {
                    IsInCombatTimer = 10;
                    IsInCombat      = false;
                }
            }
            if (Attacked)
            {
                AttackCooldownCounter--;
                if (AttackCooldown < 0)
                {
                    Attacked = false;
                }
            }
            if (BeingPushed)
            {
                if (VelocityForce > 0f)
                {
                    VelocityForce -= 0.2f;
                }
                else
                {
                    BeingPushed = false;
                }
            }
            if (IsDead)
            {
                if (!IsTriggeredDeath)
                {
                    OnDeath(p);
                }
                IsDeadTimer -= Delta;
                if (IsDeadTimer < 0)
                {
                    Exist = false;
                }
            }
            foreach (var t in textList)
            {
                t.Update(gameTime);
            }
        }
Пример #4
0
 public override void Update(GameTime gameTime, PlayingScreen p)
 {
     base.Update(gameTime, p);
 }
Пример #5
0
        public override void Update(GameTime gameTime, PlayingScreen p)
        {
            base.Update(gameTime, p);

            //attackDirection = Input.mPos - new Vector2(attackBox.X, attackBox.Y);
            //attackRotation = (float)Math.Atan2(attackDirection.Y, attackDirection.X);
            //Swing.Direction = Input.mPos - new Vector2(swingBox.X, swingBox.Y);
            //swingRotation = (float)Math.Atan2(Swing.Direction.Y, Swing.Direction.X);
            //swingPos = RotateAround(swingPos, new Vector2(Position.X + (Size.X / 2), (int)Position.Y + (Size.Y / 2)), swingRotation);
            inventory.Update(gameTime, this);

            if (!Attacked && !inventory.actionbar.Rectangle.Contains(Input.mPos))
            {
                if (Input.LeftHold())
                {
                    bool att = true;
                    if (inventory.bagSprite.Rectangle.Contains(Input.mPos))
                    {
                        if (inventory.IsDrawing)
                        {
                            att = false;
                        }
                    }
                    if (att)
                    {
                        IsAttacking = true;
                        Action(gameTime);
                    }
                }
            }
            else
            {
                IsAttacking       = false;
                IsAttackingTimer -= Delta;
            }

            #region keybinds
            if (Input.KeyClick(Keys.I) || Input.KeyClick(Keys.B))
            {
                if (inventory.IsDrawing)
                {
                    inventory.IsDrawing = false;
                }
                else
                {
                    inventory.IsDrawing = true;
                }
            }
            #region Movement
            Direction = new Vector2(0);
            if (Direction == new Vector2(0))
            {
                SetAnimation(new[] { GSheet[0, CurrentRow] });
            }
            if (AttackCooldown < 0.1)
            {
                if (Input.KeyHold(Keys.W))
                {
                    Direction = new Vector2(Direction.X, -1);
                    SetAnimation(Animations["walkup"]);
                }
                if (Input.KeyHold(Keys.S))
                {
                    Direction = new Vector2(Direction.X, 1);
                    SetAnimation(Animations["walkdown"]);
                }
                if (Input.KeyHold(Keys.A))
                {
                    Direction = new Vector2(-1, Direction.Y);
                    SetAnimation(Animations["walkleft"]);
                }
                if (Input.KeyHold(Keys.D))
                {
                    Direction = new Vector2(1, Direction.Y);
                    SetAnimation(Animations["walkright"]);
                }



                #endregion

                #region triangle
                // triangle above player
                if (Helper.IsPointInTri(Input.mWorldPos(cam, gd), Globals.ScreenTopLeft, Globals.ScreenTopRight, CenterBox))
                {
                    var mod = (int)(8);
                    CurrentRow     = 1;
                    attackBox      = new Rectangle((int)Position.X - (int)Size.X - (mod / 2), (int)Position.Y - (int)Size.Y - (mod / 2), (int)Swing.Size.Y + mod, (int)Swing.Size.X + mod + 8);
                    Swing.Rotation = MathHelper.ToRadians(270);
                }

                // triangle under player
                if (Helper.IsPointInTri(Input.mWorldPos(cam, gd), Globals.ScreenBotLeft, Globals.ScreenBotRight, CenterBox))
                {
                    var mod = (int)(8);
                    CurrentRow     = 0;
                    attackBox      = new Rectangle((int)Position.X - (int)Size.X - (mod / 2), (int)Position.Y + (int)Size.Y - (mod / 2) - 8, (int)Swing.Size.Y + mod, (int)Swing.Size.X + mod + 8);
                    Swing.Rotation = MathHelper.ToRadians(90);
                }

                // triangle left player
                if (Helper.IsPointInTri(Input.mWorldPos(cam, gd), Globals.ScreenTopLeft, Globals.ScreenBotLeft, CenterBox))
                {
                    var mod = (int)(8);
                    CurrentRow     = 3;
                    attackBox      = new Rectangle((int)Position.X - (int)Size.X - (mod / 2), (int)Position.Y - (int)Size.Y - (mod / 2), (int)Swing.Size.X + mod + 8, (int)Swing.Size.Y + mod);
                    Swing.Rotation = MathHelper.ToRadians(180);
                }

                // triangle right player
                if (Helper.IsPointInTri(Input.mWorldPos(cam, gd), Globals.ScreenTopRight, Globals.ScreenBotRight, CenterBox))
                {
                    var mod = (int)(8);
                    CurrentRow     = 2;
                    attackBox      = new Rectangle((int)Position.X + (int)Size.X - (mod / 2) - 8, (int)Position.Y - (int)Size.Y - (mod / 2), (int)Swing.Size.X + mod + 8, (int)Swing.Size.Y + mod);
                    Swing.Rotation = MathHelper.ToRadians(0);
                }
            }

            #endregion
            #endregion

            Swing.Update(gameTime);

            #region test
            if (Input.KeyHold(Keys.Left))
            {
            }
            if (Input.KeyHold(Keys.Right))
            {
            }
            if (Input.KeyHold(Keys.Up))
            {
            }
            if (Input.KeyHold(Keys.Down))
            {
            }
            #endregion
        }