コード例 #1
0
    public void TriangulateAllCells()
    {
        // This method could be invoked at any time, even when cells have already been triangulated earlier.
        // So we should begin by clearing the old data.
        Terrain.Clear();
        Rivers.Clear();
        Roads.Clear();
        Water.Clear();
        WaterShore.Clear();
        Estuaries.Clear();
        Features.Clear();

        for (int i = 0; i < _cells.Length; i++)
        {
            Precalculation(_cells[i]);
        }

        for (int i = 0; i < _cells.Length; i++)
        {
            TriangulateCell(_cells[i]);
            AddFeatures(_cells[i]);
        }

        Terrain.Apply();
        Rivers.Apply();
        Roads.Apply();
        Water.Apply();
        WaterShore.Apply();
        Estuaries.Apply();
        Features.Apply();
    }
コード例 #2
0
        private void RefreshRoads()
        {
            Roads.Clear();

            foreach (var cell in CenteredCells)
            {
                RoadTriangulator.TriangulateRoads(cell, Roads);
            }

            Roads.Apply();

            TerrainBaker.BakeIntoChunk(this);
        }
コード例 #3
0
ファイル: PlayerGameModel.cs プロジェクト: joelong01/Catan
        public void Reset()
        {
            _islands                    = new Dictionary <Island, int>();
            Score                       = 0;
            KnightsPlayed               = 0;
            LongestRoad                 = 0;
            TimesTargeted               = 0;
            NoResourceCount             = 0;
            RollsWithResource           = 0;
            MaxNoResourceRolls          = 0;
            GoodRoll                    = false;
            CardsLost                   = 0;
            CardsLostToBaron            = 0;
            CardsLostToSeven            = 0;
            CardsLostToMonopoly         = 0;
            ResourcesAcquired           = 0;
            LargestArmy                 = false;
            HasLongestRoad              = false;
            RoadsPlayed                 = 0;
            ShipsPlayed                 = 0;
            CitiesPlayed                = 0;
            SettlementsPlayed           = 0;
            IslandsPlayed               = 0;
            TotalTime                   = TimeSpan.FromSeconds(0);
            MovedBaronAfterRollingSeven = null;
            PlayedKnightThisTurn        = false;
            Roads.Clear();
            Settlements.Clear();
            Cities.Clear();
            Ships.Clear();
            IsCurrentPlayer = false;
            MaxShips        = 0;
            MaxRoads        = 0;
            MaxSettlements  = 0;
            MaxCities       = 0;
            PlayerTurnResourceCount.OnPlayerResourceUpdate -= OnGameModelResourceUpdate;
            PlayerTurnResourceCount.GameReset();
            Pips       = 0;
            _GoldRolls = new List <List <int> >();

            for (int i = 0; i < _RoadTie.Count(); i++)
            {
                _RoadTie[i] = false;
            }
        }
コード例 #4
0
 /// <summary>
 /// Builds the mesh of the hex grid out of the provided array of cells.
 /// </summary>
 public void Triangulate()
 {
     Terrain.Clear();
     Rivers.Clear();
     Roads.Clear();
     Water.Clear();
     WaterShore.Clear();
     Estuaries.Clear();
     Features.Clear();
     for (int i = 0; i < Cells.Length; i++)
     {
         Triangulate(Cells[i]);
     }
     Terrain.Apply();
     Rivers.Apply();
     Roads.Apply();
     Water.Apply();
     WaterShore.Apply();
     Estuaries.Apply();
     Features.Apply();
 }
コード例 #5
0
ファイル: NetworkDataViewModel.cs プロジェクト: hodoje/hci
        // When we create a NetworkDataView view instance, a viewmodel of this type will be created, we will call it VM-1
        // When we instantiate the AddWindow window a new viewmodel of this type will be created, we will call it VM-2
        // Obviously, VM-1 and VM-2 will be different instances, so because of that there will be 2 different properties "Roads"
        // Although there are 2 properties, there is only one ROADS LIST we are using, and that's the "RoadsObs.Instance.Road" observable collection
        // Because of that, when we instantiate the NetworkDataView again, we will have the right elements in it
        // When we add an element via AddWindow, we change the "Roads" property of VM-2, not the VM-1, and because of that
        // NetworkDataView view will not be updated until we instantiate it again and read the data again from the deserialization
        public NetworkDataViewModel()
        {
            Roads.Clear();                                                                                          // We clear the list of the old elements
            if (serializer.DeSerializeObject <ObservableCollection <Road> >("roads.xml") != null)
            {
                serializer.DeSerializeObject <ObservableCollection <Road> >("roads.xml").ToList().ForEach(Roads.Add); // And then we deserialize the file holding a list of Roads
            }                                                                                                         // and add each element to the "Roads" property
                                                                                                                      // This LINQ expression is the same as if we manually did the foreach loop

            FilterCollection        = new CollectionViewSource();
            FilterCollection.Source = Roads;                                                                        // Sets the collection from which to create a view

            DeleteCommand  = new MyICommand(OnDelete, CanDelete);
            AddOpenCommand = new MyICommand(OnAddOpen);
            AddCommand     = new MyICommand(OnAdd);
            CancelCommand  = new MyICommand(OnCancel);
            FilterCommand  = new MyICommand(OnFilter);
            ClearCommand   = new MyICommand(OnClear);

            NotifiedVms.Instance.Register(this);
            //ovde registrujemo ovaj VM da bude u listi u singletonu i prosledimo this, a taj this implementira neki nas interfejs
        }
コード例 #6
0
        public void Triangulate(HexCell[] cells)
        {
            Terrain.Clear();
            Rivers.Clear();
            Roads.Clear();
            Water.Clear();
            WaterShore.Clear();
            Estuaries.Clear();
            Features.Clear();

            foreach (var cell in cells)
            {
                TriangulateCell(cell);
            }

            Terrain.Apply();
            Rivers.Apply();
            Roads.Apply();
            Water.Apply();
            WaterShore.Apply();
            Estuaries.Apply();
            Features.Apply();
        }