Exemplo n.º 1
0
        public void AddLand(Land land)
        {
            if (Lands.Any(lnd => lnd.Equals(land)))
            {
                return;
            }

            Lands.Add(land);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a GeoJson file to the layer.
        /// </summary>
        /// <param name="file"></param>
        public void AddFile(GeoJsonFile file)
        {
            if (file.Features is null)
            {
                throw new Exception(
                          $"The {nameof(GeoJsonFile.Features)} property is required to build a {nameof(CoreMap<TDrawingContext>)} instance. " +
                          $"Ensure the property is not null.");
            }

            foreach (var feature in file.Features)
            {
                if (feature.Geometry is null || feature.Geometry.Coordinates is null)
                {
                    continue;
                }

                var name      = (feature.Properties?["name"] ?? "?").ToLowerInvariant();
                var shortName = (feature.Properties?["shortName"] ?? "?").ToLowerInvariant();
                var setOf     = (feature.Properties?["setOf"] ?? "?").ToLowerInvariant();

                var definition = new LandDefinition(shortName, name, setOf);

                var dataCollection = new List <LandData>();

                foreach (var geometry in feature.Geometry.Coordinates)
                {
                    foreach (var segment in geometry)
                    {
                        var data = new LandData(segment);

                        if (data.MaxBounds[0] > definition.MaxBounds[0])
                        {
                            definition.MaxBounds[0] = data.MaxBounds[0];
                        }
                        if (data.MinBounds[0] < definition.MinBounds[0])
                        {
                            definition.MinBounds[0] = data.MinBounds[0];
                        }

                        if (data.MaxBounds[1] > definition.MaxBounds[1])
                        {
                            definition.MaxBounds[1] = data.MaxBounds[1];
                        }
                        if (data.MinBounds[1] < definition.MinBounds[1])
                        {
                            definition.MinBounds[1] = data.MinBounds[1];
                        }

                        dataCollection.Add(data);
                    }
                }

                definition.Data = dataCollection.OrderByDescending(x => x.BoundsHypotenuse).ToArray();
                Lands.Add(shortName, definition);
            }
        }
Exemplo n.º 3
0
 public PlayingTile(IBoard board, LandEnum landLeft, LandEnum landRight)
 {
     m_Board = board;
     Lands   = new[]
     {
         new Land(this, LandEnum.Volcano, CurrentPositionX, CurrentPositionY - 1),
         new Land(this, landLeft, CurrentPositionX, CurrentPositionY),
         new Land(this, landRight, CurrentPositionX + 1, CurrentPositionY)
     };
     Volcano = Lands.First(l => l.LandType == LandEnum.Volcano);
 }
        public IEnumerable <Land> GetListForUser(int customerId)
        {
            List <land> Lands;

            using (LD_kursEntities db = new LD_kursEntities())
            {
                Lands = db.land
                        .Where(f => f.customer_id == customerId)
                        .ToList <land>();
            }
            return(Mapper.Map <List <Land> >(Lands.OrderByDescending(x => x.id)));
        }
        public IEnumerable <Land> GetList()
        {
            List <land> Lands;
            List <Land> List;

            using (LD_kursEntities db = new LD_kursEntities())
            {
                Lands = db.land.ToList <land>();
                List  = Mapper.Map <List <Land> >(Lands.OrderByDescending(x => x.id));
            }
            return(List);
        }
Exemplo n.º 6
0
    IEnumerator GetLandsRequest(string url)
    {
        UnityWebRequest webRequest = UnityWebRequest.Get(url);

        yield return(webRequest.SendWebRequest());

        if (webRequest.isNetworkError || webRequest.isHttpError)
        {
            Debug.Log("Error: " + webRequest.error);
            yield break;
        }

        if (webRequest.downloadHandler.text == "")
        {
            Debug.Log("World has not been unlocked");
            yield break;
        }

        JSONNode rawJson = JSON.Parse(webRequest.downloadHandler.text);

        landListStr = "{\"listOfLands\":" + rawJson.ToString() + "}";
        Debug.Log("Land List:" + rawJson.ToString());

        landList = JsonUtility.FromJson <Lands>(landListStr);

        Map = new List <Land>();
        Debug.Log("count:" + landList.listOfLands.Count);

        //if events.mode=="battle"/"duel"

        foreach (LandInfo landInfo in landList.listOfLands)
        {
            Land newLand = new Land();
            newLand.landNo = landInfo.ind;
            worldId        = landInfo.worldId;
            if (landInfo.ownerId != 0)
            {
                newLand.iconSprite = iconSprites[0];//which is flower
                newLand.owner      = landInfo.ownerName;
                //newLand.owner = getOwnerName(landInfo.ownerId);
                newLand.difficulty = getDifficultyStr(landInfo.ownerDifficulty);
            }
            else
            {
                newLand.iconSprite = iconSprites[1];//which is soil
                newLand.owner      = landInfo.landId.ToString();
            }
            Map.Add(newLand);
        }
        GenMap();
    }
        public void LandInitialization()
        {
            var random = new Random(Seed);

            for (int y = 0; y < 20; y++)
            {
                for (int x = 0; x < 20; x++)
                {
                    var n     = random.Next(1, 18);
                    var plane = (n > 12 && n > 16) ? new City() : (n > 12) ? new Town() : new Plane();
                    foreach (Producer pr in Producers)
                    {
                        plane.Producers.Add(pr, 0);
                    }
                    if (plane is City)
                    {
                        plane.Gold = random.Next(300, 1500) * 2;
                        for (int i = 0; i < random.Next(2, 5); i++)
                        {
                            var p = random.Next(0, Producers.Count);
                            var l = random.Next(1, 4);
                            plane.Producers[Producers[p]] += l;
                            plane.Shop      = new Shop();
                            plane.Shop.Gold = plane.Gold;
                        }
                    }
                    else if (plane is Town)
                    {
                        plane.Gold = random.Next(300, 1500);
                        var p = random.Next(0, Producers.Count);
                        var l = random.Next(1, 2);
                        plane.Producers[Producers[p]] = l;
                        plane.Shop      = new Shop();
                        plane.Shop.Gold = plane.Gold;
                    }
                    if (plane is Town || plane is City)
                    {
                        foreach (Item item in Resources)
                        {
                            Item it = item;
                            int  r  = plane is City?random.Next(10, 100) : random.Next(5, 50);

                            it.ActualValue = (r / 10 * it.BaseValue) - (plane.Producers.First(p => p.Key.Resource.Name == it.Name).Value *plane.Producers.First(p => p.Key.Resource.Name == it.Name).Key.ResourcePerDay);
                            plane.Shop.Items.Add(it, r);
                        }
                    }
                    Lands.Add(new Point(x, y), plane);
                }
            }
        }
Exemplo n.º 8
0
    IEnumerator GetLandsRequest(string url)
    {
        UnityWebRequest webRequest = UnityWebRequest.Get(url);

        yield return(webRequest.SendWebRequest());

        if (webRequest.isNetworkError || webRequest.isHttpError)
        {
            Debug.Log("Error: " + webRequest.error);
            yield break;
        }

        if (webRequest.downloadHandler.text == "")
        {
            Debug.Log("World has not been unlocked");
            yield break;
        }
        JSONNode rawJson = JSON.Parse(webRequest.downloadHandler.text);

        landListStr = "{\"landList\":" + rawJson.ToString() + "}";
        Debug.Log("Land List string:" + landListStr);

        landList = JsonUtility.FromJson <Lands>(landListStr);
    }
Exemplo n.º 9
0
        async void GetLands()
        {
            //IsBusy = true;
            try
            {
                Lands.Clear();
                var landList = await remoteService.GetAllProperty();

                foreach (var item in landList)
                {
                    if (item.ItemType.ToLower() == "land")
                    {
                        if (Lands.Count < 3)
                        {
                            Lands.Add(item);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
Exemplo n.º 10
0
    IEnumerator GetLandsRequest(string url)
    {
        UnityWebRequest webRequest = UnityWebRequest.Get(url);

        yield return(webRequest.SendWebRequest());

        if (webRequest.isNetworkError || webRequest.isHttpError)
        {
            Debug.Log("Error: " + webRequest.error);
            yield break;
        }

        if (webRequest.downloadHandler.text == "")
        {
            Debug.Log("World has not been unlocked");
            yield break;
        }

        JSONNode rawJson = JSON.Parse(webRequest.downloadHandler.text);

        landListStr = "{\"listOfLands\":" + rawJson.ToString() + "}";
        Debug.Log("Land List:" + rawJson.ToString());

        landList = JsonUtility.FromJson <Lands>(landListStr);

        Map = new List <Land>();
        Debug.Log("count:" + landList.listOfLands.Count);
        standingOn = landList.listOfLands[0].landId;
        //if events.mode=="battle"/"duel"

        foreach (LandInfo landInfo in landList.listOfLands)
        {
            Land newLand = new Land();
            newLand.landNo = landInfo.ind;
            newLand.landId = landInfo.landId;
            newLand.level  = landInfo.ownerDifficultyLevel;
            worldId        = landInfo.worldId;

            if (landInfo.ownerId == userId)
            {
                newLand.iconSprite = iconSprites[0];//landOwnerOccupy
                newLand.status     = 0;
                //newLand.owner = landInfo.ownerName;
                newLand.difficulty = getDifficultyStr(landInfo.ownerDifficultyLevel);
            }
            else if (landInfo.ownerId == 0 && events.mode == "battle")
            {
                newLand.iconSprite = iconSprites[1];//land Own World Isolated
                newLand.status     = 1;
                //newLand.difficulty = "";
                //newLand.owner = landInfo.landId.ToString();
            }
            else if (landInfo.ownerId != 0 && landInfo.ownerId != userId)
            {
                newLand.iconSprite = iconSprites[2];//land Others Occupy
                newLand.status     = 2;
                newLand.owner      = "Occupied by " + landInfo.ownerName;
                newLand.difficulty = getDifficultyStr(landInfo.ownerDifficultyLevel);
            }
            else
            {
                newLand.iconSprite = iconSprites[3];//land Others World Isolated
                newLand.status     = 3;
                //newLand.difficulty = "";
            }
            Map.Add(newLand);
        }
        GenMap();
    }
Exemplo n.º 11
0
        private void RecalculatePositions()
        {
            if (IsPointingUp)
            {
                Land[] landsFromUpperLeftCorner =
                {
                    Lands[((int)RotateAngle / 120 + 0) % 3],
                    Lands[((int)RotateAngle / 120 + 1) % 3],
                    Lands[((int)RotateAngle / 120 + 2) % 3],
                };

                if (IsOnOddRow)
                {
                    landsFromUpperLeftCorner[0].X = CurrentPositionX + 1;
                    landsFromUpperLeftCorner[0].Y = CurrentPositionY - 1;

                    landsFromUpperLeftCorner[1].X = CurrentPositionX;
                    landsFromUpperLeftCorner[1].Y = CurrentPositionY;

                    landsFromUpperLeftCorner[2].X = CurrentPositionX + 1;
                    landsFromUpperLeftCorner[2].Y = CurrentPositionY;
                }
                else
                {
                    landsFromUpperLeftCorner[0].X = CurrentPositionX;
                    landsFromUpperLeftCorner[0].Y = CurrentPositionY - 1;

                    landsFromUpperLeftCorner[1].X = CurrentPositionX;
                    landsFromUpperLeftCorner[1].Y = CurrentPositionY;

                    landsFromUpperLeftCorner[2].X = CurrentPositionX + 1;
                    landsFromUpperLeftCorner[2].Y = CurrentPositionY;
                }
            }
            else
            {
                Land[] landsFromUpperLeftCorner =
                {
                    Lands[((int)RotateAngle / 120 + 1) % 3],
                    Lands[((int)RotateAngle / 120 + 0) % 3],
                    Lands[((int)RotateAngle / 120 + 2) % 3],
                };

                if (IsOnOddRow)
                {
                    landsFromUpperLeftCorner[0].X = CurrentPositionX;
                    landsFromUpperLeftCorner[0].Y = CurrentPositionY - 1;

                    landsFromUpperLeftCorner[1].X = CurrentPositionX + 1;
                    landsFromUpperLeftCorner[1].Y = CurrentPositionY - 1;

                    landsFromUpperLeftCorner[2].X = CurrentPositionX;
                    landsFromUpperLeftCorner[2].Y = CurrentPositionY;
                }
                else
                {
                    landsFromUpperLeftCorner[0].X = CurrentPositionX;
                    landsFromUpperLeftCorner[0].Y = CurrentPositionY - 1;

                    landsFromUpperLeftCorner[1].X = CurrentPositionX + 1;
                    landsFromUpperLeftCorner[1].Y = CurrentPositionY - 1;

                    landsFromUpperLeftCorner[2].X = CurrentPositionX + 1;
                    landsFromUpperLeftCorner[2].Y = CurrentPositionY;
                }
            }
            if (State != PlayingTileStateEnum.Passive)
            {
                //If there is no board tile under every land, PROBLEM
                if (Lands.Any(p => m_Board.BoardMatrix[p.X, p.Y] == null))
                {
                    State = PlayingTileStateEnum.ActiveProblem;
                }

                //If every land would be at the same level, it's a good start
                else if (Lands.Select(p => m_Board.BoardMatrix[p.X, p.Y].Lands.Count).Distinct().Count() == 1)
                {
                    //If spaces are empty under every land, there is a chance it would be good
                    if (Lands.All(p => !m_Board.BoardMatrix[p.X, p.Y].Lands.Any()))
                    {
                        // If this is the first tile, it's clearly CORRECT
                        if (m_Board.NbPlayingTiles == 1)
                        {
                            State = PlayingTileStateEnum.ActiveCorrect;
                        }

                        // If this is not the first tile, there are some placement rules
                        else
                        {
                            //We need to find at least 1 land that is touching one already on board
                            foreach (var p in Lands)
                            {
                                var pIsOnOddRow = p.Y % 2 == 0;
                                var points      = new List <Point>
                                {
                                    new Point(p.X - 1, p.Y),
                                    new Point(p.X + 1, p.Y),
                                    new Point(p.X, p.Y - 1),
                                    new Point(p.X, p.Y + 1),
                                    new Point(pIsOnOddRow ? p.X + 1 : p.X - 1, p.Y + 1),
                                    new Point(pIsOnOddRow ? p.X + 1 : p.X - 1, p.Y - 1),
                                };

                                //If there is one land already on board touching the land, CORRECT
                                if (points.Any(q => m_Board.BoardMatrix[(int)q.X, (int)q.Y] != null && m_Board.BoardMatrix[(int)q.X, (int)q.Y].Lands.Any()))
                                {
                                    State = PlayingTileStateEnum.ActiveCorrect;
                                    return;
                                }
                            }

                            //There was no land touching one already on the board, PROBLEM
                            State = PlayingTileStateEnum.ActiveProblem;
                        }
                    }

                    //There is same level land under each land, but they're all from the same tile, PROBLEM
                    else if (Lands.Select(p => m_Board.BoardMatrix[p.X, p.Y].Lands.Last().ParentTile).Distinct().Count() == 1)
                    {
                        State = PlayingTileStateEnum.ActiveProblem;
                    }

                    //There is same level land under each land, and they're not all from the same tile, it's a good start
                    else
                    {
                        // If volcano is over another volcano, CORRECT, or else it's a PROBLEM
                        State = m_Board.BoardMatrix[Volcano.X, Volcano.Y].Lands.Last().LandType == LandEnum.Volcano ? PlayingTileStateEnum.ActiveCorrect : PlayingTileStateEnum.ActiveProblem;
                    }
                }

                //All the lands are not at the same level, PROBLEM
                else
                {
                    State = PlayingTileStateEnum.ActiveProblem;
                }
            }
            PositionChanged();
        }
Exemplo n.º 12
0
 public new Board Clone()
 {
     return(new Board {
         Lands = Lands.Clone(), NonLands = NonLands.Clone()
     });
 }
Exemplo n.º 13
0
 public new Hand Clone()
 {
     return(new Hand {
         Lands = Lands.Clone(), NonLands = NonLands.Clone()
     });
 }