public void ApplyDelta(byte[] delta) { byte playerDiffMask = delta[0]; int index = 1; if ((playerDiffMask & CONSTANTS.NAME_MASK) > 0) { // Convert from bytes to string name = DataUtils.ReadString(ref index, delta); } if ((playerDiffMask & CONSTANTS.PLAYER_ID_MASK) > 0) { playerID = delta[index]; ++index; } if ((playerDiffMask & CONSTANTS.PLAYER_TYPE_MASK) > 0) { playerType = (PLAYER_TYPE)delta[index]; ++index; } if ((playerDiffMask & CONSTANTS.READY_MASK) > 0) { isReady = delta[index]; ++index; } if ((playerDiffMask & CONSTANTS.TEAM_MASK) > 0) { team = delta[index]; ++index; } }
void Awake() { playerIndex = GameStateManager.instance.RegisterPlayer(gameObject); anim = GetComponent <Animator>(); anim.SetInteger("PlayerNum", playerIndex); sprite = GetComponent <SpriteRenderer>(); playerCollider = GetComponent <Collider>(); sprite.sprite = playerSprites[playerIndex]; if (playerIndex == 0) { Debug.Log("Zookeeper"); role = PLAYER_TYPE.ZOOKEEPER; anim.SetBool("IsBeaver", false); walkSound = zookeeperWalkSound; speed = zookeeperSpeed; carrySpeed = zookeeperCarrySpeed; zookeeperJoinSound.PlayOneShot(zookeeperJoinSound.clip, 3f); } else { Debug.Log("Beaver"); role = PLAYER_TYPE.BEAVER; anim.SetBool("IsBeaver", true); walkSound = beaverWalkSound; speed = beaverSpeed; carrySpeed = beaverCarrySpeed; beaverJoinSound.PlayOneShot(beaverJoinSound.clip, 1f); } Debug.Log("Player " + playerIndex.ToString() + " registered"); rb = GetComponent <Rigidbody>(); }
/* Costruttore di classe, accetta in input * PlayerType: tipo enum di giocatore * TokenID: intero che rappresenta la pedina da utilizzare * Money: somma da assegnare al giocatore * PropertyList: lista di proprieta' della partita (globale) */ public Player(PLAYER_TYPE PlayerType, int TokenID, float Money, List<Property> PropertyList) { this.PlayerType = PlayerType; this.TokenID = TokenID; this.Money = Money; if (PlayerType != PLAYER_TYPE.BANK) { // Il numero che sara' random int randomNumber = -1; // Lista che conterra' le proprieta' libere List<Property> tempList = new List<Property>(); for (int i = 0; i < PropertyList.Count; i++) { if (!PropertyList[i].isOwned()) { tempList.Add(PropertyList[i]); } } // A questo punto posso eseguire 6 volte il random sulla tempList for (int i = 0; i < 7; i++) { randomNumber = Random.Range(0, tempList.Count - 1); // Il giocatore compra la proprieta' this.buyProperty(tempList[randomNumber]); // La proprieta' viene eliminata dalla tempList perche' non piu' disponibile tempList.RemoveAt(randomNumber); } } }
public void OnDisconnectClicked() { m_ws.Close(); m_chessBoard.SendMessage("OnDisconnect", SendMessageOptions.DontRequireReceiver); m_playerType = PLAYER_TYPE.NONE; m_isMyTurn = false; }
public PLAYER_INFO(int i, PLAYER_TYPE t, CHARACTER c, DevType[] _dev = null) { id = i; type = t; character = c; dev = _dev; }
public void initPlayer(string name, int id, Color c, bool network, PLAYER_TYPE type) { playerType = type; playerName = name; playerID = id; playerColor = c; selectedObject = null; }
// 处理服务器发送来的所有消息(也可能有本地消息) public void DoMessage() { if (m_stackMessage.Count == 0) { return; } Dictionary <string, object> dic = m_stackMessage.Pop(); string sType = dic["message_type"].ToString(); print("接收到的数据类型为:" + sType); switch (sType) { case "player_type": // 玩家类型设置 string player_type = dic["message_detail"].ToString(); print("玩家设定的类型为:" + player_type); if (player_type == "red") { m_playerType = PLAYER_TYPE.RED; // 后进入的用红子 m_chessBoard.SendMessage("InitRedChessPieces", SendMessageOptions.DontRequireReceiver); m_isMyTurn = true; // 红子先走 } else if (player_type == "black") { m_playerType = PLAYER_TYPE.BLACK; m_chessBoard.SendMessage("InitBlackChessPieces", SendMessageOptions.DontRequireReceiver); m_isMyTurn = false; // 黑子后走 } else { print("玩家数只能有两位,断开"); m_ws.Close(); } break; case "move": { // 监听到其他玩家移动棋子 string move_detail = dic["message_detail"].ToString(); string[] move_strings = move_detail.Split('-'); int move_index = int.Parse(move_strings[0]); int move_col = int.Parse(move_strings[1]); int move_row = int.Parse(move_strings[2]); print(move_detail); GameObject move_piece = m_chessBoard.GetComponent <ChessBoard>().chessPieces[move_index]; move_piece.transform.position = new Vector3(CalcX(move_col), CalcY(move_row), -2f); move_piece.GetComponent <ChessPiece>().m_col = move_col; move_piece.GetComponent <ChessPiece>().m_row = move_row; m_isMyTurn = true; break; } case "delete": // 接收到服务器的吃掉棋子指令 int delete_detail = Convert.ToInt32(dic["message_detail"].ToString()); // 将要删除的棋子的index GameObject delete_piece = m_chessBoard.GetComponent <ChessBoard>().chessPieces[delete_detail]; Destroy(delete_piece); break; } }
/// <summary> /// Permet de recuperer le type de joueur /// </summary> /// <returns><see cref="Diaballik.Player.PLAYER_TYPE"/> /// </returns> public override PLAYER_TYPE getType() { PLAYER_TYPE ia = PLAYER_TYPE.IA_PROGRESSIVE; switch (this.iaStrategy.getType()) { case IAStrategy.IA_STRATEGY.NOOB: ia = PLAYER_TYPE.IA_NOOB; break; case IAStrategy.IA_STRATEGY.STARTING: ia = PLAYER_TYPE.IA_STARTING; break; } return(ia); }
public CPlayer(byte player_index, PLAYER_TYPE player_type, SendFn send_function, CLocalServer local_server) { this.player_index = player_index; this.agent = new CPlayerAgent(player_index); this.player_type = player_type; switch (this.player_type) { case PLAYER_TYPE.HUMAN: this.send_function = send_function; break; case PLAYER_TYPE.AI: this.ai_logic = new CAIPlayer(local_server); this.send_function = this.ai_logic.send; break; } }
// Update is called once per frame void Update() { // アクションに合わせて分岐 switch (m_type) { case PLAYER_TYPE.type_walk: audioSource = GetComponent <AudioSource>(); audioSource.clip = audioClip1; audioSource.Play(); m_type = PLAYER_TYPE.type_none; break; case PLAYER_TYPE.type_jump: audioSource = GetComponent <AudioSource>(); audioSource.clip = audioClip2; audioSource.Play(); m_type = PLAYER_TYPE.type_none; break; } }
public void Play(string fileName, PLAYER_TYPE playerType, bool soundOverlap) { if (!this.soundTable.ContainsKey(fileName)) { Load(fileName); } if (soundOverlap) { this.soundPlayers[(int)playerType].PlayOneShot(this.soundTable[fileName]); } else { if (this.soundPlayers[(int)playerType].clip != this.soundTable[fileName]) { SetSoundSourceInPlayer(fileName, playerType); } this.soundPlayers[(int)playerType].Play(); } }
public void SetPlayerType(int newType) { //Debug.Log(newType); gameObject.transform.eulerAngles = new Vector3(0, 0, 0); transform.localScale = new Vector3(1.5f, 1.5f, 0); moveSpeed = origSpeed; if (currentPlayer == "P1") { float r = 1; float g = 0.4078f; float b = 0.6352f; float a = 1; GetComponent <SpriteRenderer>().color = new Vector4(r, g, b, a); } else if (currentPlayer == "P2") { float r = 0.3215f; float g = 0.9882f; float b = 1; float a = 1; GetComponent <SpriteRenderer>().color = new Vector4(r, g, b, a); } if (newType > 0) { charType = (PLAYER_TYPE)newType; } if (heldItem != null && heldItem.activeInHierarchy == true) { heldItem.SetActive(false); } CheckHeldObject(); }
public GamePlayer AddPlayerOfType( int _playerID, PLAYER_TYPE _playerType ) { DebugConsole.Log( "Adding player " + _playerID + " to " + _playerType ); if ( this.playerMap.ContainsKey( _playerID ) ) { DebugConsole.Warning( "Player " + _playerID + " already added", this ); return null; } GamePlayer newPlayer = new GamePlayer(); newPlayer.id = _playerID; this.playerMap.Add( newPlayer.id, newPlayer ); this.ChangePlayerType( newPlayer.id, _playerType ); if ( _playerID == Common.MyNetworkID() ) { Debug.Log( "Setting my player to " + _playerID ); this.myPlayer = newPlayer; } if ( Network.peerType != NetworkPeerType.Disconnected ) { foreach ( NetworkPlayer netPlayer in Network.connections ) { if ( Common.NetworkID( netPlayer ) == _playerID ) { newPlayer.networkPlayer = netPlayer; break; } } } return newPlayer; }
/// <summary> /// NOTE : Create Player setting Function GUI /// </summary> private void CreatePlayer() { GUILayout.Space(10); GUILayout.BeginVertical("Box"); characterpos = EditorGUILayout.Vector2Field("Character Position", characterpos); GUILayout.EndVertical(); GUILayout.Space(10); GUILayout.BeginVertical("Box"); GUILayout.Label("CAT TYPE", MapToolWindow.titleFont); selectedTypePlayer = GUILayout.Toolbar(selectedTypePlayer, new string[] { PLAYER_TYPE.Cat1.ToString(), PLAYER_TYPE.Dog.ToString() }); GUILayout.Label("추후 추가예정.."); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); if (GUILayout.Button("CREATE", GUILayout.Height(35))) { playerOb = GameObject.FindGameObjectWithTag("Player"); //추후에 여러 플레이어 캐릭터가 존재할경우 변경 해야함 if (playerOb != null) { DestroyImmediate(playerOb); } PLAYER_TYPE pType = (PLAYER_TYPE)selectedTypePlayer; var tmpplayerob = AssetDatabase.LoadAssetAtPath(playerPath + pType.ToString() + ".prefab", typeof(Object)); playerOb = PrefabUtility.InstantiatePrefab(tmpplayerob) as GameObject; playerOb.transform.position = characterpos; Selection.activeGameObject = playerOb; EditorGUIUtility.PingObject(playerOb); } GUILayout.Space(10); }
public void SetSoundSourceInPlayer(string fileName, PLAYER_TYPE playerType) { this.soundPlayers[(int)playerType].clip = this.soundTable[fileName]; }
public void RegisterSoundPlayer(PLAYER_TYPE playerType, AudioSource audioSource) { this.soundPlayers[(int)playerType] = audioSource; }
public void ActiveSelectCompletePanel(PLAYER_TYPE _pType) { selectCompeletePanel.SetActive(true); selectCompeleteText.text = "'" + _pType.ToString() + "' START ?"; pType = _pType; }
public void ChangePlayerType(PLAYER_TYPE newPlayerType) { Type = newPlayerType; }
public bool ValidTypeChange( int _playerID, PLAYER_TYPE _playerType ) { GamePlayer player = this.GetPlayerWithID( _playerID ); if ( player == null ) { return false; } if ( player.playerType == _playerType ) { return false; } switch ( _playerType ) { case PLAYER_TYPE.COMMANDER1: { return this.commander1 == null; } case PLAYER_TYPE.COMMANDER2: { return this.commander2 == null; } //TODO: Fighter list size check default: { return true; } } }
public void Resume(PLAYER_TYPE playerType) { this.soundPlayers[(int)playerType].UnPause(); }
public void Stop(PLAYER_TYPE playerType) { this.soundPlayers[(int)playerType].Stop(); }
public void ChangePlayerType( int _playerID, PLAYER_TYPE _newType ) { if ( !this.playerMap.ContainsKey( _playerID ) ) { DebugConsole.Error( "Unknown player ID " + _playerID ); return; } GamePlayer player = this.playerMap[_playerID]; if ( player.playerType == _newType ) { DebugConsole.Warning( "Useless change request changing player " + _playerID + " to " + _newType ); } switch ( player.playerType ) { case PLAYER_TYPE.UNDEFINED: break; case PLAYER_TYPE.FIGHTER1: if ( !this.fighters1.Remove( player ) ) { DebugConsole.Error( "Error removing " + _playerID + " from team 1" ); } break; case PLAYER_TYPE.FIGHTER2: if ( !this.fighters2.Remove( player ) ) { DebugConsole.Error( "Error removing " + _playerID + " from team 2" ); } break; case PLAYER_TYPE.COMMANDER1: if ( this.commander1 != player ) { DebugConsole.Error( "Error removing " + _playerID + " from commander 1" ); } this.commander1 = null; break; case PLAYER_TYPE.COMMANDER2: if ( this.commander2 != player ) { DebugConsole.Error( "Error removing player " + _playerID + " from commander 2" ); } this.commander2 = null; break; default: DebugConsole.Error( "Uncaught player type " + _playerID + ":" + player.playerType ); break; } player.playerType = _newType; switch ( player.playerType ) { case PLAYER_TYPE.UNDEFINED: DebugConsole.Warning( "You shouldn't be changing the player type to UNDEFINED " + player.id ); break; case PLAYER_TYPE.FIGHTER1: this.fighters1.Add( player ); player.team = TEAM.TEAM_1; break; case PLAYER_TYPE.FIGHTER2: this.fighters2.Add( player ); player.team = TEAM.TEAM_2; break; case PLAYER_TYPE.COMMANDER1: if ( this.commander1 != null ) { DebugConsole.Error( "Commander 1 is already occupied. Cannot change to " + _playerID ); } this.commander1 = player; player.team = TEAM.TEAM_1; break; case PLAYER_TYPE.COMMANDER2: if ( this.commander2 != null ) { DebugConsole.Error( "Commander 2 is already occupied. Cannot change to " + _playerID ); } this.commander2 = player; player.team = TEAM.TEAM_2; break; default: DebugConsole.Error( "Uncaught player type " + _playerID + ":" + player.playerType ); break; } }
/// <summary> /// 플레이어 생성 /// </summary> private void CreatePlayer(PLAYER_TYPE _playertype, string path) { var playerprefab = Resources.Load(path + _playertype.ToString()) as GameObject; playerOb = Instantiate(playerprefab).GetComponent <Player>(); }
public void UseDefaults() { this.playerType = PLAYER_TYPE.COMMANDER1; }
public void SendChangePlayerTypeMessage( int _playerID, PLAYER_TYPE _playerType ) { this.GetComponent<NetworkView>().RPC( "OnChangePlayerTypeRPC", RPCMode.All, _playerID, (int)_playerType ); }
public void SendValidatePlayerTypeChange( int _playerID, PLAYER_TYPE _playerType ) { this.GetComponent<NetworkView>().RPC( "OnValidatePlayerTypeChangeRPC", RPCMode.Server, _playerID, (int)_playerType ); }
private void OnForcePlayerTypeButtonDown( PLAYER_TYPE _type ) { if ( _type == GamePlayerManager.instance.myPlayer.playerType ) { return; } if ( Network.isServer ) { MenuNetworking.instance.SendChangePlayerTypeMessage( Common.MyNetworkID(), _type ); } else { MenuNetworking.instance.SendValidatePlayerTypeChange( Common.MyNetworkID(), _type ); } }
// Use this for initialization void Start() { // 初期化 m_type = PLAYER_TYPE.type_none; }
void GUIPrepLocalMatch() { GUILayout.BeginVertical(); player1Name = GUILayout.TextField(player1Name, 50); player2Name = GUILayout.TextField(player2Name, 50); if (GUILayout.Button("Play")) { // Setup players based on UI state if (player1 != null) { Destroy(player1); } var p1 = Instantiate(playerLocalPrefab).GetComponent <PlayerLocal>(); player1 = p1.gameObject; p1.playerID = IGame.PLAYER.PLAYER1; p1.playerName = player1Name; p1.board = board; switch (player1Type) // TODO: Configure player controller (human or AI) { case PLAYER_TYPE.HUMAN: // TODO break; case PLAYER_TYPE.AI: // TODO break; } if (player2 != null) { Destroy(player2); } var p2 = Instantiate(playerLocalPrefab).GetComponent <PlayerLocal>(); player2 = p2.gameObject; p2.playerID = IGame.PLAYER.PLAYER2; p2.playerName = player2Name; p2.board = board; switch (player2Type) // TODO: Configure player controller (human or AI) { case PLAYER_TYPE.HUMAN: // TODO break; case PLAYER_TYPE.AI: // TODO break; } // Setup match based on players above and UI state about match var matchLocal = matchControllers.GetComponentInChildren <MatchLocal>(true); matchLocal.gameObject.SetActive(true); Debug.Assert(matchLocal != null, "MatchLocal component required"); matchLocal.match.game = game; matchLocal.match.board = board; // Is this necessary? matchLocal.match.player1 = player1.gameObject.GetComponent <IPlayer>(); matchLocal.match.player2 = p2.gameObject.GetComponent <IPlayer>(); //currentMatch = matchLocal; // Transition to Playing state //currentMatch.Begin(); activeMenu = MENU.PLAYING_LOCAL_MATCH; } if (GUILayout.Button("Back")) { activeMenu = MENU.MAIN; } GUILayout.EndVertical(); GUILayout.BeginVertical(); player1TypeSelection = GUILayout.SelectionGrid(player1TypeSelection, new string[] { "Human", "AI" }, 2); player2TypeSelection = GUILayout.SelectionGrid(player2TypeSelection, new string[] { "Human", "AI" }, 2); if (player1Type != (PLAYER_TYPE)player1TypeSelection) { player1Type = (PLAYER_TYPE)player1TypeSelection; } if (player2Type != (PLAYER_TYPE)player2TypeSelection) { player2Type = (PLAYER_TYPE)player2TypeSelection; } GUILayout.EndVertical(); }
public LiuhePlayer(int i, PLAYER_TYPE t, PLAYER_CHARACTER p) { _PlayerIndex = i; _Type = t; _PC = p; }