static void Main(string[] args) { Durango d = new Durango(); d.Boxer(); playerInfo playerOne = new playerInfo(); playerInfo playerTwo = new playerInfo(); char[,] board = new char[9, 10]; int dropChoice, win, full, again; Console.WriteLine("Let's Play Connect 4"); Console.WriteLine("Player One please enter your name: "); playerOne.playerName = Console.ReadLine(); playerOne.playerID = 'X'; Console.WriteLine("Player Two please enter your name: "); playerTwo.playerName = Console.ReadLine(); playerTwo.playerID = 'O'; full = 0; win = 0; again = 0; DisplayBoard(board); do { dropChoice = PlayerDrop(board, playerOne); CheckBellow(board, playerOne, dropChoice); DisplayBoard(board); win = CheckFour(board, playerOne); if (win == 1) { PlayerWin(playerOne); again = restart(board); if (again == 2) { break; } } dropChoice = PlayerDrop(board, playerTwo); CheckBellow(board, playerTwo, dropChoice); DisplayBoard(board); win = CheckFour(board, playerTwo); if (win == 1) { PlayerWin(playerTwo); again = restart(board); if (again == 2) { break; } } full = FullBoard(board); if (full == 7) { Console.WriteLine("The board is full, it is a draw!"); again = restart(board); } } while (again != 2); }
IEnumerator Addplayer_json(playerInfo playerInfo) { string url = "http://" + WebserverIP + "/" + create_webname; WWWForm form = new WWWForm(); form.AddField("playerinfo", playerdate_to_json(playerInfo)); var www = UnityWebRequest.Post(url, form); yield return(www.Send()); //接收新增的回傳資料 string str_temp = www.downloadHandler.text; int errorNumber; if (int.TryParse(str_temp, out errorNumber)) { Get_db_logerror(errorNumber); PlayerManager.set_mainPlayer(null); yield break; } else { PlayerManager.set_mainPlayer(JsonConvert.DeserializeObject <playerInfo>(www.downloadHandler.text)); } GetSessionID(www.GetResponseHeaders()); //得到WEBserver的SESSION表頭黨 PlayerManager.set_Board(); Grid.getGrid.LoadFile(); PlayerManager.SavePlayerInfo_Local(PlayerManager.get_main_playerInfo()); }
private void Start() { playerinfo = new playerInfo(); Positions = new List <Vector3>(); InvokeRepeating("RecordPosition", 0, positionInterval); InvokeRepeating("RecordTime", 0, 1); }
void initGameState_Playing() { //隐藏退出和就位等按钮 readyBtn.gameObject.SetActive(false); leaveBtn.gameObject.SetActive(false); changeRoomBtn.gameObject.SetActive(false); //显示麻将剩余数量 numOfMJText.text = room.public_roomInfo.numOfMJ + ""; print("庄家索引是" + room.public_roomInfo.button); print(room.public_roomInfo.playerInfo[1].userId + " 玩家手牌数量==" + room.public_roomInfo.playerInfo[1].holdsCount); //初始化打出牌,碰、杠、胡牌 for (int i = 0; i < room.public_roomInfo.playerInfo.Count; i++) { PLAYER_PUBLIC_INFO pb = room.public_roomInfo.playerInfo[i]; playerInfo pi = GetPlayerInfoByServerIndex(i); realyPlayer.Add(pi); //按照房间人数安排的玩家列表 pi.initSeat(i); pi.upDataHandCards(); //初始化手中牌 pi.upDataFlodsCard(); //更新打出的牌 pi.upDataPengCard(); //更新碰的牌 pi.upDataGangCard(); //更新杠的牌 } //处理正在打出的牌 int chuPai = room.public_roomInfo.chuPai; if (chuPai != -1) { GetPlayerInfoByServerIndex(room.public_roomInfo.turn).showChuPai(chuPai); } foreach (PLAYER_PUBLIC_INFO pb in room.public_roomInfo.playerInfo) { } }
void LoadJsonData() { playerInfo data = null; string jdata = File.ReadAllText(Application.persistentDataPath + "/Json/save.json"); if (jdata != null) { data = JsonConvert.DeserializeObject <playerInfo>(jdata); } if (data != null) { MaxScore = data.MaxScore; MyFirstItemNum = data.MyFirstItemNum; MySecondItemNum = data.MySecondItemNum; MyGold = data.MyGold; MyStamina = data.MyStamina; MyStaminaTime = data.MyStaminaTime; SaveDateTime = data.SaveDateTime; } else { MaxScore = 0; MyFirstItemNum = 0; MySecondItemNum = 0; MyGold = 0; MyStamina = 5; MyStaminaTime = 60; SaveDateTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")); } }
//client connect to server ,called on server public override void OnServerConnect(NetworkConnection conn) { base.OnServerConnect(conn); Transform start; playerInfo playerInfo = new playerInfo(); Debug.Log(numPlayers); if (numPlayers % 2 == 0) { playerInfo.teamColor = "Archer Warrior Red"; playerInfo.teamtype = false; start = redStartPosition; } else { playerInfo.teamColor = "Archer Warrior Blue"; playerInfo.teamtype = true; start = blueStartPosition; } GameObject player = Instantiate(spawnPrefabs.Find(prefab => prefab.name == playerInfo.teamColor), start.position, start.rotation); NetworkServer.AddPlayerForConnection(conn, player); playerInfo.player = player; conn.Send(playerInfo); Debug.Log("send player info to client"); }
public Save(List <GameObject> ammos, List <GameObject> doors, List <GameObject> vents, List <GameObject> matchThreeObjects, List <GameObject> tutorials, GameObject character) { foreach (GameObject obj in ammos) { ammoInfos.Add(new ammoInfo(obj.GetComponent <PickupAmmoInteraction>())); } foreach (GameObject obj in matchThreeObjects) { matchThreeObjectInfos.Add(new matchThreeObjectInfo(obj.GetComponent <MatchThreeObject>())); } foreach (GameObject obj in tutorials) { tutorialInfos.Add(new tutorialInfo(obj.GetComponent <Tutorial>())); } foreach (GameObject obj in doors) { doorInfos.Add(new doorInfo(obj.GetComponent <DoorInteraction>())); } foreach (GameObject obj in vents) { DoorInteraction vent = obj.GetComponentInChildren <DoorInteraction>(); doorInfos.Add(new doorInfo(vent.transform.parent.name, vent.isOpen, vent.isLocked)); } player = new playerInfo(character.GetComponent <MyCharacterController>()); }
public void login_player(playerInfo info) { if (!IsWebserverOn) { return; } StartCoroutine(Login_json(info)); }
public void create_player(playerInfo info) { if (!IsWebserverOn) { return; } StartCoroutine(Addplayer_json(info)); }
// Start is called before the first frame update void Start() { if (info == null) { info = GameObject.Find("PlayerInfo").GetComponent <playerInfo>(); } FindStats(); }
public void update_highscore(playerInfo info) { if (!IsWebserverOn) { return; } StartCoroutine(UpdateHighscore_json(info)); }
public static void readSave(Save save) { //Clear existing objects ClearMatchThreeObjects(); ClearAmmoObjects(); DestroyCharacter(); //Create Player playerInfo playerInfo = save.player; player = Instantiate(CharacterObject).GetComponent <MyCharacterController>(); player.transform.position = playerInfo.position.GetPosition(); Vector3 orientation = playerInfo.orientation.GetOrientation(); player.my_camera.GetComponent <camMouseLook>().Look(orientation); player.SetCrouchState(playerInfo.crouched, true); player.health = playerInfo.health; GunController gunController = player.my_pickup.gunController; for (int i = 0; i < playerInfo.ammo.Length; ++i) { gunController.arsenal[i].gun.ammo = playerInfo.ammo[i]; gunController.arsenal[i].is_in_arsenal = playerInfo.inArse[i]; } gunController.equip_gun((GunController.gun_type)playerInfo.equip); //Create Match Threes foreach (matchThreeObjectInfo obj in save.matchThreeObjectInfos) { GameObject newObj = Instantiate(matchThreeObjectTypes.types[obj.type], GameObject.Find(obj.room).transform); MatchThreeObject newObjM3 = newObj.GetComponent <MatchThreeObject>(); newObj.name = obj.name; newObj.transform.position = obj.position.GetPosition(); newObjM3.match3_group_id = (MatchThreeObject.match3_group_id_names)obj.group; newObjM3.apply_color(); } //Create Ammo Pickups foreach (ammoInfo obj in save.ammoInfos) { GameObject newObj = Instantiate(AmmoObject); PickupAmmoInteraction newObjAmmo = newObj.GetComponent <PickupAmmoInteraction>(); newObj.name = obj.name; newObj.transform.position = obj.position.GetPosition(); newObj.transform.eulerAngles = obj.rotation.GetOrientation(); newObjAmmo.gun = (GunController.gun_type)obj.type; newObjAmmo.amount = obj.amount; } //Set Door Parameters foreach (doorInfo obj in save.doorInfos) { DoorInteraction door = GameObject.Find(obj.name).GetComponentInChildren <DoorInteraction>(); door.twistLock(obj.locked); door.swingDoor(obj.open, false); } //Temporary code for setting references foreach (GameObject tutorial in tutorials) { tutorial.GetComponent <Tutorial>().GetUIComponents(player.gameObject); } }
public override void ClickAction() { playerInfo temp = new playerInfo(PlayerManager.In_Account.text, PlayerManager.In_Passwd.text); if (PlayerManager.check_playerInfoFormat_right(temp)) { PlayerManager.create_player(temp); } }
private void button1_Click(object sender, EventArgs e) { //another attempt to save player names playerInfo player1 = new playerInfo(); playerInfo player2 = new playerInfo(); textBox1.Text = player1.playerName; textBox2.Text = player2.playerName; }
static int CheckFour(char[,] board, playerInfo activePlayer) { char XO; int win; XO = activePlayer.playerID; win = 0; for (int i = 8; i >= 1; --i) { for (int ix = 9; ix >= 1; --ix) { if (board[i, ix] == XO && board[i - 1, ix - 1] == XO && board[i - 2, ix - 2] == XO && board[i - 3, ix - 3] == XO) { win = 1; } if (board[i, ix] == XO && board[i, ix - 1] == XO && board[i, ix - 2] == XO && board[i, ix - 3] == XO) { win = 1; } if (board[i, ix] == XO && board[i - 1, ix] == XO && board[i - 2, ix] == XO && board[i - 3, ix] == XO) { win = 1; } if (board[i, ix] == XO && board[i - 1, ix + 1] == XO && board[i - 2, ix + 2] == XO && board[i - 3, ix + 3] == XO) { win = 1; } if (board[i, ix] == XO && board[i, ix + 1] == XO && board[i, ix + 2] == XO && board[i, ix + 3] == XO) { win = 1; } } } return(win); }
void OnTriggerEnter(Collider other) { playerInfo player = other.GetComponent <playerInfo>(); if (player != null) { player.Hurt(damageNum); } Destroy(this.gameObject); }
private void SetLeaderBoard(LeaderBoard lb) { for (int i = 0; i < lb.leaderboard.Count; i++) { playerInfo playerInfo = lb.leaderboard [i]; Rank.text += (i + 1).ToString() + "\n"; Name.text += playerInfo.name + "\n"; Score.text += playerInfo.score.ToString() + "\n"; // Debug.Log (playerInfo.name + ": " + playerInfo.score); } }
void UpdateShow() { playerInfo info = playerInfo._instance; HeadSprite.spriteName = info.HeadPortrait; Label_level.text = info.Level.ToString(); Label_name.text = info.Name; Energyslider.value = info.Energy / 100f; LabelEnergy.text = info.Energy + "/100"; Toughenslider.value = info.Toughen / 50f; LabelToughen.text = info.Toughen + "/50"; }
// Start is called before the first frame update void Start() { if (player == null) { player = GameObject.Find("player").GetComponent <playerController>(); } if (info == null) { info = GameObject.Find("PlayerInfo").GetComponent <playerInfo>(); } StartCoroutine(moveEnemy()); }
playerInfo[] getPlayersInfo() { playerInfo[] ret = new playerInfo[players.Length]; int i = 0; foreach (GameObject player in players) { ret[i] = new playerInfo(player.transform.position.x, player.transform.position.y, player.GetComponent <PlayerControl>().Grounded, player.GetComponent <PlayerControl>().Dead, player.GetComponent <PlayerControl>().id); i++; } return(ret); }
public void SaveJsonData() { data = new playerInfo(data.score, data.MaxScore, data.MyFirstItemNum, data.MySecondItemNum, data.MyGold + GainGold, data.MyStamina, data.MyStaminaTime, DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"))); if (!Directory.Exists(Application.persistentDataPath + "/Json")) { Directory.CreateDirectory(Application.persistentDataPath + "/Json"); } string jdata = JsonConvert.SerializeObject(data); File.WriteAllText(Application.persistentDataPath + "/Json/save.json", jdata); StartCoroutine(updateDataBase(data)); }
// JSON 업데이트 public void updateJson() { playerInfo data; data = new playerInfo(PlayerData.Instance.money, PlayerData.Instance.playerSkill[4], PlayerData.Instance.playerSkill[5], PlayerData.Instance.playerSkill[6]); if (!Directory.Exists(Application.persistentDataPath + "/Json")) { Directory.CreateDirectory(Application.persistentDataPath + "/Json"); } string jdata = JsonConvert.SerializeObject(data); File.WriteAllText(Application.persistentDataPath + "/Json/save.json", jdata); }
public void saveJson(int score, int MaxScore, int MyFirstItemNum, int MySecondItemNum, int MyGold, int MyStamina, int MyStaminaTime, DateTime SaveDateTime) { playerInfo data; data = new playerInfo(score, MaxScore, MyFirstItemNum, MySecondItemNum, MyGold, MyStamina, MyStaminaTime, DateTime.Parse(SaveDateTime.ToString("yyyy-MM-dd hh:mm:ss"))); if (!Directory.Exists(Application.persistentDataPath + "/Json")) { Directory.CreateDirectory(Application.persistentDataPath + "/Json"); } string jdata = JsonConvert.SerializeObject(data); File.WriteAllText(Application.persistentDataPath + "/Json/save.json", jdata); }
//Instantiate players name and sign private static Tuple <playerInfo, playerInfo> InstantiatePlayers() { playerInfo playerOne = new playerInfo(); playerInfo playerTwo = new playerInfo(); Console.WriteLine("Game started"); Console.WriteLine("Player One please enter your name: "); playerOne.playerName = Console.ReadLine(); playerOne.playerSign = " X "; Console.WriteLine("\nPlayer Two please enter your name: "); playerTwo.playerName = Console.ReadLine(); playerTwo.playerSign = " O "; return(Tuple.Create <playerInfo, playerInfo>(playerOne, playerTwo)); }
public static playerInfo LoadPlayerInfo_Local() { string Name, Passwd; int Highscore, Goldcoin; Name = PlayerPrefs.GetString("PlayerName"); Passwd = PlayerPrefs.GetString("PlayerPasswd"); Highscore = PlayerPrefs.GetInt("PlayerHighscore", 0); Goldcoin = PlayerPrefs.GetInt("GoldCoin", 0); playerInfo temp = new playerInfo(Name, Passwd); temp.Highscore = Highscore; temp.GoldCoin = Goldcoin; string s = PlayerPrefs.GetString("ItemDatas"); playerInfo.MyList <ShopItemData> ItemDatas = JsonUtility.FromJson <playerInfo.MyList <ShopItemData> >(s); temp.ItemDatas = new playerInfo.MyList <ShopItemData>(); if (ItemDatas != null) { foreach (ShopItemData child in ItemDatas.ToList()) { if (ShopManager.GetShopData_ByShopNumber(child.ShopNumber) != null) { temp.ItemDatas.Add(ShopManager.GetShopData_ByShopNumber(child.ShopNumber)); } } } string d = PlayerPrefs.GetString("PresetItemDatas"); playerInfo.MyList <ShopItemData> vPresetItemDatas = JsonUtility.FromJson <playerInfo.MyList <ShopItemData> >(d); temp.PresetItemDatas = new playerInfo.MyList <ShopItemData>(); if (vPresetItemDatas != null) { foreach (ShopItemData child in vPresetItemDatas.ToList()) { if (ShopManager.GetShopData_ByShopNumber(child.ShopNumber) != null) { temp.SetPresetItemData(ShopManager.GetShopData_ByShopNumber(child.ShopNumber)); } } } if (Name == "") { temp.Name = "Player"; } return(temp); }
public void Save() { BinaryFormatter bFormatter = new BinaryFormatter(); FileStream saveFile = File.Create(Application.persistentDataPath + "/playerinfo.dat"); playerInfo info = new playerInfo(); info.savedLevel = SceneManager.GetActiveScene().name; info.twivalbool = mtwivalbool; info.shrwoodsbool = mshrwoodsbool; info.nmpassbool = mnmpassbool; info.bosscountstored = bossCount; bFormatter.Serialize(saveFile, info); saveFile.Close(); }
public void initIdle() { readyBtn.gameObject.SetActive(true); leaveBtn.gameObject.SetActive(true); changeRoomBtn.gameObject.SetActive(true); numOfMJText.text = ""; for (int i = 0; i < room.public_roomInfo.playerInfo.Count; i++) { //PLAYER_PUBLIC_INFO pb = room.public_roomInfo.playerInfo[i]; playerInfo pi = GetPlayerInfoByServerIndex(i); pi.root.gameObject.SetActive(true); pi.initSeat(i); } }
public void updateJson(int money, int atkPoint, int hpPoint, int aspPoint) { playerInfo data; data = new playerInfo(money, atkPoint, hpPoint, aspPoint); if (!Directory.Exists(Application.persistentDataPath + "/Json")) { Directory.CreateDirectory(Application.persistentDataPath + "/Json"); } string jdata = JsonConvert.SerializeObject(data); File.WriteAllText(Application.persistentDataPath + "/Json/save.json", jdata); // string jdata = JsonConvert.SerializeObject(data); // File.WriteAllText(Application.dataPath + "/save.json", jdata); }
private void Awake() { if (m_PlayerManager == null) { m_PlayerManager = this; DontDestroyOnLoad(this); } else if (this != m_PlayerManager) { Destroy(gameObject); } main_playerInfo = LoadPlayerInfo_Local(); m_webserver = gameObject.AddComponent <Webserver>(); m_webserver.set_playerManager(this); }
public static bool check_playerInfoFormat_right(playerInfo playerInfo) { if (!IsString(playerInfo.Name)) { set_MessegeBox("your account format woring"); return(false); } if (!IsString(playerInfo.Passwd)) { set_MessegeBox("your passwd format woring"); return(false); } return(true); }
void Awake() { _instance = this; roleController=this.GetComponent<RoleController>(); itemDBController = this.GetComponent<InventoryItemDBController>(); }
public void updateTeamData(string teamColor, string name, string playerID) { if(teamColor=="blue"){ blueTeamPlayers[blueTeamTotalPlayers] = name; blueTeamTotalPlayers++; } else{ redTeamPlayers[redTeamTotalPlayers] = name; redTeamTotalPlayers++; } allPlayers[numberOfPlayers] = new playerInfo(); allPlayers[numberOfPlayers].playerName = name; allPlayers[numberOfPlayers].playerGuid = playerID; allPlayers[numberOfPlayers].playerTeamColor = teamColor; numberOfPlayers++; }
public void removePlayer(string playerID) { //get name from ID string myName=null; string teamColor=null; for (int i =0;i<allPlayers.Length;i++){ //Debug.Log ("Looking for: " + playerID); //Debug.Log ("position i: " + i + " =" + allPlayers[i].playerGuid); if(allPlayers[i].playerGuid == playerID){ //Debug.Log ("found at: " + i); myName = allPlayers[i].playerName; teamColor = allPlayers[i].playerTeamColor; } } Debug.Log ("player to remove: " + myName + ", color: " + teamColor); if (myName !=null){ //move last item to index of name, remove last item, decrement if(teamColor=="blue"){//blue team int index = System.Array.IndexOf(blueTeamPlayers,myName); blueTeamPlayers[index] = blueTeamPlayers [blueTeamTotalPlayers-1]; //Debug.Log ("revising index: " + index + " from " + blueTeamPlayers[index] + " to " + blueTeamPlayers[blueTeamTotalPlayers-1]); blueTeamPlayers[blueTeamTotalPlayers-1]=null; blueTeamTotalPlayers--; //Debug.Log ("revised blue team: " + getBlueTeamString()); } else{ //red team int index = System.Array.IndexOf(redTeamPlayers,myName); redTeamPlayers[index] = redTeamPlayers [redTeamTotalPlayers-1]; //Debug.Log ("revising index: " + index + " from " + redTeamPlayers[index] + " to " + redTeamPlayers[redTeamTotalPlayers-1]); redTeamPlayers[redTeamTotalPlayers-1]=null; redTeamTotalPlayers--; //Debug.Log ("revised red team: " + getRedTeamString()); } int indexLocation = 0; for (int i=0;i<allPlayers.Length;i++){ if(allPlayers[i].playerName == myName && allPlayers[i].playerTeamColor == teamColor) indexLocation = i; } allPlayers[indexLocation] = allPlayers[numberOfPlayers-1]; allPlayers[numberOfPlayers-1] = new playerInfo(); //Debug.Log ("revised all players: " + allPlayers.ToString()); numberOfPlayers--; } }