예제 #1
0
        internal World(ModData modData, Map map, OrderManager orderManager, WorldType type)
        {
            Type           = type;
            OrderManager   = orderManager;
            orderGenerator = new UnitOrderGenerator();
            Map            = map;
            Timestep       = orderManager.LobbyInfo.GlobalSettings.Timestep;
            SharedRandom   = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);
            LocalRandom    = new MersenneTwister();

            ModelCache = modData.ModelSequenceLoader.CacheModels(map, modData, map.Rules.ModelSequences);

            var worldActorType = type == WorldType.Editor ? "EditorWorld" : "World";

            WorldActor = CreateActor(worldActorType, new TypeDictionary());
            ActorMap   = WorldActor.Trait <IActorMap>();
            ScreenMap  = WorldActor.Trait <ScreenMap>();
            Selection  = WorldActor.Trait <ISelection>();

            // Reset mask
            LongBitSet <PlayerBitMask> .Reset();

            // Add players
            foreach (var cmp in WorldActor.TraitsImplementing <ICreatePlayers>())
            {
                cmp.CreatePlayers(this);
            }

            // Set defaults for any unset stances
            foreach (var p in Players)
            {
                if (!p.Spectating)
                {
                    AllPlayersMask = AllPlayersMask.Union(p.PlayerMask);
                }

                foreach (var q in Players)
                {
                    SetUpPlayerMask(p, q);

                    if (!p.Stances.ContainsKey(q))
                    {
                        p.Stances[q] = Stance.Neutral;
                    }
                }
            }

            Game.Sound.SoundVolumeModifier = 1.0f;

            gameInfo = new GameInformation
            {
                Mod     = Game.ModData.Manifest.Id,
                Version = Game.ModData.Manifest.Metadata.Version,

                MapUid   = Map.Uid,
                MapTitle = Map.Title
            };

            RulesContainTemporaryBlocker = map.Rules.Actors.Any(a => a.Value.HasTraitInfo <ITemporaryBlockerInfo>());
        }
예제 #2
0
        internal World(Manifest manifest, Map map, OrderManager orderManager, bool isShellmap)
        {
            IsShellmap        = isShellmap;
            this.orderManager = orderManager;
            orderGenerator_   = new UnitOrderGenerator();
            Map = map;

            TileSet      = Rules.TileSets[Map.Tileset];
            SharedRandom = new XRandom(orderManager.LobbyInfo.GlobalSettings.RandomSeed);

            WorldActor = CreateActor("World", new TypeDictionary());
            ActorMap   = WorldActor.Trait <ActorMap>();
            ScreenMap  = WorldActor.Trait <ScreenMap>();

            // Add players
            foreach (var cmp in WorldActor.TraitsImplementing <ICreatePlayers>())
            {
                cmp.CreatePlayers(this);
            }

            // Set defaults for any unset stances
            foreach (var p in Players)
            {
                foreach (var q in Players)
                {
                    if (!p.Stances.ContainsKey(q))
                    {
                        p.Stances[q] = Stance.Neutral;
                    }
                }
            }

            Sound.SoundVolumeModifier = 1.0f;
        }
예제 #3
0
        public void PixelsToBitmap()
        {
            unsafe
            {
                BitmapData bitmapData     = ScreenMap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                int        bytesPerPixel  = System.Drawing.Bitmap.GetPixelFormatSize(bitmapData.PixelFormat) / 8; // 4
                int        heightInPixels = bitmapData.Height;
                int        widthInBytes   = bitmapData.Width * bytesPerPixel;
                byte *     PtrFirstPixel  = (byte *)bitmapData.Scan0;


                //Parallel.For(0, heightInPixels, y =>
                for (int y = 0; y < heightInPixels; y++)
                {
                    byte *currentLine = PtrFirstPixel + (y * bitmapData.Stride);
                    for (int x = 0; x < widthInBytes; x = x + bytesPerPixel)
                    {
                        currentLine[x]     = Pixels[(x) + y * widthInBytes];
                        currentLine[x + 1] = Pixels[(x + 1) + y * widthInBytes];
                        currentLine[x + 2] = Pixels[(x + 2) + y * widthInBytes];
                        currentLine[x + 3] = Pixels[(x + 3) + y * widthInBytes];
                    }
                }
                ScreenMap.UnlockBits(bitmapData);
            }
        }
예제 #4
0
        internal World(ModData modData, Map map, OrderManager orderManager, WorldT type)
        {
            Type           = type;
            OrderManager   = orderManager;
            orderGenerator = new UnitOrderGenerator();
            Map            = map;
            Timestep       = orderManager.LobbyInfo.GlobalSettings.Timestep;
            SharedRandom   = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);

            ModelCache = modData.ModelSequenceLoader.CachModels(map, modData, map.Rules.ModelSequences);

            var worldActorT = type == WorldT.Editor ? "EditorWorld" : "World";

            WorldActor = CreateActor(worldActorT, new TypeDictionary());
            ActorMap   = WorldActor.Trait <IActorMap>();
            ScreenMap  = WorldActor.Trait <ScreenMap>();

            //Add players
            foreach (var cmp in WorldActor.TraitsImplementing <ICreatePlayers>())
            {
                cmp.CreatePlayers(this);
            }

            //Set defaults for any unset stances
            foreach (var p in Players)
            {
                foreach (var q in Players)
                {
                    if (!p.Stances.ContainsKey(q))
                    {
                        p.Stances[q] = Stance.Neutral;
                    }
                }
            }
        }
예제 #5
0
파일: World.cs 프로젝트: zhangolove/OpenRA
        internal World(Map map, OrderManager orderManager, WorldType type)
        {
            Type           = type;
            OrderManager   = orderManager;
            orderGenerator = new UnitOrderGenerator();
            Map            = map;
            Timestep       = orderManager.LobbyInfo.GlobalSettings.Timestep;

            TileSet      = map.Rules.TileSets[Map.Tileset];
            SharedRandom = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);

            var worldActorType = type == WorldType.Editor ? "EditorWorld" : "World";

            WorldActor = CreateActor(worldActorType, new TypeDictionary());
            ActorMap   = WorldActor.Trait <ActorMap>();
            ScreenMap  = WorldActor.Trait <ScreenMap>();

            // Add players
            foreach (var cmp in WorldActor.TraitsImplementing <ICreatePlayers>())
            {
                cmp.CreatePlayers(this);
            }

            // Set defaults for any unset stances
            foreach (var p in Players)
            {
                foreach (var q in Players)
                {
                    if (!p.Stances.ContainsKey(q))
                    {
                        p.Stances[q] = Stance.Neutral;
                    }
                }
            }

            Game.Sound.SoundVolumeModifier = 1.0f;

            gameInfo = new GameInformation
            {
                Mod     = Game.ModData.Manifest.Mod.Id,
                Version = Game.ModData.Manifest.Mod.Version,

                MapUid   = Map.Uid,
                MapTitle = Map.Title
            };

            if (!LobbyInfo.GlobalSettings.Shroud)
            {
                foreach (var player in Players)
                {
                    player.Shroud.ExploreAll(this);
                }
            }
        }
예제 #6
0
파일: Ui.cs 프로젝트: Playspal/TextQuest
    public static void ShowScreenPopulation()
    {
        ScreenPopulation.Show();
        PanelFooter.Show();

        //ScreenCards.Hide();
        ScreenTown.Hide();
        ScreenMap.Hide();

        Quest.Instance.SetPause(true);
        //ControllerRain.Instance.gameObject.SetActive(false);
    }
예제 #7
0
        internal World(ModData modData, Map map, OrderManager orderManager, WorldType type)
        {
            Type           = type;
            OrderManager   = orderManager;
            orderGenerator = new UnitOrderGenerator();
            Map            = map;
            Timestep       = orderManager.LobbyInfo.GlobalSettings.Timestep;
            SharedRandom   = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);
            LocalRandom    = new MersenneTwister();

            ModelCache = modData.ModelSequenceLoader.CacheModels(map, modData, map.Rules.ModelSequences);

            var worldActorType = type == WorldType.Editor ? "EditorWorld" : "World";

            WorldActor      = CreateActor(worldActorType, new TypeDictionary());
            ActorMap        = WorldActor.Trait <IActorMap>();
            ScreenMap       = WorldActor.Trait <ScreenMap>();
            Selection       = WorldActor.Trait <ISelection>();
            OrderValidators = WorldActor.TraitsImplementing <IValidateOrder>().ToArray();

            LongBitSet <PlayerBitMask> .Reset();

            // Create an isolated RNG to simplify synchronization between client and server player faction/spawn assignments
            var playerRandom = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);

            foreach (var cmp in WorldActor.TraitsImplementing <ICreatePlayers>())
            {
                cmp.CreatePlayers(this, playerRandom);
            }

            Game.Sound.SoundVolumeModifier = 1.0f;

            gameInfo = new GameInformation
            {
                Mod     = Game.ModData.Manifest.Id,
                Version = Game.ModData.Manifest.Metadata.Version,

                MapUid   = Map.Uid,
                MapTitle = Map.Title
            };

            RulesContainTemporaryBlocker = map.Rules.Actors.Any(a => a.Value.HasTraitInfo <ITemporaryBlockerInfo>());
            gameSettings = Game.Settings.Game;
        }
예제 #8
0
        async Task GetGeoLocatio()
        {
            try
            {
                var request  = new GeolocationRequest(GeolocationAccuracy.Medium);
                var location = await Geolocation.GetLocationAsync(request);

                //Position position = new Position(location.Latitude, location.Longitude);
                Position position = new Position(56.796975, 53.230891);
                MapSpan  mapSpan  = new MapSpan(position, 0.01, 0.01);
                ScreenMap.MoveToRegion(mapSpan);
                List <Pin> pins = new List <Pin>();
                pins.Add(new Pin
                {
                    Position = new Position(56.796975, 53.230891),
                    Label    = "   "
                });
                //pins.Add(new Pin
                //{
                //    Position = new Position(56.8429, 53.2867),
                //    Label = "АЗС"
                //});
                //pins.Add(new Pin
                //{
                //    Position = new Position(56.8347, 53.1203),
                //    Label = "АЗС"
                //});
                //pins.Add(new Pin
                //{
                //    Position = new Position(56.8347, 53.1203),
                //    Label = "АЗС"
                //});
                //pins.Add(new Pin
                //{
                //    Position = new Position(56.8349113, 53.1116808),
                //    Label = "АЗС"
                //});
                //pins.Add(new Pin
                //{
                //    Position = new Position(56.822781, 53.1270012),
                //    Label = "АЗС"
                //});
                //pins.Add(new Pin
                //{
                //    Position = new Position(56.8293204, 53.127043),
                //    Label = "АЗС"
                //});
                //pins.Add(new Pin
                //{
                //    Position = new Position(56.8288236, 53.1286666),
                //    Label = "АЗС"
                //});
                //pins.Add(new Pin
                //{
                //    Position = new Position(56.8255776, 53.1178199),
                //    Label = "АЗС"
                //});
                //pins.Add(new Pin
                //{
                //    Position = new Position(56.8251125, 53.1263353),
                //    Label = "АЗС"
                //});
                //pins.Add(new Pin
                //{
                //    Position = new Position(56.829349, 53.1298458),
                //    Label = "АЗС"
                //});
                //pins.Add(new Pin
                //{
                //    Position = new Position(56.8279394, 53.1044006),
                //    Label = "АЗС"
                //});
                //pins.Add(new Pin
                //{
                //    Position = position,
                //    Label = "I am here"
                //});
                foreach (var p in pins)
                {
                    ScreenMap.Pins.Add(p);
                }

                ScreenMap.IsShowingUser = true;
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
            }
            catch (Exception ex)
            {
                // Unable to get location
            }
        }
예제 #9
0
    private static void InitWeights()
    {
        // get the tiles
        var penrose = Controller.Instance.penrose;
        var tiles   = penrose.Tiles;
        var bounds  = penrose.Bounds;
        var min     = bounds.min;
        var max     = bounds.max;

        var xSpacing = (max.x - min.x) / width;
        var ySpacing = (max.y - min.y) / height;

        // loop through all the tiles
        for (var i = 0; i < Penrose.Total; i++)
        {
            // create closeNeighbors array
            var closeNeighbors = new ScreenMap[count];
            for (var j = 0; j < count; j++)
            {
                closeNeighbors[j] = new ScreenMap();
            }

            // reset index and x position
            var index = 0;
            var xPos  = min.x;
            for (var x = 0; x < width; x++)
            {
                // reset y position
                var yPos = min.y;
                for (var y = 0; y < height; y++)
                {
                    var screenPos = new Vector2(xPos, yPos);
                    var distance  = Vector2.Distance(screenPos, tiles[i].center);

                    if (distance < closeNeighbors[index].distance)
                    {
                        closeNeighbors[index].position.x = x;
                        closeNeighbors[index].position.y = y;
                        closeNeighbors[index].distance   = distance;
                        Array.Sort(closeNeighbors, (a, b) => a.distance.CompareTo(b.distance));
                    }

                    // increase index if we need too
                    if (index < count - 1)
                    {
                        index++;
                    }

                    // move y forward
                    yPos += ySpacing;
                }

                // move x forward
                xPos += xSpacing;
            }

            // closest have been found
            // get the total of all distances and
            // add the closeNeighbors to the neighbors array
            // ignoring the last closeNeighbor as that was used for sorting
            var totalDistance = 0f;
            for (var j = 0; j < count; j++)
            {
                totalDistance  += closeNeighbors[j].distance;
                neighbors[i][j] = closeNeighbors[j];
            }

            // set the weight for the color value based on distance
            for (var j = 0; j < count; j++)
            {
                neighbors[i][j].weight = closeNeighbors[j].distance / totalDistance;
            }
        }
    }