コード例 #1
0
ファイル: Enemy.cs プロジェクト: kuzawskak/DungeonVandal
 /// <summary>
 /// Poruszanie w określonym kierunku
 /// </summary>
 /// <param name="add_x">Zmiana indeksu x na tablicy obiektów</param>
 /// <param name="add_y">Zmiana indeksu y na tablicy obiektów </param>
 /// <param name="map">Mapa obiektów</param>
 public void MoveInDirection(int add_x, int add_y, Map.Map map)
 {
     int new_x = x + add_x;
     int new_y = y + add_y;
     collision_obj = map.getObject(new_x, new_y);
     if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste) || collision_obj.GetType() == typeof(DestroyableObjects.Ziemia))
     {
         map.setObject(new_x, new_y, this);
         map.setObject(x, y, new NonDestroyableObjects.Puste(content, new Rectangle(x * this.rectangle.Width, y * this.rectangle.Height, this.rectangle.Width, this.rectangle.Height),x,y));
         x = new_x;
         y = new_y;
     }
 }
コード例 #2
0
ファイル: Enemy.cs プロジェクト: kuzawskak/DungeonVandal-new
        /// <summary>
        /// Poruszanie w określonym kierunku
        /// </summary>
        /// <param name="add_x">Zmiana indeksu x na tablicy obiektów</param>
        /// <param name="add_y">Zmiana indeksu y na tablicy obiektów </param>
        /// <param name="map">Mapa obiektów</param>
        public void MoveInDirection(int add_x, int add_y, Map.Map map)
        {
            int new_x = x + add_x;
            int new_y = y + add_y;

            collision_obj = map.getObject(new_x, new_y);
            if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste) || collision_obj.GetType() == typeof(DestroyableObjects.Ziemia))
            {
                map.setObject(new_x, new_y, this);
                map.setObject(x, y, new NonDestroyableObjects.Puste(content, new Rectangle(x * this.rectangle.Width, y * this.rectangle.Height, this.rectangle.Width, this.rectangle.Height), x, y));
                x = new_x;
                y = new_y;
            }
        }
コード例 #3
0
        /// <summary>
        /// Poruszanie w wyznaczonym kierunku
        /// </summary>
        /// <param name="add_x">przyrost indeksu w poziomie</param>
        /// <param name="add_y">przyrost indeksu w pionie</param>
        /// <param name="map">mapa obiektow</param>
        public void MoveInDirection(int add_x, int add_y, Map.Map map)
        {
            int new_x = x + add_x;
            int new_y = y + add_y;

            collision_obj = map.getObject(new_x, new_y);
            if (collision_obj.IsAccesible)
            {
                if (collision_obj is Weapon.Weapon)
                {
                    (collision_obj as Weapon.Weapon).OnFound(map);
                }

                if (collision_obj is Zniszczalny)
                {
                    (collision_obj as Zniszczalny).OnDestroy(map);
                }



                map.setObject(new_x, new_y, this);
                if (!(collision_obj is Eteryczny))
                {
                    map.setObject(x, y, new NonDestroyableObjects.Puste(content, new Rectangle(x * this.rectangle.Width, y * this.rectangle.Height, this.rectangle.Width, this.rectangle.Height), x, y));
                }

                x = new_x;
                y = new_y;
            }
            else if (add_y == 0 && collision_obj is Przesuwalny && (collision_obj as Przesuwalny).Przesun(map, add_x))
            {
                map.setObject(x, y, new NonDestroyableObjects.Puste(content, new Rectangle(x * this.rectangle.Width, y * this.rectangle.Height, this.rectangle.Width, this.rectangle.Height), x, y));
                map.setObject(new_x, new_y, this);
                x = new_x;
                y = new_y;
            }
            else if (!map.GetVandal().is_immortal&& collision_obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
            {
                this.is_alive = false;
            }
        }
コード例 #4
0
        /// <summary>
        /// Wystrzel rakiete
        /// </summary>
        /// <param name="game_map">mapa obiektow</param>
        public void AttackWithRacket(Map.Map game_map)
        {
            Map.MapObject collision_obj = null;
            switch (view_direction)
            {
            case Game.direction.down:
                collision_obj = game_map.getObject(x, y + 1);
                break;

            case Game.direction.up:
                collision_obj = game_map.getObject(x, y - 1);
                break;

            case Game.direction.right:
                collision_obj = game_map.getObject(x + 1, y);
                break;

            case Game.direction.left:
                collision_obj = game_map.getObject(x - 1, y);
                break;
            }


            if (collision_obj != null && (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste) || collision_obj.IsAccesible))
            {
                Map.MapObject racket = new Weapon.Racket(content, collision_obj.rectangle, collision_obj.x, collision_obj.y, view_direction);
                game_map.setObject(collision_obj.x, collision_obj.y, racket);

                SoundEffect fire_racket_effect = content.Load <SoundEffect>("Audio\\fire_racket");
                if (!game_map.player.AudioSettings.IsMuted)
                {
                    SoundEffect.MasterVolume = (float)game_map.player.AudioSettings.SoundVolume;
                    fire_racket_effect.Play();
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Upusc dynamit
        /// </summary>
        /// <param name="game_map">mapa obiektow</param>
        /// <param name="gametime">czas gry</param>
        public void LeftDynamite(Map.Map game_map, GameTime gametime)
        {
            int dyn_x = x - 1;
            int dyn_y = y;

            switch (view_direction)
            {
            case Game.direction.right:
                dyn_x = x - 1;
                dyn_y = y;
                break;

            case Game.direction.left:
                dyn_x = x + 1;
                dyn_y = y;
                break;

            case Game.direction.up:
                dyn_x = x;
                dyn_y = y + 1;
                break;

            case Game.direction.down:
                dyn_x = x;
                dyn_y = y - 1;
                break;
            }

            //nie zmieniamy pozycji Vandala (wstawiamy dynamit za Vandalem)
            collision_obj = game_map.getObject(dyn_x, dyn_y);
            if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste))
            {
                game_map.setObject(dyn_x, dyn_y, new Weapon.Dynamit(content, new Rectangle(dyn_x * this.rectangle.Width, dyn_y * this.rectangle.Height, this.rectangle.Width, this.rectangle.Height), dyn_x, dyn_y, gametime));
                game_map.addPlayersDynamites(-1);
            }
        }
コード例 #6
0
        /// <summary>
        /// Aktualizacja stanu rakiety
        /// </summary>
        /// <param name="gametime">Czas gry</param>
        /// <param name="map">Mapa obiektów</param>
        public override void Update(GameTime gametime, Map.Map map)
        {
            if (gametime.TotalGameTime.Milliseconds % 20 == 0 && is_fired)
            {
                int collision_x = x;
                int collision_y = y;
                switch (direction)
                {
                case Game.direction.down:
                    texture     = content.Load <Texture2D>("Textures\\racket_down");
                    collision_x = x;
                    collision_y = y + 1;

                    break;

                case Game.direction.up:
                    texture     = content.Load <Texture2D>("Textures\\racket_up");
                    collision_x = x;
                    collision_y = y - 1;

                    break;

                case Game.direction.left:
                    texture     = content.Load <Texture2D>("Textures\\racket_left");
                    collision_x = x - 1;
                    collision_y = y;

                    break;

                case Game.direction.right:
                    texture     = content.Load <Texture2D>("Textures\\racket_right");
                    collision_x = x + 1;
                    collision_y = y;

                    break;
                }

                if (map.getObject(collision_x, collision_y).GetType() != typeof(NonDestroyableObjects.Puste) && map.getObject(collision_x, collision_y) != this)
                {
                    if (map.player.Rackets > 0)
                    {
                        map.addPlayersRacket(-1);



                        //explosion
                        SoundEffect explosion_sound = content.Load <SoundEffect>("Audio\\explosion_sound");
                        if (!map.player.AudioSettings.IsMuted)
                        {
                            SoundEffect.MasterVolume = (float)map.player.AudioSettings.SoundVolume;
                            explosion_sound.Play();
                        }
                        int vandal_x = map.GetVandal().x;
                        int vandal_y = map.GetVandal().y;

                        Map.MapObject
                            obj = map.getObject(x - 1, y - 1);
                        if (obj is Zniszczalny)
                        {
                            (obj as Zniszczalny).OnDestroy(map);
                        }
                        else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
                        {
                            (obj as Characters.Enemy).Die(map);
                        }
                        obj = map.getObject(x - 1, y + 1);
                        if (obj is Zniszczalny)
                        {
                            (obj as Zniszczalny).OnDestroy(map);
                        }
                        else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
                        {
                            (obj as Characters.Enemy).Die(map);
                        }
                        obj = map.getObject(x - 1, y);
                        if (obj is Zniszczalny)
                        {
                            (obj as Zniszczalny).OnDestroy(map);
                        }
                        else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
                        {
                            (obj as Characters.Enemy).Die(map);
                        }
                        obj = map.getObject(x, y - 1);
                        if (obj is Zniszczalny)
                        {
                            (obj as Zniszczalny).OnDestroy(map);
                        }
                        else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
                        {
                            (obj as Characters.Enemy).Die(map);
                        }
                        obj = map.getObject(x, y + 1);
                        if (obj is Zniszczalny)
                        {
                            (obj as Zniszczalny).OnDestroy(map);
                        }
                        else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
                        {
                            (obj as Characters.Enemy).Die(map);
                        }
                        obj = map.getObject(x + 1, y);
                        if (obj is Zniszczalny)
                        {
                            (obj as Zniszczalny).OnDestroy(map);
                        }
                        else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
                        {
                            (obj as Characters.Enemy).Die(map);
                        }
                        obj = map.getObject(x + 1, y - 1);
                        if (obj is Zniszczalny)
                        {
                            (obj as Zniszczalny).OnDestroy(map);
                        }
                        else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
                        {
                            (obj as Characters.Enemy).Die(map);
                        }
                        obj = map.getObject(x + 1, y + 1);
                        if (obj is Zniszczalny)
                        {
                            (obj as Zniszczalny).OnDestroy(map);
                        }
                        else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
                        {
                            (obj as Characters.Enemy).Die(map);
                        }


                        //miejsce w ktorym rakieta sie zatrzymala
                        map.setObject(x, y, new NonDestroyableObjects.Puste(content, this.rectangle, x, y));
                    }
                }
                else
                {
                    map.setObject(collision_x, collision_y, this);
                    map.setObject(x, y, new NonDestroyableObjects.Puste(content, this.rectangle, x, y));
                    this.x = collision_x;
                    this.y = collision_y;
                }
            }
        }
コード例 #7
0
ファイル: Vandal.cs プロジェクト: kuzawskak/DungeonVandal-new
        /// <summary>
        /// Poruszanie w wyznaczonym kierunku
        /// </summary>
        /// <param name="add_x">przyrost indeksu w poziomie</param>
        /// <param name="add_y">przyrost indeksu w pionie</param>
        /// <param name="map">mapa obiektow</param>
        public void MoveInDirection(int add_x, int add_y, Map.Map map)
        {
            int new_x = x + add_x;
            int new_y = y + add_y;
            collision_obj = map.getObject(new_x, new_y);
            if (collision_obj.IsAccesible)
            {
                if (collision_obj is Weapon.Weapon)
                {
                    (collision_obj as Weapon.Weapon).OnFound(map);
                }

                if (collision_obj is Zniszczalny)
                    (collision_obj as Zniszczalny).OnDestroy(map);

                map.setObject(new_x, new_y, this);
                if (!(collision_obj is Eteryczny))
                    map.setObject(x, y, new NonDestroyableObjects.Puste(content, new Rectangle(x * this.rectangle.Width, y * this.rectangle.Height, this.rectangle.Width, this.rectangle.Height), x, y));

                x = new_x;
                y = new_y;
            }
            else if (add_y == 0 && collision_obj is Przesuwalny && (collision_obj as Przesuwalny).Przesun(map, add_x))
            {
                map.setObject(x, y, new NonDestroyableObjects.Puste(content, new Rectangle(x * this.rectangle.Width, y * this.rectangle.Height, this.rectangle.Width, this.rectangle.Height), x, y));
                map.setObject(new_x, new_y, this);
                x = new_x;
                y = new_y;
            }
            else if (!map.GetVandal().is_immortal && collision_obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
            {
                this.is_alive = false;
            }
        }
コード例 #8
0
ファイル: Vandal.cs プロジェクト: kuzawskak/DungeonVandal-new
        /// <summary>
        /// Upusc dynamit
        /// </summary>
        /// <param name="game_map">mapa obiektow</param>
        /// <param name="gametime">czas gry</param>
        public void LeftDynamite(Map.Map game_map, GameTime gametime)
        {
            int dyn_x = x - 1;
            int dyn_y = y;
            switch (view_direction)
            {
                case Game.direction.right:
                    dyn_x = x - 1;
                    dyn_y = y;
                    break;
                case Game.direction.left:
                    dyn_x = x + 1;
                    dyn_y = y;
                    break;
                case Game.direction.up:
                    dyn_x = x;
                    dyn_y = y + 1;
                    break;
                case Game.direction.down:
                    dyn_x = x;
                    dyn_y = y - 1;
                    break;

            }

            //nie zmieniamy pozycji Vandala (wstawiamy dynamit za Vandalem)
            collision_obj = game_map.getObject(dyn_x, dyn_y);
            if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste))
            {
                game_map.setObject(dyn_x, dyn_y, new Weapon.Dynamit(content, new Rectangle(dyn_x * this.rectangle.Width, dyn_y * this.rectangle.Height, this.rectangle.Width, this.rectangle.Height), dyn_x, dyn_y, gametime));
                game_map.addPlayersDynamites(-1);
            }
        }
コード例 #9
0
ファイル: Vandal.cs プロジェクト: kuzawskak/DungeonVandal-new
        /// <summary>
        /// Wystrzel rakiete
        /// </summary>
        /// <param name="game_map">mapa obiektow</param>
        public void AttackWithRacket(Map.Map game_map)
        {
            Map.MapObject collision_obj = null;
            switch (view_direction)
            {
                case Game.direction.down:
                    collision_obj = game_map.getObject(x, y + 1);
                    break;
                case Game.direction.up:
                    collision_obj = game_map.getObject(x, y - 1);
                    break;
                case Game.direction.right:
                    collision_obj = game_map.getObject(x + 1, y);
                    break;
                case Game.direction.left:
                    collision_obj = game_map.getObject(x - 1, y);
                    break;
            }

            if (collision_obj != null && (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste) || collision_obj.IsAccesible))
            {

                Map.MapObject racket = new Weapon.Racket(content, collision_obj.rectangle, collision_obj.x, collision_obj.y, view_direction);
                game_map.setObject(collision_obj.x, collision_obj.y, racket);

                SoundEffect fire_racket_effect = content.Load<SoundEffect>("Audio\\fire_racket");
                if (!game_map.player.AudioSettings.IsMuted)
                {
                    SoundEffect.MasterVolume = (float)game_map.player.AudioSettings.SoundVolume;
                    fire_racket_effect.Play();
                }
            }
        }
コード例 #10
0
        public override void Update(GameTime gametime, Map.Map map)
        {
            if (gametime.TotalGameTime.Milliseconds % 10 == 0)
            {
                current_direction = Move(map);

                switch (current_direction)
                {
                    case Game.direction.down:

                        {
                            collision_obj = map.getObject(x,y + 1);
                            if (collision_obj.GetType()==typeof(NonDestroyableObjects.Puste))
                            {
                                MoveInDirection(0, 1, map);
                            }
                             else if(collision_obj.GetType()!=typeof(DestroyableObjects.Ziemia))
                            {
                               FireBomb(map);
                            }
                        }

                        break;
                    case Game.direction.left:
                        if (rectangle.X > 0)
                        {
                            collision_obj = map.getObject(x-1,y);
                            if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste))
                            {
                                MoveInDirection(-1, 0, map);
                            }
                            else if(collision_obj.GetType()!=typeof(DestroyableObjects.Ziemia))
                            {
                               FireBomb(map);
                            }
                        }

                        break;
                    case Game.direction.right:

                            collision_obj = map.getObject(x + 1, y);
                            if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste))
                            {
                                MoveInDirection(1, 0, map);
                            }
                             else if(collision_obj.GetType()!=typeof(DestroyableObjects.Ziemia))
                            {
                               FireBomb(map);
                            }

                        break;
                    case Game.direction.up:
                        if (rectangle.Y > 0)
                        {
                            collision_obj = map.getObject(x , y-1);
                            if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste))
                            {
                                MoveInDirection(0, -1, map);
                            }
                             else if(collision_obj.GetType()!=typeof(DestroyableObjects.Ziemia))
                            {
                               FireBomb(map);
                            }
                        }

                        break;
                    default:
                        break;

                }
            }
        }