Esempio n. 1
0
        public override bool Cast()
        {
            target = ((Player)Owner).Target;

            if (target == null || !base.Cast())
                return false;

            double distance = Math.Sqrt(
                              Math.Pow(Owner.Position.X - target.Position.X, 2) +
                              Math.Pow(Owner.Position.Y - target.Position.Y, 2));

            if (distance > range) // Portee de l'attaque
                return false;
            if (Owner.Direction == target.Direction) // Cast uniquement si le joueur est tourne vers l'entite
                return false;

            // Créer un vecteur directeur
            Vector2 move = target.Position + new Vector2(target.TextureSize.X, target.TextureSize.Y) / 2;

            move -= Owner.Position + new Vector2(Owner.TextureSize.X, Owner.TextureSize.Y) / 2;
            move.Normalize(); // Donne au vecteur la taille d'un pixel

            target.Position += move * 5;
            target.Damage(Owner, 10);

            return true;
        }
Esempio n. 2
0
        public override bool Cast()
        {
            target = ((Player)Owner).Target;

            if (target == null || !base.Cast())
                return false;

            // Créer un vecteur directeur
            Vector2 move = target.Position + new Vector2(target.TextureSize.X, target.TextureSize.Y) / 2;

            move -= Owner.Position + new Vector2(Owner.TextureSize.X, Owner.TextureSize.Y) / 2;
            move.Normalize(); // Donne au vecteur la taille d'un pixel

            target.Position += move * 20;
            target.Damage(Owner, 20);

            return true;
        }
Esempio n. 3
0
        public override void Update(GameTime gameTime)
        {
            if (CanMove)
            {
                Vector2 oldPos = Position;
                base.Update(gameTime);
                InternalMove(gameTime);
                if (MouseManager.IsRightClicked()) //Deplacement a la souris
                    pos = GameScreen.camera.Location(MouseManager.Position);
                if (pos.X > 0 && pos.Y > 0)
                    new Maps.Path.Ia(gameTime, pos, this, this.Game.MapFirst.Data);
                if (oldPos == Position)
                    Step = 1;
            }

            coord = new Vector2((int)Math.Ceiling(Position.X * 32 / 1000) - 1, (int)Math.Ceiling(Position.Y * 32 / 1000) - 1);

            Keys[] keys = new[] {Keys.Q, Keys.A, Keys.E, Keys.R, Keys.D2 };

            for (int i = 0; i < spells.Count; i++)
            {
                if (keys.Length < i) break;
                if (!KeyboardManager.IsPressed(keys[i]) && !(MouseManager.IsInRectangle(spellsRect[i]) && MouseManager.IsLeftClicked())) continue;

                if (spells[i].Type == SpellType.Buff) // Si le sort est un Buff...
                {
                    if (spells[i].IsActivated)
                        spells[i].Unbuff();
                    else
                        spells[i].Buff();
                }
                else
                    spells[i].Cast();
            }

            if (KeyboardManager.IsPressed(Keys.Tab) || MouseManager.IsLeftClicked()) // Change de cible
            {
                if (Target != null)
                    Target.Targeter = null;

                if (KeyboardManager.IsPressed(Keys.Tab))
                {
                    IList<Monster> monsters = Game.Entities.OfType<Monster>().ToList();
                    ++targetIndex;
                    if (targetIndex >= monsters.Count)
                        targetIndex = (monsters.Count > 0 ? 0 : -1);
                    Target = targetIndex >= 0 ? monsters[targetIndex] : null;
                }
                else
                {
                    foreach (Monster monster in Game.Entities.OfType<Monster>())
                    {
                        if (MouseManager.IsInRectangle(monster.Bounds, GameScreen.camera))
                            Target = monster;
                    }
                }

                if (Target != null)
                    Target.Targeter = this;
            }

            if (KeyboardManager.IsPressed(Keys.Escape)) // Deselectionne une cible
            {
                if (Target != null)
                    Target.Targeter = null;
                Target = null;
            }

            // Insérer tout le cheat
            if (Keyboard.GetState().IsKeyDown(Keys.D1))
                Power = Stats.PowerMax;
            // Insérer tout le cheat

            foreach (Spell spell in spells) // Update tout les spells
                spell.Update(gameTime);

            Regeneration(gameTime);
        }
Esempio n. 4
0
        public override void Update(GameTime gameTime)
        {
            if (CanMove)
            {
                base.Update(gameTime);
                InternalMove(gameTime);
            }

            coord = new Vector2((int)Math.Ceiling(Position.X * 32 / 1000) - 1, (int)Math.Ceiling(Position.Y * 32 / 1000) - 1);

            // Pour le lancement de spells
            for (int i = 0; i < spells.Count; i++)
            {
                if (!KeyboardManager.IsPressed(KeyboardManager.BindedKeys[(int) KeyboardManager.KeysEnum.Spell1 + i]) && !(MouseManager.IsInRectangle(spellsRect[i]) && MouseManager.IsLeftClicked())) continue;

                if (spells[i].Type == SpellType.Buff)
                {
                    if (spells[i].IsActivated)
                        spells[i].Unbuff();
                    else
                        spells[i].Buff();
                }
                else
                    spells[i].Cast();
            }

            // Change de cible
            if (KeyboardManager.IsPressed(KeyboardManager.BindedKeys[(int)KeyboardManager.KeysEnum.Target]) || MouseManager.IsLeftClicked())
            {
                if (Target != null)
                    Target.Targeter = null;

                if (KeyboardManager.IsPressed(KeyboardManager.BindedKeys[(int)KeyboardManager.KeysEnum.Target]))
                {
                    IList<Monster> monsters = Game.Entities.OfType<Monster>().ToList();
                    ++targetIndex;
                    if (targetIndex >= monsters.Count)
                        targetIndex = (monsters.Count > 0 ? 0 : -1);
                    Target = targetIndex >= 0 ? monsters[targetIndex] : null;
                }
                else
                {
                    foreach (Monster monster in Game.Entities.OfType<Monster>())
                    {
                        if (MouseManager.IsInRectangle(GameScreen.Camera.ScreenLocation(MouseManager.Position), monster.Bounds))
                            Target = monster;
                    }
                }

                if (Target != null)
                    Target.Targeter = this;
            }

            // Deselectionne une cible
            if (KeyboardManager.IsPressed(KeyboardManager.BindedKeys[(int)KeyboardManager.KeysEnum.Escape]))
            {
                if (Target != null)
                    Target.Targeter = null;
                Target = null;
            }

            // Insérer tout le cheat
            if (Keyboard.GetState().IsKeyDown(Keys.D0))
                Power = Stats.PowerMax;

            // Update tout les spells
            foreach (Spell spell in spells)
                spell.Update(gameTime);

            Regeneration(gameTime);
        }