Exemplo n.º 1
0
        void CreatePlayer()
        {
            Debug.Log("SyncManager::CreatePlayer.count:" + GameData.Instance.RoomPlayers.Count);

            for (int i = 0; i < GameData.Instance.RoomPlayers.Count; i++)
            {
                KBEngine.Avatar player = GameData.Instance.RoomPlayers[i];

                if (player.component1.isWathcher > 0)
                {
                    continue;
                }

                //TSVector bronPosition = new TSVector(-3 + (i - 1) * 4, 1, 16);

                GameObject perfab = SyncedInstantiate(playerPerfab, player.position.ToTSVector(), new TSQuaternion(0, 0, 0, 1));

                Debug.Log("SyncManager::CreatePlayer.player.renderObj:" + (perfab == null? "Null": perfab.name)
                          + ",position:" + perfab.transform.position);

                PlayerContorl playerScript = perfab.AddComponent <PlayerContorl>();
                playerScript.owner = player;

//                 GameEntity gameEntity = perfab.AddComponent<GameEntity>();
//                 gameEntity.entity = player;
//                 gameEntity.name = player.className + "_" + player.id;
//
//                 gameEntity.isPlayer = true;
//                 gameEntity.isAvatar = true;
                player.renderObj = perfab;
            }
        }
Exemplo n.º 2
0
        void PlayerBehaviour()
        {
            for (int i = 0; i < GameData.Instance.RoomPlayers.Count; i++)
            {
                GameObject player = (GameObject)GameData.Instance.RoomPlayers[i].renderObj;

                if (player == null)
                {
                    continue;
                }

                PlayerContorl playerScript = player.GetComponent <PlayerContorl>();

                if (playerScript != null && playerScript.isActiveAndEnabled)
                {
                    playerScript.OnSyncedUpdate();
                }
            }
        }