public static void Serialize(Player_Info unitClass) { string json = JsonUtility.ToJson(unitClass); SaveToFile(json); Debug.Log("Json saved."); }
private void OnTriggerStay2D(Collider2D collision) { KeyCode keyUp = KeyCode.None; foreach (KeyCode vKey in System.Enum.GetValues(typeof(KeyCode))) { if (Input.GetKeyUp(vKey)) { keyUp = vKey; if (keyUp.ToString() == KeyImputManager.GetKeyBind("interact")) { if (collision.gameObject.tag == "Player") { podiumReset(); podiumSwordChangeSprite(); Instantiate(knight_3); knight_3.transform.position = gameObject.transform.position; Player_Info.setPlayerGameObject(knight_3); Player_Info.CharacterName = knight_3.name; HitTracker.HaveHit = false; destroyPlayer(); } } } } }
public override void AddCoinToPlayer() { Random r = new Random(); int rnd = r.Next(10, 50); Player_Info.addMoney(rnd); }
public void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Player") { Player_Info.dealDamage(10 * Player_Info.ngPlus); } }
public static Player_Info Deserialize() { Player_Info unitClass = new Player_Info(); JsonUtility.FromJsonOverwrite(ReadFromFile(), unitClass); Debug.Log("Data Loaded"); return(unitClass); }
private void restartGame() { PlayerPlatformerController player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerPlatformerController>(); Player_Info.increaseNgPlus(); player.resetPlayer(); player.TeleportPlayerToMainMenu(); }
void Start() { camOffset = new Vector3(0f, CamVerticalOffset, 0f); MainSceneCamera = GetComponent<Player_Setup>().MainSceneCamera; sceneCamTranform = MainSceneCamera.transform; P_Info = GetComponent<Player_Info>(); P_Shoot = GetComponent<Player_Shoot>(); }
// Use this for initialization void Start() { //Get the rigidbody component and the child camera rb = GetComponent <Rigidbody> (); playerInfo = GameObject.Find("Player_Manager").GetComponent <Player_Info>(); bloodAlpha = Blood.GetComponent <Alpha_Animate> (); playerCamera = GameObject.Find("Main Camera"); }
public void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Player") { Player_Info.dealDamage(25 * Player_Info.ngPlus); pushThePlayer = true; } }
private void Start() { NewLevel(); ui_manager.Pause_Game(); level_complete_canvas.enabled = false; player_info = data_base.Deserialize(); checker_Script = new checker_script(GetComponent <singletone_script>()); }
//// Save and load the information of users in a jason file. public void Save() { string Sex = sexchoice[0]; if (!ifMale) { Sex = sexchoice[1]; } Player_Info _data = new Player_Info() { Email = Email, FirstName = FirstName, FamilyName = FamilyName, Age = Age, Sex = Sex, City = City, Country = Country, Institution = Institution, Score = Score, Level = Level }; string playerJson = JsonConvert.SerializeObject(_data, Formatting.Indented); string UserPath = Application.persistentDataPath + "/Unity/" + Email + ".json"; //save the player information to the local Json file try { File.WriteAllText(UserPath, playerJson); AlertWindow2.SetActive(true); } catch (Exception ex) { AlertText.text = ex.Message; AlertWindow.SetActive(true); } //save the player information to the database string query = @"insert into runoob.player_info (age, city, country, email, familyname, firstname, institute, level, score, sex, password, carrots) values (" + Age + ", \"" + City + "\", '" + Country + "', '" + Email + "', '" + FamilyName + "', '" + FirstName + "', '" + Institution + "', " + Level + ", " + Score + ", '" + Sex + "', '" + _data.password + "', " + _data.carrots + ")"; Debug.Log(query); MysqlConnector mysqlConnector = new MysqlConnector(); mysqlConnector.Query(query); }
private void Start() { if (!debugMode) { fps.SetActive(false); console.SetActive(false); } NewLevel(); ui_manager.Pause_Game(); level_complete_canvas.enabled = false; player_info = data_base.Deserialize(); checker_Script = new checker_script(GetComponent <singletone_script>()); }
public void buyDegat() { if (Player_Info.Money >= ShopInfo.AttackPrice) { Player_Info.BuyDamage(); print(Player_Info.degat); Player_Info.reduceMoney(ShopInfo.AttackPrice); ShopInfo.incrementAttack(); updateAttackPrice(); updatePlayerMoney(); playCoinAudio(); save(); } else { errorAttackPrice(); Invoke("updateAttackPrice", 3f); } }
public void buyDefence() { if (Player_Info.Money >= ShopInfo.DefencePrice) { Player_Info.BuyDefence(); print(Player_Info.defence); Player_Info.reduceMoney(ShopInfo.DefencePrice); ShopInfo.incrementDefence(); updateDefencePrice(); updatePlayerMoney(); playCoinAudio(); save(); } else { errorDefencePrice(); Invoke("updateDefencePrice", 3f); } }
public void buyHealth() { if (Player_Info.Money >= ShopInfo.HealthPrice) { Player_Info.BuyHealth(); print(Player_Info.startingHealth); Player_Info.reduceMoney(ShopInfo.HealthPrice); ShopInfo.incrementHealth(); updateHealthPrice(); updatePlayerMoney(); playCoinAudio(); save(); } else { errorHealthPrice(); Invoke("updateHealthPrice", 3f); } }
void receive_client()//클라이언트 접속 받아들임 { try { m_listener = new TcpListener(ipAddr, PORT); m_listener.Start(); Message("서버시작. 클라이언트 접속 대기 중"); m_bStop = true; while (m_bStop) { hClient = m_listener.AcceptTcpClient(); if (hClient.Connected) { //여기서 join data 패킷 받고 m_stream = hClient.GetStream(); m_stream.Read(readBuffer, 0, 1024 * 4); //Packet packet = (Packet)Packet.Desserialize(readBuffer); Join_data join_data = (Join_data)Packet.Desserialize(readBuffer); Message(join_data.nickname + "님이 로그인 시도");//입장했다는 메세지보다 더 명확한의미로 시도로 바꿈 Join_result join_result = new Join_result(); join_result.Type = (int)PacketType.연결; //name 중복검사 if (!checkName(join_data.nickname)) // => 클라이언트에게 name중복임을 알리고 처리하도록 (연결안됨-게임폼으로 못넘어가게) { //중복이면 연결해제하고 count--하고 관련된 것들 처리 필요 //connection=false전달 Message("이름 중복 발생. client연결 해제함"); join_result.success = false; join_result.reason = "이름중복"; Packet.Serialize(join_result).CopyTo(sendBuffer, 0); Send(); m_stream.Close(); Array.Clear(sendBuffer, 0, 1024 * 4); hClient.Close(); continue; } //4명이상인지 검사 if (count_client < 4) { count_client++; } else { //클라이언트에게 연결실패 전달 Message("4명 넘음. 클라이언트 연결 해제"); join_result.success = false; join_result.reason = "인원초과"; Packet.Serialize(join_result).CopyTo(sendBuffer, 0); Send(); m_stream.Close(); Array.Clear(sendBuffer, 0, 1024 * 4); hClient.Close(); continue; } Message(join_data.nickname + "님 로그인 성공"); //위의 로그인 조건 확인 뒤 로그인 성공 띄움 Player_Info info = new Player_Info(); //Client_Info 멤버변수 초기화해서 배열에 넣는 과정 info.client = hClient; if (count_client == 1) { info.drawable = true; //최초 client에게 그리기 권한 - 클라이언트들이 중간에 나가지 않는다는 가정하에 } else { info.drawable = false; } bool is_exist = false; Player_light_Info light_info = new Player_light_Info();//가벼운정보들 클라이언트에 전달용 for (int i = 0; i < arrMember.Count; i++) { if (join_data.nickname == arrMember[i].nickname) //기존 존재하는 닉네임인 경우 저장되어있는 점수 불러옴 { arrMember[i].img_num = join_data.img_num; //로그인할때 설정한 이미지 정보 회원정보에 저장 info.nickname = arrMember[i].nickname; info.img_num = arrMember[i].img_num; info.score = arrMember[i].score;//게임한판진행 중에 중간에 나갔다가 들어왔을때 점수 유지 arrClient.Add(info);//현재 플레이중 플레이어들 배열에 추가 is_exist = true; light_info.score = arrMember[i].score;//판이 끝나기 전에 저장되어있던 점수 light_info.match = arrMember[i].match; light_info.win = arrMember[i].win; light_info.lose = arrMember[i].lose; } } if (!is_exist)//기존 존재하는 닉네임이 아닌경우 { Member_Info minfo = new Member_Info(); minfo.nickname = join_data.nickname; arrMember.Add(minfo);//회원정보리스트에 추가 info.nickname = join_data.nickname; info.img_num = join_data.img_num; arrClient.Add(info); //플레이어리스트에 추가 light_info.score = 0; //처음들어오는거면 점수 0 light_info.match = 0; light_info.win = 0; light_info.lose = 0; } light_info.nickname = join_data.nickname; light_info.img_num = join_data.img_num; arrClientlight.Add(light_info); //연결문제없음. 성공 전달///////////////////////연결성공 전달할때 현재 플레이어 상태도 보내야할듯. 사진이랑 닉네임정보 join_result.success = true; join_result.arrClient = arrClientlight.ToList(); if (count_client == 1) { join_result.it = true; join_result.first_answer = answer; } else { join_result.it = false; join_result.first_answer = ""; } Packet.Serialize(join_result).CopyTo(sendBuffer, 0); Send(); New_Player player = new New_Player(); player.Type = (int)PacketType.참가; player.ligthInfo = light_info; sendToAll(player, hClient); Client_handler(); } } } catch { Message("error at receive_client"); } }
// Use this for initialization void Start() { // Get components playerRigidbody = GetComponent<Rigidbody>(); charCollider = GetComponent<CapsuleCollider>(); infoScript = gameObject.GetComponent<Player_Info>(); // Save Initial forces to reset to inputForce = initialPlayerForce; frictionCoefficent = initialFrictionCoefficent; airFrictionCoefficent = initialAirFrictionCoefficent; }
public virtual void GiveMoney() { Player_Info.addMoney(1000); }
public override void attackPlayer() { pushThePlayer = true; Player_Info.hit(degat); }
// Update is called once per frame void Update() { Player_Info.afficherHealth(); }
IEnumerator PlayerDistance(Player_Info Player) { if (Player == null) { //Player Died } else if ( Player.gameObject != null) { Vector3 pPos = Player.transform.position; Vector3 wPos = transform.position; float hPositive = wPos.y + distanceToPickUp; // weapon height plus distancePickUp float hNegative = wPos.y - distanceToPickUp; // weapon height minus distancePickUp // if weapon is more than 5 units above or below the players point // the weapon is declared out of reach and will not glow or be able // to get. Wait one second to see if it is out of reach again, skip // rest of function; if (pPos.y > hPositive || pPos.y < hNegative) { //Debug.Log(gameObject.name + "/" + WeaponName.ToString() + " OUT of height range"); inPlayerRadius[Player.PlayerNumber-1] = false; yield return new WaitForSeconds(1.0f); StartCoroutine(PlayerDistance(Player)); } else // In players height range { // If player distance to weapon is less than Distance if ( isPlayerInDistance(DistanceForm(pPos.x, pPos.z, wPos.x, wPos.z)) ) { //Debug.Log(gameObject.name + "/" + WeaponName.ToString() + " IN of xz range"); inPlayerRadius[Player.PlayerNumber-1] = true; WeaponText(pickup, Player.gameObject); } else { //Debug.Log(gameObject.name + "/" + WeaponName.ToString() + " OUT of Distance range"); //Debug.Log("Distance: " + DistanceForm(pPos.x, pPos.z, wPos.x, wPos.z)); inPlayerRadius[Player.PlayerNumber-1] = false; } // If not equipped search again after .25 second delay if (!Equipped) { yield return new WaitForSeconds(0.25f); StartCoroutine(PlayerDistance(Player)); } } } }
Chat_data chat_data;//이거 밖에있어야함? void receiveData() { TcpClient client = hClient; bool m_bConnect; Array.Clear(sendBuffer, 0, 1024 * 4); NetworkStream stream = client.GetStream(); streamList.Add(stream); if (stream != null) { m_bConnect = true; while (m_bConnect) { try { Array.Clear(readBuffer, 0, 1024 * 4); stream.Read(readBuffer, 0, 1024 * 4); } catch { Message("error발생"); return; //stream.Close(); //need check } Packet packet = (Packet)Packet.Desserialize(readBuffer); if ((int)packet.Type == (int)PacketType.채팅) { chat_data = (Chat_data)Packet.Desserialize(readBuffer); Message(chat_data.nickname + " : " + chat_data.data);//for test sendToAll(packet, client); if (answer == chat_data.data) //정답 처리하는 부분 { Correct_data correct_data = new Correct_data(); //클라이언트들에게 correct발생했다고 알림(correct패킷전송) correct_data.Type = (int)PacketType.정답; correct_data.nickname = getName(client); //맞춘 애 이름 담음 - client에서 **님이 정답을 맞췄습니다. 라고 출력 sendToAll(correct_data, null); //서버가 보낼 땐 null로... need check string correct_player = ""; bool end = false; for (int i = 0; i < arrClient.Count; i++) { if (client == arrClient[i].client) { arrClient[i].drawable = true; arrClient[i].score++; arrClientlight[i].score++; //중간에 나갔다 들어온사람한테 올바른 경기상태 전하려면 light정보 갱신 correct_player = arrClient[i].nickname; //맞춘사람 이름 if (arrClient[i].score == 3) { end = true; } } else { arrClient[i].drawable = false; } } foreach (Member_Info member in arrMember) { if (member.nickname == correct_player) { member.score++; } } if (end) { endGame(); Answer ans = new Answer(); ans.Type = (int)PacketType.다음정답; ans.answer = answer; Packet.Serialize(ans).CopyTo(sendBuffer, 0); stream.Write(sendBuffer, 0, sendBuffer.Length); stream.Flush(); Array.Clear(sendBuffer, 0, 1024 * 4); } else { count_game++; //몇 판 했는지 처리 if (count_game == 5) { endGame(); //5판끝났으면 endgame호출 } else { getAnswer(); //answer갱신 //정답자에게만 새로운 정답 알려줘야됨 Answer ans = new Answer(); ans.Type = (int)PacketType.다음정답; ans.answer = answer; Packet.Serialize(ans).CopyTo(sendBuffer, 0); stream.Write(sendBuffer, 0, sendBuffer.Length); stream.Flush(); Array.Clear(sendBuffer, 0, 1024 * 4);//이건왜 sendToAll로 안함? } } } } else if ((int)packet.Type == (int)PacketType.그림) { } else if ((int)packet.Type == (int)PacketType.나가기) { //나가기 패킷 받았으면 처리 //arrclient에서 삭제하고 얘가 나갔다고 클라이언트들에게 알린다 Exit_data exit = (Exit_data)Packet.Desserialize(readBuffer); Player_Info exit_member = new Player_Info(); exit_member.nickname = exit.nickname; Message(exit_member.nickname + "님이 나갔습니다. "); count_client--; //플레이어수 감소 sendToAll(exit, client); int exit_index = arrClient.IndexOf(exit_member); //객체넣어서비교말고 string으로만 indexOf 쓰고 싶었는데 잘안됨 arrClient.RemoveAt(exit_index); arrClientlight.RemoveAt(exit_index); } } //stream.Close(); //need check } }
//start void Start() { //set it so it's easier to mention player player = PlayerDatabase.playerDatabase.playerInfo[playerNumber - 1]; }
public override void GiveMoney() { Player_Info.addMoney(1); }
// Update is called once per frame void Update() { Player_Info.afficherMoney(); }
public virtual void attackPlayer() { Player_Info.hit(degat); playAttackAnimation(); }
void Awake() { instance = this; }
public override void GiveMoney() { Player_Info.addMoney(200 * Player_Info.ngPlus); }
void FindCameraOnPlayer(Player_Info player, Rect view) { foreach (Transform _trans in player.transform) { if (_trans.tag == "MainCamera") { _trans.camera.rect = view; //~( (1 << 18) | (1 << 19) | (1 << 20) | (1 << 21)); //_trans.camera.cullingMask = ~(1 << 18); } } }