예제 #1
0
        /// <summary>
        /// On change methode for when the players table changes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnChange_Players(object sender, SqlNotificationEventArgs e)
        {
            SqlDependency dependency = sender as SqlDependency;

            dependency.OnChange -= OnChange_Players;

            // Need to update the correct field, not players in this class
            MainClient.ReadOtherPlayers();
            localresources = MainClient.GetLocalResources();

            DatabaseInterface.MonitorPlayers(OnChange_Players);
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            playerName.InnerText = MainClient.player.Name;
            goldAmount.InnerText = "You have " + MainClient.player.Gold + " pieces of gold";

            if (!Page.IsPostBack)
            {
                localresources  = new List <LocalResource>();
                marketresources = new List <ResourceOffer>();



                MainClient.SetupDatabaseListeners(OnChange_Players, OnChange_ResourceOffer,
                                                  OnChange_TradeOffer, OnChange_Chat);
            }
            //RegisterAsyncTask(new PageAsyncTask(GetResourceOfferEvent));
            //Load data into allOtherPlayers list
            MainClient.ReadOtherPlayers();

            Player1 = MainClient.allOtherPlayers[0];
            player1Tab.InnerText = Player1.Name;

            Player2 = MainClient.allOtherPlayers[1];
            player2Tab.InnerText = Player2.Name;

            Player3 = MainClient.allOtherPlayers[2];
            player3Tab.InnerText = Player3.Name;

            List <string> names = new List <string>();

            foreach (Player player in MainClient.allOtherPlayers)
            {
                if (player.Name != "Server")
                {
                    names.Add(player.Name);
                }
            }
            tradeOfferReceiver.DataSource = names;
            tradeOfferReceiver.DataBind();

            allYourRecievedTradeOffers = MainClient.ReadAllTradeOffersForYou();
            fillTradeOffers();
            RenderTradeOffers();
            //createTradeOfferElements();

            RenderMarket();
            RenderLocalResources();
            RenderChat();
            if (MainClient.player.Name == "Alex")
            {
                MainServer.initGame();
            }
            if (!MainClient.incomeTimerHasBeenSet)
            {
                MainClient.incomeHandler();
            }
            //if (!hasGottenMission)
            //{
            //    hasGottenMission = true;
            //    MainClient.GiveMission();
            //}
        }