Esempio n. 1
0
 public GameDataGenerator(GameDataClass classToGenerate, string folderPath)
 {
     this._class = classToGenerate;
     InitializePrimitiveType();
     Generate();
     GeneratorUtility.GenerateCode(new CSharpCodeProvider(), _codeBase, folderPath + "\\" + _class.ClassName + ".cs");
 }
Esempio n. 2
0
 public GameDataParser(string filePath, string directory)
 {
     mOutputClass          = new GameDataClass();
     mOutputClass.BasePath = directory;
     mReader           = new StreamReader(filePath);
     mOutputClass.Path = filePath;
     Parse();
 }
Esempio n. 3
0
        public string ConnectToGame(string PlayerName, string PlayerID)
        {
            PlayerClass temp = new PlayerClass()
            {
                PlayerName = PlayerName, PlayerID = PlayerID
            };

            List <PlayerClass> playerList = JsonConvert.DeserializeObject <List <PlayerClass> >(System.IO.File.ReadAllText(System.IO.Path.Combine(_env.WebRootPath, "Players.json")));

            if (playerList == null)
            {
                playerList = new List <PlayerClass>();
                playerList.Add(temp);


                string edata = JsonConvert.SerializeObject(playerList);
                System.IO.File.WriteAllText(System.IO.Path.Combine(_env.WebRootPath, "Players.json"), edata);


                GameDataClass tempPlayer1 = new GameDataClass()
                {
                    MyName = temp.PlayerName, MyID = temp.PlayerID, OpponentName = temp.PlayerName, OpponentID = temp.PlayerID, IfClicked = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, SymbolPresent = new string[] { "b", "b", "b", "b", "b", "b", "b", "b", "b" }, Turn = "Mine", MySymbol = "X", OpponentSymbol = "O", IfConnected = "False", Status = "Wait", IfAlive = "False", IfQuit = "False"
                };
                string gamedataPlayer1 = JsonConvert.SerializeObject(tempPlayer1);
                System.IO.File.WriteAllText(System.IO.Path.Combine(_env.WebRootPath, temp.PlayerID + ".json"), gamedataPlayer1);
                return("WaitingForPlayer");
            }
            else
            {
                var Player1 = playerList.LastOrDefault();
                var Player2 = temp;


                System.IO.File.Delete(System.IO.Path.Combine(_env.WebRootPath, "Players.json"));
                System.IO.File.WriteAllText(System.IO.Path.Combine(_env.WebRootPath, "Players.json"), "");


                GameDataClass tempPlayer1 = new GameDataClass()
                {
                    MyName = Player1.PlayerName, MyID = Player1.PlayerID, OpponentName = Player2.PlayerName, OpponentID = Player2.PlayerID, IfClicked = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, SymbolPresent = new string[] { "b", "b", "b", "b", "b", "b", "b", "b", "b" }, Turn = "Mine", MySymbol = "X", OpponentSymbol = "O", IfConnected = "True", Status = "Wait", IfAlive = "False", IfQuit = "False"
                };
                GameDataClass tempPlayer2 = new GameDataClass()
                {
                    OpponentName = Player1.PlayerName, OpponentID = Player1.PlayerID, MyName = Player2.PlayerName, MyID = Player2.PlayerID, IfClicked = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, SymbolPresent = new string[] { "b", "b", "b", "b", "b", "b", "b", "b", "b" }, Turn = "Opponent", OpponentSymbol = "X", MySymbol = "O", IfConnected = "True", Status = "Wait", IfAlive = "True", IfQuit = "False"
                };


                string gamedataPlayer1 = JsonConvert.SerializeObject(tempPlayer1);
                System.IO.File.Delete(System.IO.Path.Combine(_env.WebRootPath, Player1.PlayerID + ".json"));
                System.IO.File.WriteAllText(System.IO.Path.Combine(_env.WebRootPath, Player1.PlayerID + ".json"), gamedataPlayer1);



                string gamedataPlayer2 = JsonConvert.SerializeObject(tempPlayer2);
                System.IO.File.WriteAllText(System.IO.Path.Combine(_env.WebRootPath, temp.PlayerID + ".json"), gamedataPlayer2);
                return("WaitingForPlayer");
            }
        }
Esempio n. 4
0
    IEnumerator LoadConfigValues()
    {
        TextAsset TA = Resources.Load("GameDataConfig") as TextAsset;

        yield return(TA);

        Debug.Log(TA.text);
        if (TA != null)
        {
            Debug.Log("Starting");
            GDC = JsonUtility.FromJson <GameDataClass>(TA.text);
            yield return(GDC);

            Debug.Log("Finishing");
            Debug.Log(JsonUtility.ToJson(GDC));
        }
    }
        private async Task CheckStatus()
        {
            string      url = "http://tictactoe.sudeshkumar.me/Android/CheckStatus";
            HttpContent q1  = new FormUrlEncodedContent(new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("ID", Application.Current.Properties["ID"] as string)
            });

            using (var httpClient = new HttpClient())
            {
                try
                {
                    Task <HttpResponseMessage> getResponse = httpClient.PostAsync(url, q1);
                    HttpResponseMessage        response    = await getResponse;
                    if (response.IsSuccessStatusCode)
                    {
                        var myContent = await response.Content.ReadAsStringAsync();

                        OnlineGameData = JsonConvert.DeserializeObject <GameDataClass>(myContent);
                    }
                    else
                    {
                        Device.BeginInvokeOnMainThread(async() =>
                        {
                            var result = await this.DisplayAlert("Errr!!", "Connection With Server Lost", "Okay", " ");
                            if (result)
                            {
                                await this.Navigation.PopAsync();
                            }
                        });
                    }
                }
                catch (Exception)
                {
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        var result = await this.DisplayAlert("Errr!!", "Connection With Server Lost", "Okay", " ");
                        if (result)
                        {
                            await this.Navigation.PopAsync();
                        }
                    });
                    return;
                }
            }
        }
Esempio n. 6
0
    public override void OnEnterStatus()
    {
        base.OnEnterStatus();

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

        list.Add("lizhu");
        list.Add("tuying");
        list.Add("luorui");


        GameDataClass gameDataObj = new GameDataClass();

        gameDataObj.list = list;
        GameDataMonitor.PushData("GameDataClass", gameDataObj);

        NetworkManager.Init <ProtocolService>();
        NetworkManager.SetServer("127.0.0.1", 2012);
        NetworkManager.Connect();

        ProtocolAnalysisService.Init();

        GlobalEvent.AddTypeEvent <role_login_c>(Recevice);
    }
        private async void ReturnMyData()
        {
            string      url = "http://tictactoe.sudeshkumar.me/Android/ReturnMyData";
            HttpContent q1  = new FormUrlEncodedContent(new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("ID", Application.Current.Properties["ID"] as string)
            });

            using (var httpClient = new HttpClient())
            {
                try
                {
                    Task <HttpResponseMessage> getResponse = httpClient.PostAsync(url, q1);
                    HttpResponseMessage        response    = await getResponse;
                    if (response.IsSuccessStatusCode)
                    {
                        var myContent = await response.Content.ReadAsStringAsync();

                        if (myContent == "False")
                        {
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                LoadingIndicator.IsVisible = false;
                                LoadingIndicatorText.Text  = "Can't Connect To Server";
                                quitButton.Text            = "Go Back";
                                quitButton.IsVisible       = true;
                            });
                        }
                        else
                        {
                            OnlineGameData = JsonConvert.DeserializeObject <GameDataClass>(myContent);
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                GameViewModel.OpponentName = OnlineGameData.OpponentName;
                                GameViewModel.PlayerSymbol = OnlineGameData.MySymbol[0];
                                if (GameViewModel.PlayerSymbol == 'X')
                                {
                                    GameViewModel.OpponentSymbol = 'O';
                                }
                                else
                                {
                                    GameViewModel.OpponentSymbol = 'X';
                                }
                                j.InvalidateSurface();
                                k.InvalidateSurface();
                                OpponentNameLabel.Text     = GameViewModel.OpponentName + "'s Turn";
                                LoadingIndicator.IsVisible = false;
                                LoadingIndicatorText.Text  = "";
                                quitButton.Text            = "Play";
                                quitButton.IsVisible       = true;
                            });
                        }
                    }
                    else
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            LoadingIndicatorText.Text = "Can't Connect To Server";
                            quitButton.Text           = "Go Back";
                            quitButton.IsVisible      = true;
                        });
                    }
                }
                catch (Exception)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        LoadingIndicatorText.Text = "Can't Connect To Server";
                        quitButton.Text           = "Go Back";
                        quitButton.IsVisible      = true;
                    });
                    return;
                }
            }
        }
Esempio n. 8
0
 public void LoadData(ref GameDataClass playerData)
 {
     FileManager.ReadFromBinaryFile(ref playerData);
 }
Esempio n. 9
0
 //Save and Load Player Data Functions
 public void SaveData(GameDataClass playerData)
 {
     FileManager.WriteToBinaryFile(playerData, false);
 }
Esempio n. 10
0
        public IActionResult Index(string PlayerName)
        {
            if (PlayerName == null)
            {
                ViewBag.Warning = "Dude! A Cool name is all we are asking";
                return(View());
            }

            PlayerClass temp = new PlayerClass()
            {
                PlayerName = PlayerName, PlayerID = DateTime.Now.Ticks.ToString()
            };

            List <PlayerClass> playerList = JsonConvert.DeserializeObject <List <PlayerClass> >(System.IO.File.ReadAllText(System.IO.Path.Combine(_env.WebRootPath, "Players.json")));

            if (playerList == null)
            {
                playerList = new List <PlayerClass>();
                playerList.Add(temp);


                string edata = JsonConvert.SerializeObject(playerList);
                System.IO.File.WriteAllText(System.IO.Path.Combine(_env.WebRootPath, "Players.json"), edata);


                GameDataClass tempPlayer1 = new GameDataClass()
                {
                    MyName = temp.PlayerName, MyID = temp.PlayerID, OpponentName = temp.PlayerName, OpponentID = temp.PlayerID, IfClicked = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, SymbolPresent = new string[] { "b", "b", "b", "b", "b", "b", "b", "b", "b" }, Turn = "Mine", MySymbol = "X", OpponentSymbol = "O", IfConnected = "False", Status = "Wait", IfAlive = "False", IfQuit = "False"
                };
                string gamedataPlayer1 = JsonConvert.SerializeObject(tempPlayer1);
                System.IO.File.WriteAllText(System.IO.Path.Combine(_env.WebRootPath, temp.PlayerID + ".json"), gamedataPlayer1);



                ViewBag.PlayerName  = temp.PlayerName;
                ViewBag.PlayerID    = temp.PlayerID.ToString();
                ViewBag.IfConnected = "False";
                return(View("WaitingForPlayer"));
            }
            else
            {
                var Player1 = playerList.LastOrDefault();
                var Player2 = temp;


                System.IO.File.Delete(System.IO.Path.Combine(_env.WebRootPath, "Players.json"));
                System.IO.File.WriteAllText(System.IO.Path.Combine(_env.WebRootPath, "Players.json"), "");


                GameDataClass tempPlayer1 = new GameDataClass()
                {
                    MyName = Player1.PlayerName, MyID = Player1.PlayerID, OpponentName = Player2.PlayerName, OpponentID = Player2.PlayerID, IfClicked = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, SymbolPresent = new string[] { "b", "b", "b", "b", "b", "b", "b", "b", "b" }, Turn = "Mine", MySymbol = "X", OpponentSymbol = "O", IfConnected = "True", Status = "Wait", IfAlive = "False", IfQuit = "False"
                };
                GameDataClass tempPlayer2 = new GameDataClass()
                {
                    OpponentName = Player1.PlayerName, OpponentID = Player1.PlayerID, MyName = Player2.PlayerName, MyID = Player2.PlayerID, IfClicked = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, SymbolPresent = new string[] { "b", "b", "b", "b", "b", "b", "b", "b", "b" }, Turn = "Opponent", OpponentSymbol = "X", MySymbol = "O", IfConnected = "True", Status = "Wait", IfAlive = "True", IfQuit = "False"
                };


                string gamedataPlayer1 = JsonConvert.SerializeObject(tempPlayer1);
                System.IO.File.Delete(System.IO.Path.Combine(_env.WebRootPath, Player1.PlayerID + ".json"));
                System.IO.File.WriteAllText(System.IO.Path.Combine(_env.WebRootPath, Player1.PlayerID + ".json"), gamedataPlayer1);



                string gamedataPlayer2 = JsonConvert.SerializeObject(tempPlayer2);
                System.IO.File.WriteAllText(System.IO.Path.Combine(_env.WebRootPath, temp.PlayerID + ".json"), gamedataPlayer2);


                ViewBag.PlayerName  = temp.PlayerName;
                ViewBag.PlayerID    = temp.PlayerID.ToString();
                ViewBag.IfConnected = "True";
                return(View("WaitingForPlayer"));
            }
        }