当前位置: 首页>>代码示例>>C#>>正文


C# Map.GetVandal方法代码示例

本文整理汇总了C#中Map.GetVandal方法的典型用法代码示例。如果您正苦于以下问题:C# Map.GetVandal方法的具体用法?C# Map.GetVandal怎么用?C# Map.GetVandal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Map的用法示例。


在下文中一共展示了Map.GetVandal方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: isVandalInSight

        /// <summary>
        /// Funkcja dla AI szczura (sprawdza czy Vandal jest w zasiegu wzroku szczura - jesli tak - to wyznacza kierunk ruc)
        /// </summary>
        /// <param name="map">Mapa obiektów</param>
        /// <returns>Punkt reprezentujacy kierunek poruszania Gigantycznego Szczura</returns>
        public Point isVandalInSight(Map.Map map)
        {
            int x_move = 0;
            int y_move = 0;
            int vandal_x = map.GetVandal().x;
            int vandal_y = map.GetVandal().y;
            if (vandal_x == this.x)
            {
                int lower_ind = vandal_y<this.y?vandal_y:this.y;
                int higher_ind = vandal_y<this.y?this.y:vandal_y;
                for (int i = lower_ind + 1; i < higher_ind; i++)
                {
                    if (map.getObject(this.x, i).GetType() != typeof(NonDestroyableObjects.Puste))
                    {
                        y_move = 0;
                        break;
                    }
                //    else y_move = lower_ind == this.y ? 1 : -1;
                }

            }
            if (vandal_y == this.y)
            {
                int lower_ind = vandal_x < this.x ? vandal_x : this.x;
                int higher_ind = vandal_x < this.x ? this.x : vandal_x;
                for (int i = lower_ind + 1; i < higher_ind; i++)
                {
                    if (map.getObject(i, this.y).GetType() != typeof(NonDestroyableObjects.Puste))
                    {
                        x_move = 0;
                        break;
                    }
                 //   else x_move = lower_ind == this.x ? 1 : -1;
                }

            }
            return new Point(x_move, y_move);
        }
开发者ID:kuzawskak,项目名称:DungeonVandal,代码行数:43,代码来源:GigantycznySzczur.cs

示例2: Zabij

 public void Zabij(Map.Map map)
 {
     if (!map.GetVandal().is_immortal)
         map.vandal.is_alive = false;
 }
开发者ID:kuzawskak,项目名称:DungeonVandal-new,代码行数:5,代码来源:NiestabilnaBeczka.cs

示例3: Update

        /// <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)
                {
                    //explosion
                     SoundEffect explosion_sound = content.Load<SoundEffect>("Audio\\explosion_sound");
                     explosion_sound.Play();
                     int vandal_x = map.GetVandal().x;
                     int vandal_y = map.GetVandal().y;
                    //TODO: dodac sprawdzanie czy nie wykraczamy indeksow w mapie i czy obiekt nie jest niezniszczalny
                    //tak naprawde powinno sie to zmienic na wywolanie onDestroy dla kazdego z tych obiektow!!!!!!!!!!
                    if(x-1!=vandal_x&&y!=vandal_y&&map.getObject(x-1,y) is Zniszczalny)
                    map.setObject(x - 1, y, new NonDestroyableObjects.Puste(content, new Rectangle((x - 1) * rectangle.Width, y * rectangle.Height, rectangle.Width, rectangle.Height), x - 1, y));
                    if (x - 1 != vandal_x && y+1 != vandal_y && map.getObject(x - 1, y+1) is Zniszczalny)
                    map.setObject(x - 1, y + 1, new NonDestroyableObjects.Puste(content, new Rectangle((x - 1) * rectangle.Width, (y + 1) * rectangle.Height, rectangle.Width, rectangle.Height), x - 1, y + 1));
                    if (x - 1 != vandal_x && y-1 != vandal_y && map.getObject(x - 1, y-1) is Zniszczalny)
                    map.setObject(x - 1, y - 1, new NonDestroyableObjects.Puste(content, new Rectangle((x - 1) * rectangle.Width, (y - 1) * rectangle.Height, rectangle.Width, rectangle.Height), x - 1, y - 1));

                    if (x  != vandal_x && y-1 != vandal_y && map.getObject(x , y-1) is Zniszczalny)
                    map.setObject(x, y - 1, new NonDestroyableObjects.Puste(content, new Rectangle((x) * rectangle.Width, (y - 1) * rectangle.Height, rectangle.Width, rectangle.Height), x, y - 1));
                    if (x  != vandal_x && y+1 != vandal_y && map.getObject(x , y+1) is Zniszczalny)
                    map.setObject(x, y + 1, new NonDestroyableObjects.Puste(content, new Rectangle((x) * rectangle.Width, (y + 1) * rectangle.Height, rectangle.Width, rectangle.Height), x, y + 1));
                    if (x  != vandal_x && y != vandal_y && map.getObject(x , y) is Zniszczalny)
                    map.setObject(x, y, new NonDestroyableObjects.Puste(content, new Rectangle((x) * rectangle.Width, y * rectangle.Height, rectangle.Width, rectangle.Height), x, y));

                    if (x + 1 != vandal_x && y != vandal_y && map.getObject(x + 1, y) is Zniszczalny)
                    map.setObject(x + 1, y, new NonDestroyableObjects.Puste(content, new Rectangle((x + 1) * rectangle.Width, y * rectangle.Height, rectangle.Width, rectangle.Height), x + 1, y));
                    if (x + 1 != vandal_x && y+1 != vandal_y && map.getObject(x + 1, y+1) is Zniszczalny)
                    map.setObject(x + 1, y + 1, new NonDestroyableObjects.Puste(content, new Rectangle((x + 1) * rectangle.Width, (y + 1) * rectangle.Height, rectangle.Width, rectangle.Height), x + 1, y + 1));
                    if (x + 1 != vandal_x && y -1!= vandal_y && map.getObject(x + 1, y-1) is Zniszczalny)
                    map.setObject(x + 1, y - 1, new NonDestroyableObjects.Puste(content, new Rectangle((x + 1) * rectangle.Width, (y + 1) * rectangle.Height, rectangle.Width, rectangle.Height), x + 1, y - 1));

                   // if (x != vandal_x && y  != vandal_y && map.getObject(x , y ) is Zniszczalny)
                    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;

                }
            }
        }
开发者ID:kuzawskak,项目名称:DungeonVandal,代码行数:79,代码来源:Racket.cs

示例4: ZniszczBohatera

 /// <summary>
 /// Impelemntacja interfejsu eteryczny, zabicie bohatera
 /// </summary>
 public void ZniszczBohatera(Map.Map map)
 {
     if(!map.GetVandal().is_immortal)
     map.vandal.is_alive = false;
 }
开发者ID:kuzawskak,项目名称:DungeonVandal-new,代码行数:8,代码来源:MagicznyMur.cs

示例5: Update

        /// <summary>
        /// aktualizacja stanu Vandala
        /// </summary>
        /// <param name="gametime">czas gry</param>
        /// <param name="map">mapa obiektow</param>
        public override void Update(GameTime gametime, Map.Map map)
        {
            if (!is_immortal)
            {
                //sprawdzenie czy styka sie z wrogiem
                if (!map.GetVandal().is_immortal &&
                    map.getObject(x, y).GetType() == typeof(Characters.Enemy) || map.getObject(x, y) is Skazony)
                { is_alive = false; return; }

            }

            LoadCurrentTexture(map);
            if(gametime.TotalGameTime.Milliseconds%20==0)
            switch (current_direction)
            {
                case Game.direction.down:
                    MoveInDirection(0, 1, map);
                    current_direction = Game.direction.none;
                    break;
                case Game.direction.left:
                    if (rectangle.X > 0)
                        MoveInDirection(-1, 0, map);
                    current_direction = Game.direction.none;
                    break;
                case Game.direction.right:
                    MoveInDirection(1, 0, map);
                    current_direction = Game.direction.none;
                    break;
                case Game.direction.up:
                    if (rectangle.Y > 0)
                        MoveInDirection(0, -1, map);
                    current_direction = Game.direction.none;
                    break;
                default:
                    MoveInDirection(0, 0, map);
                    current_direction = Game.direction.none;
                    break;

            }
        }
开发者ID:kuzawskak,项目名称:DungeonVandal-new,代码行数:45,代码来源:Vandal.cs

示例6: MoveInDirection

        /// <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;
            }
        }
开发者ID:kuzawskak,项目名称:DungeonVandal-new,代码行数:40,代码来源:Vandal.cs

示例7: Update

        /// <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);
//.........这里部分代码省略.........
开发者ID:kuzawskak,项目名称:DungeonVandal-new,代码行数:101,代码来源:Racket.cs

示例8: Move

        /// <summary>
        /// Poruszanie - ustalenie aktualnego kierunku ruchu
        /// </summary>
        /// <param name="map">mapa obiektów</param>
        public void Move(Map.Map map)
        {
            Point p = isVandalInSight(map);
            if ((p.X != 0 && p.Y == 0) || (p.X == 0 && p.Y != 0))
            {
                //gonitwa
                move_frequency = 40;
                if ((this.x - map.GetVandal().x) < 0)
                {
                    current_direction=Game.direction.right;
                }
                else if ((this.x - map.GetVandal().x) > 0)
                {

                    current_direction = Game.direction.left;
                }
                else if ((this.y - map.GetVandal().y) > 0)
                {

                    current_direction = Game.direction.up;
                }
                else if ((this.y - map.GetVandal().y) < 0)
                {

                    current_direction = Game.direction.down;
                }

               }
            else//ruch losowy
            {
                move_frequency = 80;
                List<Game.direction> available_dir = new List<Game.direction>();
                if (x > 1 && (map.getObject(x - 1, y).GetType() == typeof(NonDestroyableObjects.Puste) || map.getObject(x - 1, y).GetType() == typeof(DestroyableObjects.Ziemia)))
                    available_dir.Add(Game.direction.left);
                if (x < map.getWidth() - 1 && (map.getObject(x + 1, y).GetType() == typeof(NonDestroyableObjects.Puste) || map.getObject(x + 1, y).TypeTag == Map.ElementType.ZIEMIA))
                    available_dir.Add(Game.direction.right);
                if (y > 1 && (map.getObject(x, y - 1).GetType() == typeof(NonDestroyableObjects.Puste) || map.getObject(x, y - 1).GetType() == typeof(DestroyableObjects.Ziemia)))
                    available_dir.Add(Game.direction.up);
                if (x < map.getHeight() - 1 && (map.getObject(x, y + 1).GetType() == typeof(NonDestroyableObjects.Puste) || map.getObject(x, y + 1).GetType() == typeof(DestroyableObjects.Ziemia)))
                    available_dir.Add(Game.direction.down);
                if (available_dir.Capacity > 0)
                {

                    int rand_dir = rand.Next(0, available_dir.Capacity - 1);
                    current_direction = (Game.direction)(rand_dir);

                }
                else
                {

                    current_direction = Game.direction.none;
                }
            }
        }
开发者ID:kuzawskak,项目名称:DungeonVandal-new,代码行数:58,代码来源:GigantycznySzczur.cs


注:本文中的Map.GetVandal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。