Esempio n. 1
0
        /// <summary>
        /// Received from the CityServer in response to a CITY_TOKEN packet.
        /// </summary>
        public static CityTransferStatus OnCityTokenResponse(NetworkClient Client, ProcessedPacket Packet)
        {
            LogThis.Log.LogThis("Received OnCityTokenResponse", LogThis.eloglevel.info);

            CityTransferStatus Status = (CityTransferStatus)Packet.ReadByte();

            ushort NumHouses = Packet.ReadUInt16();

            LotTileEntry[] TileEntries = new LotTileEntry[NumHouses];

            if (NumHouses > 0)
            {
                for (int i = 0; i < NumHouses; i++)
                {
                    TileEntries[i] = new LotTileEntry(Packet.ReadInt32(), Packet.ReadString(), (short)Packet.ReadUInt16(),
                                                      (short)Packet.ReadUInt16(), (byte)Packet.ReadByte(), Packet.ReadInt32());
                }
            }

            PlayerAccount.Money = Packet.ReadInt32();

            lock (GameFacade.CDataRetriever.LotTileData)
                GameFacade.CDataRetriever.LotTileData = TileEntries;

            return(Status);
        }
Esempio n. 2
0
 private void Controller_OnPlayerJoined(LotTileEntry TileEntry)
 {
     LotTileEntry[] TileEntries = new LotTileEntry[GameFacade.CDataRetriever.LotTileData.Length + 1];
     TileEntries[0] = TileEntry;
     GameFacade.CDataRetriever.LotTileData.CopyTo(TileEntries, 1);
     CityRenderer.populateCityLookup(TileEntries);
 }
Esempio n. 3
0
        void RefreshCity(BindingChange[] changes)
        {
            if (CurrentCity.Value != null)
            {
                var mapData = LotTileEntry.GenFromCity(CurrentCity.Value);

                //We know if lots are online, we can update the data service
                DataService.GetMany <Lot>(mapData.Select(x => (object)(uint)x.packed_pos).ToArray()).ContinueWith(x =>
                {
                    if (!x.IsCompleted)
                    {
                        return;
                    }

                    foreach (var lot in x.Result)
                    {
                        var mapItem = mapData.FirstOrDefault(y => y.packed_pos == lot.Id);
                        if (mapItem != null)
                        {
                            lot.Lot_IsOnline = (mapItem.flags & LotTileFlags.Online) == LotTileFlags.Online;
                        }
                    }
                });

                GameThread.NextUpdate((state) => View.populateCityLookup(mapData));
            }
        }
        public void _OnPlayerJoinedSession(NetworkClient Client, ProcessedPacket Packet)
        {
            LotTileEntry TileEntry = UIPacketHandlers.OnPlayerJoinedSession(Client, Packet);

            if (TileEntry.lotid != 0)
            {
                if (OnPlayerJoined != null)
                {
                    OnPlayerJoined(TileEntry);
                }
            }
        }
Esempio n. 5
0
        private void DrawSprites(SpriteBatch sbatch)
        {
            for (int i = 0; i < m_HousesData.LotTileData.Count; i++)
            {
                LotTileEntry lot = m_HousesData.LotTileData[i];

                // if (m_HousesData.HousesImages[i] != null)
                //   sbatch.Draw(m_HousesData.HousesImages[i], new Rectangle(lot.x, lot.y, 256, 256), Color.White);
            }

            //Draw2DPoly();
        }
        /// <summary>
        /// City server sent the cost of a lot.
        /// </summary>
        public void _OnLotCost(NetworkClient Client, ProcessedPacket Packet)
        {
            LotTileEntry Entry = UIPacketHandlers.OnLotCostResponse(Client, Packet);

            if (OnLotCost != null)
            {
                OnLotCost(Entry);
            }
            else
            {
                //TODO: Error handling...
            }
        }
        private void RefreshCity(BindingChange[] changes)
        {
            if (CurrentCity.Value != null)
            {
                var mapData   = LotTileEntry.GenFromCity(CurrentCity.Value);
                var neighJSON = CurrentCity.Value.City_NeighJSON;

                //We know if lots are online, we can update the data service
                DataService.GetMany <Lot>(mapData.Select(x => (object)(uint)x.packed_pos).ToArray()).ContinueWith(x =>
                {
                    if (!x.IsCompleted)
                    {
                        return;
                    }

                    foreach (var lot in x.Result)
                    {
                        var mapItem = mapData.FirstOrDefault(y => y.packed_pos == lot.Id);
                        if (mapItem != null)
                        {
                            lot.Lot_IsOnline = (mapItem.flags & LotTileFlags.Online) == LotTileFlags.Online;
                        }
                    }
                });

                GameThread.NextUpdate((state) => {
                    View.populateCityLookup(mapData);
                    if (neighJSON != LastLotJSON)
                    {
                        try
                        {
                            var neigh = JsonConvert.DeserializeObject <List <Rendering.City.Model.CityNeighbourhood> >(neighJSON);
                            Rendering.City.Model.CityNeighbourhood.Init(neigh);
                            View.NeighGeom.Data = neigh;
                            View.NeighGeom.Generate(GameFacade.GraphicsDevice);
                        } catch
                        {
                        }

                        LastLotJSON = neighJSON;
                    }
                });
            }
        }
Esempio n. 8
0
        /// <summary>
        /// A player joined a session (game) in progress.
        /// </summary>
        public static LotTileEntry OnPlayerJoinedSession(NetworkClient Client, ProcessedPacket Packet)
        {
            LotTileEntry TileEntry = new LotTileEntry(0, "", 0, 0, 0, 0);

            UISim Avatar = new UISim(Packet.ReadString());

            Avatar.Name              = Packet.ReadString();
            Avatar.Sex               = Packet.ReadString();
            Avatar.Description       = Packet.ReadString();
            Avatar.HeadOutfitID      = Packet.ReadUInt64();
            Avatar.BodyOutfitID      = Packet.ReadUInt64();
            Avatar.Avatar.Appearance = (AppearanceType)Packet.ReadInt32();

            byte HasHouse = (byte)Packet.ReadByte();

            if (HasHouse != 0)
            {
                TileEntry = new LotTileEntry(Packet.ReadInt32(), Packet.ReadString(), (short)Packet.ReadUInt16(),
                                             (short)Packet.ReadUInt16(), (byte)Packet.ReadByte(), Packet.ReadInt32());

                Avatar.LotID  = TileEntry.lotid;
                Avatar.HouseX = TileEntry.x;
                Avatar.HouseY = TileEntry.y;

                LotTileEntry[] TileEntries = new LotTileEntry[GameFacade.CDataRetriever.LotTileData.Length + 1];
                TileEntries[0] = TileEntry;
                GameFacade.CDataRetriever.LotTileData.CopyTo(TileEntries, 1);
            }

            lock (NetworkFacade.AvatarsInSession)
            {
                NetworkFacade.AvatarsInSession.Add(Avatar);
            }

            return(TileEntry);
        }
Esempio n. 9
0
        /// <summary>
        /// Received CharacterCreation packet from CityServer.
        /// </summary>
        /// <returns>The result of the character creation.</returns>
        public static CharacterCreationStatus OnCharacterCreationStatus(NetworkClient Client, ProcessedPacket Packet)
        {
            LogThis.Log.LogThis("Received OnCharacterCreationStatus!", LogThis.eloglevel.info);

            CharacterCreationStatus CCStatus = (CharacterCreationStatus)Packet.ReadByte();

            ushort NumHouses = Packet.ReadUInt16();

            LotTileEntry[] TileEntries = new LotTileEntry[NumHouses];

            if (NumHouses > 0)
            {
                for (int i = 0; i < NumHouses; i++)
                {
                    TileEntries[i] = new LotTileEntry(Packet.ReadInt32(), Packet.ReadString(), (short)Packet.ReadUInt16(),
                                                      (short)Packet.ReadUInt16(), (byte)Packet.ReadByte(), Packet.ReadInt32());
                }
            }

            lock (GameFacade.CDataRetriever.LotTileData)
                GameFacade.CDataRetriever.LotTileData = TileEntries;

            return(CCStatus);
        }
 private void Controller_OnPlayerJoined(LotTileEntry TileEntry)
 {
 }
Esempio n. 11
0
        public override void Update(UpdateState state)
        {
            if (Visible)
            {  //if we're not visible, do not update CityRenderer state...
                CoreGameScreen CurrentUIScr = (CoreGameScreen)GameFacade.Screens.CurrentUIScreen;

                m_LastMouseState = m_MouseState;
                m_MouseState     = Mouse.GetState();

                m_MouseMove = (m_MouseState.RightButton == ButtonState.Pressed);

                if (m_HandleMouse)
                {
                    if (m_MouseState.RightButton == ButtonState.Pressed && m_LastMouseState.RightButton == ButtonState.Released)
                    {
                        m_MouseStart = new Vector2(m_MouseState.X, m_MouseState.Y);  //if middle mouse button activated, record where we started pressing it (to use for panning)
                    }

                    else if (m_MouseState.LeftButton == ButtonState.Released && m_LastMouseState.LeftButton == ButtonState.Pressed)  //if clicked...
                    {
                        if (!m_Zoomed)
                        {
                            m_Zoomed = true;
                            double ResScale = 768.0 / m_ScrHeight;
                            double isoScale = (Math.Sqrt(0.5 * 0.5 * 2) / 5.10) * ResScale;
                            double hb       = m_ScrWidth * isoScale;
                            double vb       = m_ScrHeight * isoScale;

                            m_TargVOffX = (float)(-hb + m_MouseState.X * isoScale * 2);
                            m_TargVOffY = (float)(vb - m_MouseState.Y * isoScale * 2);  //zoom into approximate location of mouse cursor if not zoomed already
                        }
                        else
                        {
                            if (m_SelTile[0] != -1 && m_SelTile[1] != -1)
                            {
                                m_SelTileTmp[0] = m_SelTile[0];
                                m_SelTileTmp[1] = m_SelTile[1];

                                UIAlertOptions AlertCoords = new UIAlertOptions();
                                AlertCoords.Title = GameFacade.Strings.GetString("246", "1");
                                //AlertOptions.Message = GameFacade.Strings.GetString("215", "23", new string[]
                                //{ m_LotCost.ToString(), CurrentUIScr.ucp.MoneyText.Caption });

                                AlertCoords.Message = m_SelTile[0].ToString() + " " + m_SelTile[1].ToString();


                                foreach (LotTileEntry Lot in m_HousesData.LotTileData)
                                {
                                    if (Lot.x == m_SelTile[0] && Lot.y == m_SelTile[1])
                                    {
                                        m_CurrentLot = Lot;
                                    }
                                }


                                if (m_CurrentLot != null)
                                {
                                    UIAlertOptions AlertOptions = new UIAlertOptions();
                                    AlertOptions.Title = GameFacade.Strings.GetString("246", "1");
                                    //AlertOptions.Message = GameFacade.Strings.GetString("215", "23", new string[]
                                    //{ m_LotCost.ToString(), CurrentUIScr.ucp.MoneyText.Caption });

                                    AlertOptions.Message = m_CurrentLot.x.ToString() + " " + m_CurrentLot.y.ToString();
                                    //AlertOptions.Buttons = UIAlertButtons.YesNo;
                                }
                            }
                        }

                        CurrentUIScr.ucp.UpdateZoomButton();
                    }
                }
                else
                {
                    m_SelTile = new int[] { -1, -1 };
                }

                GameTime time = new GameTime();

                m_SecondsBehind += time.ElapsedGameTime.TotalSeconds;
                m_SecondsBehind -= 1 / 60;
                SetTimeOfDay(m_DayNightCycle % 1); //calculates sun/moon light colour and position
                m_DayNightCycle += 0.001;          //adjust the cycle speed here. When ingame, set m_DayNightCycle to to the percentage of time passed through the day. (0 to 1)

                m_ViewOffX = (m_TargVOffX) * m_ZoomProgress;
                m_ViewOffY = (m_TargVOffY) * m_ZoomProgress;
            }
        }