Beispiel #1
0
    //use this to load the map once it's prefap is made
    public void LoadMap()
    {
        var allMaps   = GameManager.Instance.GetComponent <Maps>().allMapsDict;
        int menuIndex = mapSelector.value;
        List <TMP_Dropdown.OptionData> menuOptions = mapSelector.options;

        mapName = menuOptions[menuIndex].text;

        if (allMaps.ContainsKey(mapName))
        {
            var map = Instantiate(allMaps[mapName].mapPrefab, transform.position, Quaternion.identity);
            map.transform.SetParent(mapCanvas.transform);


            //clear the active tiles and active towers list
            GameManager.Instance.activeTiles.Clear();
            GameManager.Instance.activeTowers.Clear();

            map.transform.position         = new Vector2(0f, 0f);
            loadTowerMenuBtn.interactable  = true;
            GameManager.Instance.inGame    = true;
            GameManager.Instance.activeMap = mapDetails;
            //THIS IS IMPORTANT. SET THE INSTANTIATED MAP AS THE NEW TARGET FOR THE WORLD MAP'S MAP OBJECT
            mapObject  = map;
            mapDetails = map.GetComponent <MapDetails>();
            map.GetComponentInChildren <MapDetails>().SummonMap();


            mapDetailsObject.GetComponent <MapInfoMenu>().mapDetails = map.GetComponent <MapDetails>();
            mapDetailsObject.SetActive(true);
            mapDetailsObject.GetComponent <MapInfoMenu>().LoadMap();
            worldMapObject.SetActive(false);
        }
    }
Beispiel #2
0
        /// <summary>
        /// Loads the data for a level using the Tiled Map Xml format.
        /// </summary>
        public static LevelData LoadTmx(string FilePath)
        {
            // https://github.com/bjorn/tiled/wiki/TMX-Map-Format contains a description of the format.
            XmlDocument Doc = new XmlDocument();

            Doc.Load(FilePath);
            if (Doc.GetElementsByTagName("map").Count != 1)
            {
                throw new FormatException("Expected a single map to be defined in a .tmx file.");
            }
            var MapElement = Doc.GetElementsByTagName("map").Item(0);
            var MapDetails = new MapDetails(MapElement);
            List <TextureDetails> Textures   = ParseTilesets(MapDetails);
            List <Layer>          Layers     = ParseLayers(MapDetails, Textures);
            List <Entity>         Entities   = ParseEntities(MapDetails);
            List <LevelProperty>  Properties = ParseProperties(MapDetails);

            LevelData Result = new LevelData()
            {
                DynamicObjects = Entities.ToArray(),
                Layers         = Layers.ToArray(),
                MapSize        = new Vector2(MapDetails.MapWidth, MapDetails.MapHeight),
                TileSize       = new Vector2(MapDetails.MapTileWidth, MapDetails.MapTileHeight),
                Properties     = Properties.ToArray()
            };

            return(Result);
        }
Beispiel #3
0
    //get the map details script from the World Map, and then set the MapDetails values of the WorldMap according to this map's variables
    public void LoadMap(MapDetails MapDetails)
    {
        mapDetails = MapDetails;

        mapDetails.mapName = mapName;
        //mapDetails.mapCode = allMaps[mapName].mapCode;
        mapDetails.enemyCount    = 0;
        mapDetails.enemyMax      = enemyMax;
        mapDetails.levelMin      = levelMin;
        mapDetails.levelMax      = levelMax;
        mapDetails.spawnInterval = maxHP;
        mapDetails.mapLevel      = mapLevel;
        mapDetails.mapWeather    = weather;

        mapDetails.mapName   = mapName;
        mapDetails.mapCanvas = gameObject;

        mapDetails.mapInformation.playerEnergy     = 10;
        mapDetails.mapInformation.playerEnergyMax  = 100;
        mapDetails.mapInformation.mapHealthMax     = maxHP;
        mapDetails.mapInformation.mapHealthCurrent = maxHP;

        mapTiles = mapDetails.allTiles;

        //make a path code for each possible path, and add them to a Dictionary of PathCodes
        for (int p = 0; p < pathCodes.Count; p++)
        {
            //break up each path code in to sections of 3, since each tile is a 3 digit number, and store them in a dictionary of path codes that an enemy will choose at random upon their spawn
            //string[] pathChars = new string[pathCode.Length];
            string[]       pathChars = new string[pathCodes[p].Length];
            string         code      = pathCodes[p];
            List <string>  pathCode  = new List <string>();
            List <MapTile> pathTiles = new List <MapTile>();


            int h = 2;
            for (int i = 0; i < code.Length / 3; i++)
            {
                pathChars[i] = code[h - 2].ToString() + code[h - 1].ToString() + code[h].ToString();
                h           += 3;
                int tileCheck = int.Parse(pathChars[i]);

                mapDetails.path[i] = GameObject.Find(tileCheck.ToString()).GetComponent <MapTile>();
                mapDetails.path[i].Road();
                pathTiles.Add(mapDetails.path[i]);
            }
        }

        //clear the active tiles and active towers list
        GameManager.Instance.activeTiles.Clear();
        GameManager.Instance.activeTowers.Clear();

        mapDetails.GetComponent <MonsterInfoMenus>().LoadYourTowers();
        mapDetails.weatherSystem.intensity = Random.Range(0, 3);
        mapDetails.weatherSystem.StartWeather(mapDetails);



        InvokeRepeating("SpawnEnemy", 2, spawnInterval);
    }
Beispiel #4
0
 public void Init(GameIDType gameID, PlayerIDType myPlayerID, Dictionary <PlayerIDType, GamePlayer> players, MapDetails map, GameStanding distributionStanding, GameSettings gameSettings, int numberOfTurns, Dictionary <PlayerIDType, PlayerIncome> incomes, GameOrder[] prevTurn, GameStanding latestTurnStanding, GameStanding previousTurnStanding, Dictionary <PlayerIDType, TeammateOrders> teammatesOrders, List <CardInstance> cards, int cardsMustPlay, Stopwatch timer, List <string> directives)
 {
     this.DistributionStandingOpt = distributionStanding;
     this.Standing          = latestTurnStanding;
     this.PlayerID          = myPlayerID;
     this.Players           = players;
     this.Map               = map;
     this.Settings          = gameSettings;
     this.TeammatesOrders   = teammatesOrders;
     this.Cards             = cards;
     this.CardsMustPlay     = cardsMustPlay;
     this.Incomes           = incomes;
     this.BaseIncome        = Incomes[PlayerID];
     this.EffectiveIncome   = BaseIncome.Clone();
     this.Neighbors         = players.Keys.ExceptOne(PlayerID).ConcatOne(TerritoryStanding.NeutralPlayerID).ToDictionary(o => o, o => new Neighbor(this, o));
     this.Opponents         = players.Values.Where(o => o.State == GamePlayerState.Playing && !IsTeammateOrUs(o.ID)).ToList();
     this.IsFFA             = Opponents.Count > 1 && (Opponents.Any(o => o.Team == PlayerInvite.NoTeam) || Opponents.GroupBy(o => o.Team).Count() > 1);
     this.WeightedNeighbors = WeightNeighbors();
     this.Timer             = timer;
     this.Directives        = directives;
     if (tracker.isInit())
     {
         tracker.update(this);
     }
     else
     {
         tracker.init(this);
     }
     AILog.Log("BotMain", "PyBot initialized.  Starting at " + timer.Elapsed.TotalSeconds + " seconds");
 }
Beispiel #5
0
    public void StartWeather(MapDetails map)
    {
        mapDetails = map;
        weather    = map.mapWeather;



        if (weather == MapWeather.Snow)
        {
            Snow();
        }

        if (weather == MapWeather.Rain)
        {
            Rain();
        }

        if (weather == MapWeather.Sunny)
        {
            StartCoroutine(Sun());
        }

        wind.windMain           = 1 * (1 + intensity);
        wind.windPulseMagnitude = 3 * (1 + intensity);
        weatherClip.Play();
        windClip.Play();
    }
Beispiel #6
0
        protected override void AssignByIndex()
        {
            MapDetails details = m_MapList[m_CurrentIndex];

            m_MapPreview.sprite = details.image;
            m_Description.text  = details.description;
            m_MapName           = details.name;
            m_MapId             = details.id;
            m_MapCost           = details.unlockCost;

            m_MapNamePrompt.text = m_MapName.ToUpperInvariant();

            // Set BG
            if (m_BgImage != null)
            {
                m_BgImage.color = details.effectsGroup == MapEffectsGroup.Snow ? m_SnowBgColour : m_DesertBgColour;
            }

            //We determine whether a level should be displayed as locked. We assume it's unlocked by default.
            bool levelLocked = false;

            if (m_CostParent != null)
            {
                m_CostParent.gameObject.SetActive(levelLocked);
                if (m_UnlockButton != null)
                {
                    m_UnlockButton.gameObject.SetActive(levelLocked);
                }
                if (m_MapCostPrompt != null)
                {
                    m_MapCostPrompt.text = m_MapCost.ToString();
                }
            }
            m_CreateButton.interactable = !levelLocked;
        }
Beispiel #7
0
        /// <summary>
        /// Register network players so we have all of them
        /// </summary>
        public void RegisterNetworkPlayer(NetworkPlayer newPlayer)
        {
            MapDetails currentMap = m_Settings.map;

            connectedPlayers.Add(newPlayer);
            newPlayer.becameReady += OnPlayerSetReady;

            if (s_IsServer)
            {
                UpdatePlayerIDs();
            }

            // Send initial scene message
            string sceneName = SceneManager.GetActiveScene().name;

            if (currentMap != null && sceneName == currentMap.sceneName)
            {
                newPlayer.OnEnterGameScene();
            }
            else if (sceneName == s_LobbySceneName)
            {
                newPlayer.OnEnterLobbyScene();
            }

            if (playerJoined != null)
            {
                playerJoined(newPlayer);
            }
            // AgoraPlayerController.instance.AddNetworkPlayer(newPlayer);
            newPlayer.gameDetailsReady += FireGameModeUpdated;
        }
Beispiel #8
0
        public async Task ShouldReturnLocationIfOneIsSelected()
        {
            // Arrange
            var location = new MapDetails()
            {
                MapPosition = new MapPosition()
                {
                    Lat = 1, Lon = 1
                },
                AccessibleTransportLink = ""
            };

            var processedGroup = new ProcessedGroupBuilder().MapDetails(location).Build();

            // Mocks
            _loggedInHelper.Setup(_ => _.GetLoggedInPerson()).Returns(new LoggedInPerson());
            _processedRepository.Setup(o => o.Get <Group>(It.IsAny <string>(), It.IsAny <List <Query> >()))
            .ReturnsAsync(new StockportWebapp.Http.HttpResponse((int)HttpStatusCode.OK, processedGroup, string.Empty));

            _configuration.Setup(_ => _.GetArchiveEmailPeriods())
            .Returns(new List <ArchiveEmailPeriod> {
                new ArchiveEmailPeriod {
                    NumOfDays = 1
                }
            });

            // Act
            var view = await _groupController.Detail("slug") as ViewResult;

            var model = view.ViewData.Model as GroupDetailsViewModel;

            // Assert
            model.Group.MapDetails.Should().Be(location);
        }
Beispiel #9
0
        public override void OnClientSceneChanged(NetworkConnection conn)
        {
            MapDetails currentMap = m_Settings.map;

            Debug.Log("OnClientSceneChanged");
            base.OnClientSceneChanged(conn);

            PlayerController pc = conn.playerControllers[0];

            if (!pc.unetView.isLocalPlayer)
            {
                return;
            }

            string sceneName = SceneManager.GetActiveScene().name;

            if (currentMap != null && sceneName == currentMap.sceneName)
            {
                state = NetworkState.InGame;

                // Tell all network players that they're in the game scene
                for (int i = 0; i < connectedPlayers.Count; ++i)
                {
                    NetworkPlayer np = connectedPlayers[i];
                    if (np != null)
                    {
                        np.OnEnterGameScene();
                    }
                }
            }
            else if (sceneName == s_LobbySceneName)
            {
                if (state != NetworkState.Inactive)
                {
                    if (gameType == NetworkGameType.Singleplayer)
                    {
                        state = NetworkState.Pregame;
                    }
                    else
                    {
                        state = NetworkState.InLobby;
                    }
                }

                // Tell all network players that they're in the lobby scene
                for (int i = 0; i < connectedPlayers.Count; ++i)
                {
                    NetworkPlayer np = connectedPlayers[i];
                    if (np != null)
                    {
                        np.OnEnterLobbyScene();
                    }
                }
            }

            if (sceneChanged != null)
            {
                sceneChanged(false, sceneName);
            }
        }
Beispiel #10
0
        /// --------------------------------------------------------------------------------------------------------
        /// <summary>
        /// 增加一个玩家到本地游戏中
        /// </summary>
        /// --------------------------------------------------------------------------------------------------------
        public void RegisterNetworkPlayer(NetworkPlayer newPlayer)
        {
            MapDetails currentMap = m_Settings.map;

            Debug.Log("Player joined");
            connectedPlayers.Add(newPlayer);
            playerList.Add(newPlayer.gameObject);
            newPlayer.becameReady += OnPlayerSetReady;

            if (s_IsServer)
            {
                UpdatePlayerIDs();
            }

            string sceneName = SceneManager.GetActiveScene().name;

            if (currentMap != null && sceneName == currentMap.sceneName)
            {
                newPlayer.OnEnterGameScene();
            }
            else if (sceneName == s_LobbySceneName)
            {
                newPlayer.OnEnterLobbyScene();
            }

            if (playerJoined != null)
            {
                playerJoined(newPlayer);
            }

            newPlayer.gameDetailsReady += FireGameModeUpdated;
        }
Beispiel #11
0
        private static List <TextureDetails> ParseTilesets(MapDetails Details)
        {
            var Textures = new List <TextureDetails>();

            foreach (XmlNode TilesetNode in Details.MapElement.SelectNodes("tileset"))
            {
                if (TilesetNode.ChildNodes.Count != 1)
                {
                    throw new FormatException("Expected a single 'image' child for the children of map.");
                }
                var    ImageNode   = TilesetNode.ChildNodes[0];
                string ImageSource = ImageNode.Attributes["source"].Value;
                string TextureName = Path.GetFileNameWithoutExtension(ImageSource);
                var    Texture     = CorvBase.Instance.GlobalContent.Load <Texture2D>("Tiles/" + TextureName);
                int    StartGID    = int.Parse(TilesetNode.Attributes["firstgid"].Value);
                int    TileWidth   = int.Parse(TilesetNode.Attributes["tilewidth"].Value);
                int    TileHeight  = int.Parse(TilesetNode.Attributes["tileheight"].Value);
                Textures.Add(new TextureDetails()
                {
                    Texture      = Texture,
                    StartGID     = StartGID,
                    TileHeight   = TileHeight,
                    TileWidth    = TileWidth,
                    NumTilesHigh = Texture.Height / TileHeight,
                    NumTilesWide = Texture.Width / TileWidth
                });
            }
            Textures = Textures.OrderBy(c => c.StartGID).ToList();
            return(Textures);
        }
Beispiel #12
0
    // Start is called before the first frame update
    void Start()
    {
        mapDetails = GetComponent <MapDetails>();

        mapCanvas = mapDetails.mapCanvas;
        mapTile   = mapDetails.mapTile;

        width  = gameObject.GetComponent <RectTransform>().rect.width;
        height = gameObject.GetComponent <RectTransform>().rect.height;



        //Debug.Log(height);

        columns = int.Parse(width.ToString()) / 50;
        rows    = int.Parse(height.ToString()) / 50;

        if (editorMode == true)
        {
            //RandomMap();
            codeInput.GetComponent <TMP_InputField>();
        }
        else
        {
        }
    }
 /// <summary>
 /// Initialize enemy tracker with null arguments, which will be updated once we know initial position of map.
 /// </summary>
 public EnemyTracker()
 {
     this.bot           = null;
     this.map           = null;
     this.enemyProbs    = null;
     this.enemyDeployed = 0;
     this.enemyIncome   = 0;
 }
Beispiel #14
0
 private void Start()
 {
     foregroundTilemap = ObjectReferences.Instance.ForegroundTilemap;
     backgroundTilemap = ObjectReferences.Instance.BackgroundTilemap;
     TurnTextScript    = ObjectReferences.Instance.TurnTextScript;
     DialogueHandler   = ObjectReferences.Instance.DialogueHandlerScript;
     MapDetails.InitialiseTiles(foregroundTilemap);
 }
Beispiel #15
0
        public static List <TerritoryIDType> GetNeighborTerritories(TerritoryIDType territory)
        {
            MapDetails map = GameState.Map;
            List <TerritoryDetails> territoryDetails      = map.Territories.Select(o => o.Value).ToList();
            TerritoryDetails        territoryInQuestion   = territoryDetails.Where(o => o.ID == territory).First();
            List <TerritoryIDType>  connectedTerritoryIds = territoryInQuestion.ConnectedTo.Keys.ToList();

            return(connectedTerritoryIds);
        }
        public void GetMapSource_Zoom_HasDefaultValue()
        {
            var sut = new GoogleMapsProvider();
            var mapDetails = new MapDetails();

            var actual = sut.GetStaticMap(mapDetails);

            Assert.Contains("zoom=", actual.ToString());
        }
        public void GetMapSource_EncodedPolyLine_IncludesPolyLine()
        {
            var sut = new GoogleMapsProvider();
            var mapDetails = new MapDetails { EncodedPolyline = "blah" };

            var actual = sut.GetStaticMap(mapDetails);

            Assert.Contains("path=enc:blah", actual.ToString());
        }
        public void GetMapSource_Zoom_MapsToInt()
        {
            var sut = new GoogleMapsProvider();
            var mapDetails = new MapDetails { Zoom = 1 };

            var actual = sut.GetStaticMap(mapDetails);

            Assert.Contains("zoom=21", actual.ToString());
        }
        public void GetMapSource_Center_ReturnsUrlWithCenter()
        {
            var sut = new GoogleMapsProvider();
            var mapDetails = new MapDetails { Center = new Coordinate { Latitude = 1, Longitude = 2 } };

            var actual = sut.GetStaticMap(mapDetails);

            Assert.Contains("center=1%2C2", actual.ToString());
        }
        public void GetMapSource_NoCenter_ReturnsUrlWithoutCenter()
        {
            var sut = new GoogleMapsProvider();
            var mapDetails = new MapDetails { Center = null };

            var actual = sut.GetStaticMap(mapDetails);

            Assert.DoesNotContain("center", actual.ToString());
        }
        public void GetMapSource_EmptyParameters_ReturnsUrlWithZeroSize()
        {
            var sut = new GoogleMapsProvider();
            var mapDetails = new MapDetails();

            var actual = sut.GetStaticMap(mapDetails);

            Assert.Contains("size=0x0", actual.ToString());
        }
        public void GetMapSource_EncodedPolyLine_DoesNotIncludeCenterOrZoom()
        {
            var sut = new GoogleMapsProvider();
            var mapDetails = new MapDetails { EncodedPolyline = "blah" };

            var actual = sut.GetStaticMap(mapDetails);

            Assert.DoesNotContain("center", actual.ToString());
            Assert.DoesNotContain("zoom", actual.ToString());
        }
Beispiel #23
0
    //Called from within Load Route List to add a route from Placenote to the list in the application
    void AddRouteToList(LibPlacenote.MapInfo routeInfo)
    {
        GameObject newElement = Instantiate(mListElement) as GameObject;
        //Calls MapDetails Class to set details for new row in list for route
        MapDetails listElement = newElement.GetComponent <MapDetails> ();

        listElement.Initialize(routeInfo, mToggleGroup, mListContentParent, (value) => {
            OnRouteSelected(routeInfo);
        });
    }
Beispiel #24
0
    protected void AddAdjacent(Node centre)
    {
        if (centre.Cost < unitDetails.MoveRange && !closedTiles.Exists(t => t.Position == centre.Position))
        {
            var newPos = new Vector2(centre.Position.x, centre.Position.y - 1);
            var tile   = MapDetails.GetTileDetails((int)newPos.x, (int)newPos.y);
            if (tile == null)
            {
                tile = new TileDetails(-1000, -1000, false);
            }
            var impassable = (!tile.Passable || MapUtils.FindUnitOnTile((int)newPos.x, (int)newPos.y));
            if (!closedTiles.Exists(t => t.Position == newPos) && !impassable)
            {
                openTiles.Add(new Node(newPos, centre, centre.Cost + 1));
            }

            newPos = new Vector2(centre.Position.x, centre.Position.y + 1);
            tile   = MapDetails.GetTileDetails((int)newPos.x, (int)newPos.y);
            if (tile == null)
            {
                tile = new TileDetails(-1000, -1000, false);
            }
            impassable = (!tile.Passable || MapUtils.FindUnitOnTile((int)newPos.x, (int)newPos.y));
            if (!closedTiles.Exists(t => t.Position == newPos) && !impassable)
            {
                openTiles.Add(new Node(newPos, centre, centre.Cost + 1));
            }

            newPos = new Vector2(centre.Position.x + 1, centre.Position.y);
            tile   = MapDetails.GetTileDetails((int)newPos.x, (int)newPos.y);
            if (tile == null)
            {
                tile = new TileDetails(-1000, -1000, false);
            }
            impassable = (!tile.Passable || MapUtils.FindUnitOnTile((int)newPos.x, (int)newPos.y));
            if (!closedTiles.Exists(t => t.Position == newPos) && !impassable)
            {
                openTiles.Add(new Node(newPos, centre, centre.Cost + 1));
            }

            newPos = new Vector2(centre.Position.x - 1, centre.Position.y);
            tile   = MapDetails.GetTileDetails((int)newPos.x, (int)newPos.y);
            if (tile == null)
            {
                tile = new TileDetails(-1000, -1000, false);
            }
            impassable = (!tile.Passable || MapUtils.FindUnitOnTile((int)newPos.x, (int)newPos.y));
            if (!closedTiles.Exists(t => t.Position == newPos) && !impassable)
            {
                openTiles.Add(new Node(newPos, centre, centre.Cost + 1));
            }
        }
        closedTiles.Add(centre);
        openTiles.Remove(centre);
    }
 /// <summary>
 /// Initialize the
 /// </summary>
 /// <param name="bot">The name of the bot containing current game-state</param>
 public void init(BotMain Bot)
 {
     bot        = Bot;
     map        = bot.Map;
     enemyProbs = new Dictionary <TerritoryIDType, double>();
     foreach (KeyValuePair <TerritoryIDType, TerritoryDetails> territory in map.Territories)
     {
         enemyProbs[territory.Key] = 0.0;
     }
     enemyIncome = Bot.Settings.MinimumArmyBonus;
 }
Beispiel #26
0
 private bool checkDistances(List <Settlement> settlements, MapDetails map)
 {
     foreach (var settlement in settlements)
     {
         if (Math.Abs(settlement.Lat - map.Lat) <= 0.2 || Math.Abs(settlement.Long - map.Long) <= 0.2)
         {
             return(true);
         }
     }
     return(false);
 }
        /// <summary>
        /// Sets up single player
        /// </summary>
        /// <param name="map">Map.</param>
        /// <param name="modeDetails">Mode details.</param>
        public void SetupSinglePlayer(MapDetails map, ModeDetails modeDetails)
        {
            this.map      = map;
            this.mapIndex = -1;
            if (mapChanged != null)
            {
                mapChanged(map);
            }

            SetMode(modeDetails, -1);
        }
Beispiel #28
0
    List <TileDetails> GetAdjacentTiles(int sourceX, int sourceY)
    {
        List <TileDetails> tiles = new List <TileDetails>
        {
            MapDetails.GetTileDetails(sourceX + 1, sourceY),
            MapDetails.GetTileDetails(sourceX - 1, sourceY),
            MapDetails.GetTileDetails(sourceX, sourceY + 1),
            MapDetails.GetTileDetails(sourceX, sourceY - 1)
        };

        return(tiles);
    }
Beispiel #29
0
 public static void PushMoveState(PlayerIDType myPlayerId, Dictionary <PlayerIDType, GamePlayer> players,
                                  MapDetails map, GameStanding distributionStanding, GameSettings gameSettings, int numberOfTurns,
                                  Dictionary <PlayerIDType, PlayerIncome> incomes, GameOrder[] prevTurn, GameStanding latestTurnStanding,
                                  GameStanding previousTurnStanding)
 {
     MyPlayerId           = myPlayerId;
     OpponentPlayerId     = players.Keys.Where(o => o != MyPlayerId).First();
     Players              = players;
     DistributionStanding = distributionStanding;
     GameSettings         = gameSettings;
     Map = map;
     TurnStates.Add(new TurnState(numberOfTurns, incomes, prevTurn, latestTurnStanding, previousTurnStanding));
 }
Beispiel #30
0
 public void Init(PlayerIDType myPlayerID, Dictionary<PlayerIDType, GamePlayer> players, MapDetails map, GameStanding distributionStanding, GameSettings gameSettings, int numberOfTurns, Dictionary<PlayerIDType, PlayerIncome> incomes, GameOrder[] prevTurn, GameStanding latestTurnStanding, GameStanding previousTurnStanding, Dictionary<PlayerIDType, TeammateOrders> teammatesOrders, List<CardInstance> cards, int cardsMustPlay)
 {
     this.DistributionStanding = distributionStanding;
     this.LatestTurnStanding = latestTurnStanding;
     this.MyPlayerID = myPlayerID;
     this.Players = players;
     this.Map = map;
     this.Settings = gameSettings;
     this.TeammatesOrders = teammatesOrders;
     this.Cards = cards;
     this.CardsMustPlay = cardsMustPlay;
     this.Incomes = incomes;
 }
Beispiel #31
0
    //this activates every time a scene is changed
    private void OnSceneChange(Scene arg0, Scene arg1)
    {
        //Debug.Log("Test:" + arg0.name + " -> " + arg1.name);

        activeTiles.Clear();
        activeMap = null;
        popMenu.SetActive(false);

        GameObject camera = GameObject.Find("Main Camera");

        canvasCamera = camera.GetComponent <Camera>();
        Instance.overworldCanvas.worldCamera = GameManager.Instance.canvasCamera;
    }
Beispiel #32
0
        /// <summary>
        /// Progress to game scene when in transitioning state
        /// </summary>
        protected virtual void Update()
        {
            if (m_SceneChangeMode != SceneChangeMode.None)
            {
                LoadingModal modal = LoadingModal.s_Instance;

                bool ready = true;
                if (modal != null)
                {
                    ready = modal.readyToTransition;

                    if (!ready && modal.fader.currentFade == Fade.None)
                    {
                        modal.FadeIn();
                    }
                }

                if (ready)
                {
                    if (m_SceneChangeMode == SceneChangeMode.Menu)
                    {
                        if (state != NetworkState.Inactive)
                        {
                            ServerChangeScene(s_LobbySceneName);
                            if (gameType == NetworkGameType.Singleplayer)
                            {
                                state = NetworkState.Pregame;
                            }
                            else
                            {
                                state = NetworkState.InLobby;
                            }
                        }
                        else
                        {
                            SceneManager.LoadScene(s_LobbySceneName);
                        }
                    }
                    else
                    {
                        MapDetails map = GameSettings.s_Instance.map;

                        ServerChangeScene(map.sceneName);

                        state = NetworkState.InGame;
                    }

                    m_SceneChangeMode = SceneChangeMode.None;
                }
            }
        }
Beispiel #33
0
        private static List <Entity> ParseEntities(MapDetails Map)
        {
            List <Entity>      Entities = new List <Entity>();
            List <PathDetails> Paths    = new List <PathDetails>();

            foreach (XmlNode ObjectGroupNode in Map.MapElement.SelectNodes("objectgroup"))
            {
                foreach (XmlNode ObjectNode in ObjectGroupNode.SelectNodes("object"))
                {
                    ObjectType Type = ReadObjectType(ObjectNode);
                    if (Type == ObjectType.Path)
                    {
                        var Path = ParsePath(ObjectNode);
                        Paths.Add(Path);
                    }
                    else if (Type == ObjectType.Entity)
                    {
                        var Entity = ParseEntity(ObjectNode);
                        Entities.Add(Entity);
                    }
                    else
                    {
                        throw new ArgumentException("Unknown object type '" + Type + "'.");
                    }
                }
            }

            foreach (var Path in Paths)
            {
                var Entity = Entities.Where(c => c.Name.Equals(Path.EntityName, StringComparison.InvariantCultureIgnoreCase));
                foreach (var e in Entity)
                {
                    var PathComponent = e.GetComponent <PathComponent>();
                    if (PathComponent == null)
                    {
                        PathComponent = new PathComponent();
                        e.Components.Add(PathComponent);
                    }
                    if (PathComponent.Nodes != null)
                    {
                        PathComponent.Nodes.Clear();
                    }
                    foreach (var Node in Path.Nodes)
                    {
                        PathComponent.AddNode(Node);
                    }
                }
            }
            return(Entities);
        }
Beispiel #34
0
    public MapTileMining(MapDetails map, MapTile tile)
    {
        MapTile = tile;
        Map     = map;

        TileAttribute att   = tile.tileAtt;
        int           level = tile.info.level;

        itemChance[0] = .95f;
        itemChance[1] = .04f;
        itemChance[2] = .01f;

        mineChance = .90f;
    }
Beispiel #35
0
        private static List <LevelProperty> ParseProperties(MapDetails Map)
        {
            List <LevelProperty> Result = new List <LevelProperty>();

            foreach (XmlNode propertiesNode in Map.MapElement.SelectNodes("properties"))
            {
                foreach (XmlNode propertyNode in propertiesNode.SelectNodes("property"))
                {
                    string name  = propertyNode.Attributes["name"].Value;
                    string value = propertyNode.Attributes["value"].Value;
                    Result.Add(new LevelProperty(name, value));
                }
            }

            return(Result);
        }
Beispiel #36
0
    //use this to check the global stat mods in play and apply them to this monster
    public void GlobalStatMod(MapDetails map)
    {
        //checks all of the global stats and adds their effects to this monster if it hasn't been added yet
        for (int i = 0; i < map.activeGlobalStats.Count; i++)
        {
            if (!activeGlobalStats.Contains(map.activeGlobalStats[i]))
            {
                activeGlobalStats.Add(map.activeGlobalStats[i]);
                map.activeGlobalStats[i].AddStat(this);
            }
        }



        MonsterStatMods();
    }
Beispiel #37
0
    // Update is called once per frame
    void Update()
    {
        if (GameManager.IsPaused)
        {
            return;
        }

        CheckMouseControl();
        if (IsMouseControlling)
        {
            CurrentGridX = MapUtils.GetMouseGridX();
            CurrentGridY = MapUtils.GetMouseGridY();
            CurrentTile  = MapDetails.GetTileDetails(CurrentGridX, CurrentGridY);
            if (CurrentTile != null)
            {
                transform.position = MapUtils.GetGridWorldPos(MapUtils.GetMouseGridX(), MapUtils.GetMouseGridY());
            }
        }
        else
        {
            if (InputManager.ActiveDevice.DPadLeft.WasPressed)
            {
                CurrentGridX = CurrentGridX - 1;
            }
            if (InputManager.ActiveDevice.DPadRight.WasPressed)
            {
                CurrentGridX = CurrentGridX + 1;
            }
            if (InputManager.ActiveDevice.DPadUp.WasPressed)
            {
                CurrentGridY = CurrentGridY + 1;
            }
            if (InputManager.ActiveDevice.DPadDown.WasPressed)
            {
                CurrentGridY = CurrentGridY - 1;
            }
            transform.position = MapUtils.GetGridWorldPos(CurrentGridX, CurrentGridY);
        }

        CurrentTile = MapDetails.GetTileDetails(CurrentGridX, CurrentGridY);
        if (CurrentTile != null)
        {
            //transform.position = TilemapUtils.GetGridWorldPos(GroundTilemap, TilemapUtils.GetMouseGridX(GroundTilemap, Camera.main), TilemapUtils.GetMouseGridY(GroundTilemap, Camera.main));
        }
        CurrentLocation = transform.position;
    }
Beispiel #38
0
        /// <summary>
        /// Loads the data for a level using the Tiled Map Xml format.
        /// </summary>
        public static LevelData LoadTmx(string FilePath)
        {
            // https://github.com/bjorn/tiled/wiki/TMX-Map-Format contains a description of the format.
            XmlDocument Doc = new XmlDocument();
            Doc.Load(FilePath);
            if(Doc.GetElementsByTagName("map").Count != 1)
                throw new FormatException("Expected a single map to be defined in a .tmx file.");
            var MapElement = Doc.GetElementsByTagName("map").Item(0);
            var MapDetails = new MapDetails(MapElement);
            List<TextureDetails> Textures = ParseTilesets(MapDetails);
            List<Layer> Layers = ParseLayers(MapDetails, Textures);
            List<Entity> Entities = ParseEntities(MapDetails);
            List<LevelProperty> Properties = ParseProperties(MapDetails);

            LevelData Result = new LevelData() {
                DynamicObjects = Entities.ToArray(),
                Layers = Layers.ToArray(),
                MapSize = new Vector2(MapDetails.MapWidth, MapDetails.MapHeight),
                TileSize = new Vector2(MapDetails.MapTileWidth, MapDetails.MapTileHeight),
                Properties = Properties.ToArray()
            };
            return Result;
        }
Beispiel #39
0
        private static List<Entity> ParseEntities(MapDetails Map)
        {
            List<Entity> Entities = new List<Entity>();
            List<PathDetails> Paths = new List<PathDetails>();
            foreach(XmlNode ObjectGroupNode in Map.MapElement.SelectNodes("objectgroup")) {
                foreach(XmlNode ObjectNode in ObjectGroupNode.SelectNodes("object")) {
                    ObjectType Type = ReadObjectType(ObjectNode);
                    if(Type == ObjectType.Path) {
                        var Path = ParsePath(ObjectNode);
                        Paths.Add(Path);
                    } else if(Type == ObjectType.Entity) {
                        var Entity = ParseEntity(ObjectNode);
                        Entities.Add(Entity);
                    } else
                        throw new ArgumentException("Unknown object type '" + Type + "'.");
                }
            }

            foreach(var Path in Paths) {
                var Entity = Entities.Where(c => c.Name.Equals(Path.EntityName, StringComparison.InvariantCultureIgnoreCase));
                foreach (var e in Entity)
                {
                    var PathComponent = e.GetComponent<PathComponent>();
                    if (PathComponent == null)
                    {
                        PathComponent = new PathComponent();
                        e.Components.Add(PathComponent);
                    }
                    if (PathComponent.Nodes != null)
                        PathComponent.Nodes.Clear();
                    foreach (var Node in Path.Nodes)
                        PathComponent.AddNode(Node);
                }
            }
            return Entities;
        }
Beispiel #40
0
 private static List<TextureDetails> ParseTilesets(MapDetails Details)
 {
     var Textures = new List<TextureDetails>();
     foreach(XmlNode TilesetNode in Details.MapElement.SelectNodes("tileset")) {
         if(TilesetNode.ChildNodes.Count != 1)
             throw new FormatException("Expected a single 'image' child for the children of map.");
         var ImageNode = TilesetNode.ChildNodes[0];
         string ImageSource = ImageNode.Attributes["source"].Value;
         string TextureName = Path.GetFileNameWithoutExtension(ImageSource);
         var Texture = CorvBase.Instance.GlobalContent.Load<Texture2D>("Tiles/" + TextureName);
         int StartGID = int.Parse(TilesetNode.Attributes["firstgid"].Value);
         int TileWidth = int.Parse(TilesetNode.Attributes["tilewidth"].Value);
         int TileHeight = int.Parse(TilesetNode.Attributes["tileheight"].Value);
         Textures.Add(new TextureDetails() {
             Texture = Texture,
             StartGID = StartGID,
             TileHeight = TileHeight,
             TileWidth = TileWidth,
             NumTilesHigh = Texture.Height / TileHeight,
             NumTilesWide = Texture.Width / TileWidth
         });
     }
     Textures = Textures.OrderBy(c => c.StartGID).ToList();
     return Textures;
 }
Beispiel #41
0
        private static List<Layer> ParseLayers(MapDetails Map, List<TextureDetails> Textures)
        {
            var Result = new List<Layer>();
            foreach(XmlNode LayerNode in Map.MapElement.SelectNodes("layer")) {
                var DataNode = LayerNode.SelectNodes("data").Item(0);
                string CompressionFormat = DataNode.Attributes["compression"].Value;
                string EncodingFormat = DataNode.Attributes["encoding"].Value;
                if(!CompressionFormat.Equals("gzip", StringComparison.InvariantCultureIgnoreCase) || !EncodingFormat.Equals("base64", StringComparison.InvariantCultureIgnoreCase))
                    throw new FormatException("Currently the Tmx loader can only handled base-64 zlib tiles.");
                string Base64Data = DataNode.InnerXml.Trim();
                byte[] CompressedData = Convert.FromBase64String(Base64Data);
                byte[] UncompressedData = new byte[1024]; // NOTE: This must be a multiple of 4.
                Tile[,] Tiles = new Tile[Map.MapNumTilesWide, Map.MapNumTilesHigh];
                int MapIndex = 0;
                using(var GZipStream = new GZipStream(new MemoryStream(CompressedData), CompressionMode.Decompress, false)) {
                    while(true) {
                        int BytesRead = GZipStream.Read(UncompressedData, 0, UncompressedData.Length);
                        if(BytesRead == 0)
                            break;
                        using(BinaryReader Reader = new BinaryReader(new MemoryStream(UncompressedData))) {
                            for(int i = 0; i < BytesRead; i += 4) {
                                int GID = Reader.ReadInt32();
                                int MapX = MapIndex % Map.MapNumTilesWide;
                                int MapY = MapIndex / Map.MapNumTilesWide;
                                MapIndex++;
                                if(GID == 0)
                                    continue;
                                var Texture = Textures.Last(c => c.StartGID <= GID);
                                int TextureX = (GID - Texture.StartGID) % Texture.NumTilesWide;
                                int TextureY = (GID - Texture.StartGID) / Texture.NumTilesWide;
                                Rectangle SourceRect = new Rectangle(TextureX * Texture.TileWidth, TextureY * Texture.TileHeight, Texture.TileWidth, Texture.TileHeight);
                                Rectangle Location = new Rectangle(MapX * Map.MapTileWidth, MapY * Map.MapTileHeight, Map.MapTileWidth, Map.MapTileHeight);
                                Tile Tile = new Tile(Texture.Texture, SourceRect, Location, new Vector2(MapX, MapY));
                                Tiles[MapX, MapY] = Tile;
                            }
                        }
                    }
                }

                bool IsSolid = true;
                foreach(XmlNode PropertiesNode in LayerNode.SelectNodes("properties")) {
                    foreach(XmlNode Property in PropertiesNode.SelectNodes("property")) {
                        string Name = Property.Attributes["name"].Value;
                        string Value = Property.Attributes["value"].Value;
                        if(Name.Equals("Solid", StringComparison.InvariantCultureIgnoreCase)) {
                            IsSolid = bool.Parse(Value);
                        }
                    }
                }
                Layer Layer = new Layer(new Vector2(Map.MapTileWidth, Map.MapTileHeight), Tiles);
                Layer.IsSolid = IsSolid;
                Result.Add(Layer);
            }
            return Result;
        }
Beispiel #42
0
        private static List<LevelProperty> ParseProperties(MapDetails Map)
        {
            List<LevelProperty> Result = new List<LevelProperty>();
            foreach (XmlNode propertiesNode in Map.MapElement.SelectNodes("properties"))
            {
                foreach (XmlNode propertyNode in propertiesNode.SelectNodes("property"))
                {
                    string name = propertyNode.Attributes["name"].Value;
                    string value = propertyNode.Attributes["value"].Value;
                    Result.Add(new LevelProperty(name, value));
                }
            }

            return Result;
        }