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


C# Map.GetSize方法代码示例

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


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

示例1: Launch

    public void Launch(Map map)
    {
        // Implementierung der Abschusssequenz

        for (int i = 0; i < Map.allowedShots; i++)
        {
            int randX = RandomNumber(i, 0, map.GetSize());
            int randY = RandomNumber(i*2, 0, map.GetSize());
            map.fireShot(randX, randY);
        }
    }
开发者ID:Dahie,项目名称:September-1983,代码行数:11,代码来源:FireSequenceBeta.cs

示例2: Launch

    public void Launch(Map map)
    {
        // Implementierung der Abschusssequenz

        int randX = RandomNumber(1, 1, map.GetSize()-1);
        int randY = RandomNumber(1*2, 1, map.GetSize()-1);

        for (int i = 0; i < Map.allowedShots; i++)
        {
            map.fireShot(randX, randY);
            map.fireShot(randX-1, randY);
            map.fireShot(randX, randY-1);
            map.fireShot(randX, randY+1);
            map.fireShot(randX+1, randY);
        }
    }
开发者ID:Dahie,项目名称:September-1983,代码行数:16,代码来源:FireSequenceGamma.cs

示例3: PhysicsUnit

        public PhysicsUnit(Item item, Dictionary<int, PhysicsUnit> items)
        {
            this.item = item;
            this.items = items;
            moving = item.GetProperty<WalkingProperty>();
            collidable = item.GetProperty<CollidableProperty>();
            carrier = item.GetProperty<CarrierProperty>();
            portable = item.GetProperty<PortableProperty>();

            map = item.Engine.Map;

            mapSize = map.GetSize();

            // Attach Item Stuff
            item.CellChanged += item_CellChanged;

            // Attach Moving Stuff
            if (moving != null)
            {
                moving.OnMaximumMoveSpeedChanged += moving_OnMaximumMoveSpeedChanged;
                moving.OnMoveDirectionChanged += moving_OnMoveDirectionChanged;
                moving.OnMoveSpeedChanged += moving_OnMoveSpeedChanged;
                moving.MoveMalus = 1;
            }

            // Attach Collision Stuff
            if (collidable != null)
            {
                collidable.OnCollisionMassChanged += collidable_OnCollisionMassChanged;
                collidable.OnCollisionFixedChanged += collidable_OnCollisionFixedChanged;
            }

            // Attach Carrier Stuff
            if (carrier != null)
            {
                carrier.OnCarrierLoadChanged += carrier_OnCarrierLoadChanged;
                carrier.OnCarrierStrengthChanged += carrier_OnCarrierStrengthChanged;
            }

            // Attach Portable Stuff
            if (portable != null)
            {
                portable.OnPortableWeightChanged += portable_OnPortableMassChanged;
                portable.OnNewCarrierItem += portable_OnNewCarrierItem;
                portable.OnLostCarrierItem += portable_OnLostCarrierItem;
                clusterUnits = new HashSet<PhysicsUnit>();
            }

            Recalc();
        }
开发者ID:FrankFlamme,项目名称:AntMeCore,代码行数:50,代码来源:PhysicsUnit.cs

示例4: GenerateMap

        private void GenerateMap(Map map)
        {
            var mapSize = map.GetSize();
            int width = (int)mapSize.Width - 1;
            int height = (int)mapSize.Height - 1;

            int count = (int)(width*height*0.35);

            var mapWithRiver = GenerateRiver(map);

            for (int i = 0; i < mapWithRiver.GetLength(0); i++)
            {
                for (int j = 0; j < mapWithRiver.GetLength(1); j++)
                {
                    if (mapWithRiver[i, j] > 0)
                        map.SetObjectFromCell(new Point(i, j), new FixedObject(new Size(1, 1), (uint)(mapWithRiver[i, j] > 1 ? 0x00002000 : 0x00002100)));
                }
            }

            int tmpX, tmpY;
            Random rand = new Random();

            while( count > 0 )
            {
                tmpX = rand.Next(width);
                tmpY = rand.Next(height);

                if( map.GetObjectFromCell(new Point(tmpX, tmpY)) != null )
                    continue;

                switch (count % 11)
                {
                    case 0:
                    case 1:
                        map.SetObjectFromCell(new Point(tmpX, tmpY), new AppleTree());
                        break;
                    case 2:
                    case 3:
                        map.SetObjectFromCell(new Point(tmpX, tmpY), new Plant());
                        break;
                    case 4:
                    case 5:
                        map.SetObjectFromCell(new Point(tmpX, tmpY), new Rock());
                        break;
                    case 6:
                    case 7:
                        map.SetObjectFromCell(new Point(tmpX, tmpY), new Bush());
                        break;
                    case 8:
                    case 9:
                        map.SetObjectFromCell(new Point(tmpX, tmpY), new SpruceTree());
                        break;
                    case 10:
                        map.SetObjectFromCell(new Point(tmpX, tmpY), new Mushroom());
                        break;
                }

                count--;
            }

            while (true)
            {
                tmpX = rand.Next(width);
                tmpY = rand.Next(height);

                if (map.GetObjectFromCell(new Point(tmpX, tmpY)) != null)
                    continue;

                map.AddMobileObject(new Dikabryozik(new Point(tmpX, tmpY)));
                break;
            }
        }
开发者ID:norniel,项目名称:Game,代码行数:72,代码来源:LoadSaveManager.cs

示例5: GenerateRiver

        private int[,] GenerateRiver(Map map)
        {
            var mapSize = map.GetSize();
            int width = (int)mapSize.Width - 1;
            int height = (int)mapSize.Height - 1;
            var mapTmp = new int[mapSize.Width, mapSize.Height];
            int river_length = 40;
            int deep = 2;
            var pointList = new List<Point>();

            int tmpX, tmpY;
            Random rand = new Random();
            tmpX = rand.Next(width);
            tmpY = rand.Next(height);
            tmpX = tmpX <= 1 ? tmpX + 10 : tmpX >= width - 1 ? tmpX - 10 : tmpX;
            tmpY = tmpY <= 1 ? tmpY + 10 : tmpY >= height - 1 ? tmpY - 10 : tmpY;
            mapTmp[tmpX, tmpY] = deep;
            pointList.Add(new Point(tmpX, tmpY));

            var posibility = rand.Next(4);
            tmpX = posibility == 0 ? tmpX - 1 : posibility == 1 ? tmpX + 1 : tmpX;
            tmpY = posibility == 2 ? tmpY - 1 : posibility == 3 ? tmpY + 1 : tmpY;
            mapTmp[tmpX, tmpY] = deep;
            pointList.Add(new Point(tmpX, tmpY));

            while (pointList.Count < river_length)
            {
                var currentListLength = pointList.Count;
                var curPoint = pointList.First();
                var firstPoint = AddDeepPointToRiver(curPoint, width, height, mapTmp, deep, rand);

                if(!object.ReferenceEquals(firstPoint, null))
                    pointList.Insert(0, firstPoint);

                curPoint = pointList.Last();
                var lastPoint = AddDeepPointToRiver(curPoint, width, height, mapTmp, deep, rand);

                if (!object.ReferenceEquals(lastPoint, null))
                    pointList.Add(lastPoint);

                if(currentListLength == pointList.Count)
                    break;
            }

            while (pointList.Count > 0)
            {
                var curPoint = pointList.First();
                pointList.RemoveAt(0);

                var curDeepness = mapTmp[curPoint.X, curPoint.Y];

                if(curDeepness <= 0)
                    continue;

                for (int i = curPoint.X - 1; i <= curPoint.X + 1; i++)
                {
                    for (int j = curPoint.Y - 1; j <= curPoint.Y + 1; j++)
                    {
                        if ((i == curPoint.X && j == curPoint.Y) || i < 0 || i > width || j < 0 || j > height
                            || mapTmp[i, j] > 0)
                            continue;

                        var posibilityForDeepness = rand.Next(9);

                        var nextDeepness = posibilityForDeepness < 8 ? curDeepness - 1 : curDeepness;

                        if(nextDeepness <= 0)
                            continue;

                        mapTmp[i, j] = nextDeepness;
                        pointList.Add(new Point(i, j));
                    }
                }
            }
            return mapTmp;
        }
开发者ID:norniel,项目名称:Game,代码行数:76,代码来源:LoadSaveManager.cs


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