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


C# Map.getHeight方法代码示例

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


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

示例1: Update

        public override void Update(GameTime gametime, Map.Map map)
        {
            if (create_ameba)
            {
                available_tiles = new List<Map.MapObject>();

                if (x > 0 && y > 0 && map.getObject(x - 1, y - 1) is Features.Slaby)
                    available_tiles.Add(map.getObject(x - 1, y - 1));
                if (x > 0 && map.getObject(x - 1, y) is Features.Slaby)
                    available_tiles.Add(map.getObject(x - 1, y));
                if (x > 0 && y < map.getHeight() - 1 && map.getObject(x - 1, y + 1) is Features.Slaby)
                    available_tiles.Add(map.getObject(x - 1, y + 1));
                if (y > 0 && map.getObject(x, y - 1) is Features.Slaby)
                    available_tiles.Add(map.getObject(x, y - 1));
                if (y < map.getHeight() - 1 && map.getObject(x, y + 1) is Features.Slaby)
                    available_tiles.Add(map.getObject(x, y + 1));
                if (x < map.getWidth() - 1 && y > 0 && map.getObject(x + 1, y - 1) is Features.Slaby)
                    available_tiles.Add(map.getObject(x + 1, y - 1));
                if (x<map.getWidth()-1&&map.getObject(x + 1, y) is Features.Slaby)
                    available_tiles.Add(map.getObject(x + 1, y));
                if (x<map.getWidth()-1&&y<map.getHeight()-1&&map.getObject(x + 1, y + 1) is Features.Slaby)
                    available_tiles.Add(map.getObject(x + 1, y + 1));
                CreateNewAmeba(map);
                create_ameba = false;
            }
        }
开发者ID:kuzawskak,项目名称:DungeonVandal,代码行数:26,代码来源:Ameba.cs

示例2: Move

 /// <summary>
 /// Poruszanie - ustalenie aktualnego kierunku ruchu
 /// </summary>
 /// <param name="map">Mapa obiektów</param>
 public void Move(Map.Map map)
 {
     List<Game.direction> available_dir = new List<Game.direction>();
     if (x > 1 && map.getObject(x - 1, y).GetType() == typeof(NonDestroyableObjects.Puste))
         available_dir.Add(Game.direction.left);
     if (x < map.getWidth() - 1 && map.getObject(x + 1, y).GetType() == typeof(NonDestroyableObjects.Puste))
         available_dir.Add(Game.direction.right);
     if (y > 1 && map.getObject(x, y - 1).GetType() == typeof(NonDestroyableObjects.Puste))
         available_dir.Add(Game.direction.up);
     if (x < map.getHeight() - 1 && map.getObject(x, y + 1).GetType() == typeof(NonDestroyableObjects.Puste))
         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,代码行数:22,代码来源:Blob.cs

示例3: Update

        /// <summary>
        /// Aktualizacja stanu (uzalezniona od stanu sasiadujacych komórek na mapie)
        /// </summary>
        /// <param name="gametime"></param>
        /// <param name="map"></param>
        public override void Update(GameTime gametime,Map.Map map)
        {
            int x_index = rectangle.X / rectangle.Width;
             int y_index = rectangle.Y / rectangle.Height;
             if (y_index == map.getHeight() - 1)
             {
                 if (is_falling)
                 {
                     MessageBox.Show(x_index.ToString() + "  " + y_index.ToString());
                     map.setObject(x_index, y_index, this);
                     map.setObject(x_index, y_index - 1, new NonDestroyableObjects.Puste(content, rectangle, x_index, y_index - 1));
                     is_falling = false;
                     return;
                 }
                 else
                     return;
             }
             if (is_falling)
             {

                 //nie spadl calkowice jeszcze na odpowiedni prosokat
                 if (rectangle.Y % rectangle.Height != 0)
                 {
                     Spadaj();
                 }
                 else
                 {
                     map.setObject(x_index, y_index, this);
                     map.setObject(x_index, y_index - 1, new NonDestroyableObjects.Puste(content, rectangle, x_index, y_index - 1));
                     if (y_index < map.getHeight() - 1 && map.getObject(x_index, y_index + 1).GetType() == typeof(NonDestroyableObjects.Puste))
                     {
                         Spadaj();
                     }
                     else is_falling = false;
                 }
             }
             else if (map.getObject(x_index, y_index + 1).GetType() == typeof(NonDestroyableObjects.Puste)&& !map.is_vandal_on_rectangle(x_index, y_index + 1))
             {//rozpoczecie spadania
                 is_falling = true;
                 Spadaj();
             }
        }
开发者ID:kuzawskak,项目名称:DungeonVandal,代码行数:47,代码来源:MarmurowyKamien.cs

示例4: isPointAccesible

        /// <summary>
        /// Sprawdzenie czy punkt jest dostepny ze wzgledu na poruszanie w danym kierunku
        /// </summary>
        /// <param name="map">Mapa obiektów</param>
        /// <param name="dir">Kierunek ruchu</param>
        /// <returns>Czy jest możliwość ruchu w danym kierunku</returns>
        private bool isPointAccesible(Map.Map map, int dir)
        {
            switch ((Game.direction)dir)
            {
                case Game.direction.down:
                    if (y + 1 < map.getHeight() - 1)
                    {
                        if (map.getObject(x, y + 1).GetType() == typeof(NonDestroyableObjects.Puste))
                            return true;
                    } break;

                case Game.direction.left:
                    if (x > 0)
                    {
                        if (map.getObject(x - 1, y).GetType() == typeof(NonDestroyableObjects.Puste))
                            return true;
                    }

                    break;
                case Game.direction.right:
                    if (x + 1 < map.getWidth() - 1)
                    {
                        if (map.getObject(x + 1, y).GetType() == typeof(NonDestroyableObjects.Puste))
                            return true;
                    }

                    break;
                case Game.direction.up:
                    if (y > 0)
                    {
                        if (map.getObject(x, y - 1).GetType() == typeof(NonDestroyableObjects.Puste))

                            return true;
                    } break;

            }
            return false;
        }
开发者ID:kuzawskak,项目名称:DungeonVandal-new,代码行数:44,代码来源:Goblin.cs

示例5: Update

        /// <summary>
        /// Aktualizacja stanu na mapie z uwzględnieniem spadania
        /// </summary>
        /// <param name="gametime"></param>
        /// <param name="map"></param>
        public override void Update(GameTime gametime, Map.Map map)
        {
            if (explode)
            {
                if (current_frame == 16) { die = true; explode = false; }
                else
                    src_rectangle = new Rectangle((current_frame++) * 64, 0, 64, 64);
            }
            else if (die)
            {
                map.setObject(x, y, new NonDestroyableObjects.Puste(content, this.Rectangle, x, y));
            }
            else
            {
                int x_index = rectangle.X / rectangle.Width;
                int y_index = rectangle.Y / rectangle.Height;

                //sprawdzenie wszytkich dookola pol
                if (map.is_vandal_on_rectangle(x_index - 1, y_index) ||
                    map.is_vandal_on_rectangle(x_index + 1, y_index) ||
                    map.is_vandal_on_rectangle(x_index, y_index - 1) ||
                    map.is_vandal_on_rectangle(x_index, y_index + 1) ||
                    map.is_vandal_on_rectangle(x_index - 1, y_index - 1) ||
                    map.is_vandal_on_rectangle(x_index - 1, y_index + 1) ||
                    map.is_vandal_on_rectangle(x_index + 1, y_index + 1) ||
                    map.is_vandal_on_rectangle(x_index + 1, y_index - 1))
                {
                    Zabij(map);
                    return;
                }

                if (y_index == map.getHeight() - 1)
                {
                    if (is_falling)
                    {
                        map.setObject(x_index, y_index, this);
                        this.x = x_index;
                        this.y = y_index;
                        map.setObject(x_index, y_index - 1, new NonDestroyableObjects.Puste(content, rectangle, x_index, y_index - 1));
                        is_falling = false;
                        return;
                    }
                    else return;
                }
                if (is_falling)
                {
                    //nie spadl calkowice jeszcze na odpowiedni prosokat
                    if (rectangle.Y % rectangle.Height != 0)
                    {
                        Spadaj();
                    }
                    else
                    {
                        map.setObject(x_index, y_index, this);
                        this.x = x_index;
                        this.y = y_index;
                        map.setObject(x_index, y_index - 1, new NonDestroyableObjects.Puste(content, rectangle, x_index, y_index - 1));
                        if (y_index < map.getHeight() - 1 && map.getObject(x_index, y_index + 1).GetType() == typeof(NonDestroyableObjects.Puste))
                        {
                            Spadaj();
                        }
                        else is_falling = false;
                    }
                }
                else if (map.getObject(x_index, y_index + 1).GetType() == typeof(NonDestroyableObjects.Puste) && !map.is_vandal_on_rectangle(x_index, y_index + 1))
                {//rozpoczecie spadania
                    is_falling = true;
                    Spadaj();
                }
                else return;
            }
        }
开发者ID:kuzawskak,项目名称:DungeonVandal-new,代码行数:77,代码来源:NiestabilnaBeczka.cs

示例6: Update

        /// <summary>
        /// Aktualizacja stanu w zależności od otoczenia
        /// </summary>
        /// <param name="gametime"></param>
        /// <param name="map"></param>
        public override void Update(GameTime gametime, Map.Map map)
        {
            int x_index = rectangle.X / rectangle.Width;
            int y_index = rectangle.Y / rectangle.Height;

            //sprawdzenie wszytkich dookola pol
            if (map.is_vandal_on_rectangle(x_index - 1, y_index) ||
                map.is_vandal_on_rectangle(x_index + 1, y_index) ||
                map.is_vandal_on_rectangle(x_index, y_index - 1) ||
                map.is_vandal_on_rectangle(x_index, y_index + 1) ||
                map.is_vandal_on_rectangle(x_index - 1, y_index - 1) ||
                map.is_vandal_on_rectangle(x_index - 1, y_index + 1) ||
                map.is_vandal_on_rectangle(x_index + 1, y_index + 1) ||
                map.is_vandal_on_rectangle(x_index + 1, y_index - 1))
            {
                Zabij(map);
                return;
            }

            if (y_index == map.getHeight() - 1)
            {
                if (is_falling)
                {

                    map.setObject(x_index, y_index, this);
                    map.setObject(x_index, y_index - 1, new NonDestroyableObjects.Puste(content, rectangle, x_index, y_index - 1));
                    is_falling = false;
                    return;
                }
                else
                    return;
            }
            if (is_falling)
            {

                //nie spadl calkowice jeszcze na odpowiedni prosokat
                if (rectangle.Y % rectangle.Height != 0)
                {
                    Spadaj();
                }
                else
                {
                    map.setObject(x_index, y_index, this);
                    map.setObject(x_index, y_index - 1, new NonDestroyableObjects.Puste(content, rectangle,x_index, y_index - 1));
                    //pozniej zmienic na nondestroyable zamista puste
                    if (y_index < map.getHeight() - 1 && map.getObject(x_index, y_index + 1).GetType() == typeof(NonDestroyableObjects.Puste))
                    {
                        Spadaj();
                        // break;
                    }
                    else is_falling = false;
                }
            }
            else if (map.getObject(x_index, y_index + 1).GetType() == typeof(NonDestroyableObjects.Puste) && !map.is_vandal_on_rectangle(x_index, y_index + 1))
            {//rozpoczecie spadania
                is_falling = true;
                Spadaj();
            }
        }
开发者ID:kuzawskak,项目名称:DungeonVandal,代码行数:64,代码来源:RadioaktywnyGlaz.cs

示例7: isVandalInSight

        /*    public Point Move(Map.Map map)
        {
            Point is_in_sight = isVandalInSight(map);
            if (is_in_sight.X == 0 && is_in_sight.Y == 0)
            {//nie ma w zasiegu wzroku Vandala - moze poruszac sie losowo, bardzo wolno
                updateFrequency = 800;
                List<Point> available_points = new List<Point>();
                Map.MapObject collision_obj;
                collision_obj = map.getObject(this.x+1,this.y);
                if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste) || collision_obj.GetType() == typeof(DestroyableObjects.Ziemia))
                    available_points.Add(new Point(1, 0));
                collision_obj = map.getObject(this.x - 1, this.y);
                if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste) || collision_obj.GetType() == typeof(DestroyableObjects.Ziemia))
                    available_points.Add(new Point( - 1, 0));
                collision_obj = map.getObject(this.x , this.y+1);
                if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste) || collision_obj.GetType() == typeof(DestroyableObjects.Ziemia))
                    available_points.Add(new Point(0 , 1));
                collision_obj = map.getObject(this.x, this.y-1);
                if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste) || collision_obj.GetType() == typeof(DestroyableObjects.Ziemia))
                    available_points.Add(new Point(0, -1));

                if (available_points.Capacity != 0)
                {
                    return available_points[rand.Next(0, available_points.Capacity - 1)];
                }
            }
            else
            {
                //goni  - porusza sie szybciej
                updateFrequency = 800;
               return(new Point(0,0));

            }

            return is_in_sight;

        }*/
        public void Move(Map.Map map)
        {
            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 ==AIHelper.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
            {
                MessageBox.Show(map.getObject(x - 1, y).GetType().ToString());
                current_direction = Game.direction.none;
            }
        }
开发者ID:kuzawskak,项目名称:DungeonVandal,代码行数:61,代码来源:GigantycznySzczur.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.getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。