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];

                TSVector position  = new TSVector(player.position.x, player.position.y, player.position.z);
                TSVector direciton = new TSVector(0, 180, 0);
                //Debug.Log("SyncManager::CreatePlayer.player.position:"+ player.position + ",direciton:"+ player.direction);

                GameObject perfab = SyncedInstantiate(playerPerfab, position, TSQuaternion.Euler(direciton));

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

                perfab.name = player.className + "_" + player.id;
                PlayerBehaviour playerScript = perfab.AddComponent <PlayerBehaviour>();
                playerScript.owner = player;
                player.renderObj   = perfab;
                playerBehaviours.Add(player.id, playerScript);

                if (player.isPlayer())
                {
                    cameraTransform.GetComponent <CamerFllown>().AttachTarget(perfab.transform);
                    cameraTransform.transform.parent = perfab.transform;
                }
            }
        }
Exemplo n.º 2
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);
                TSVector position  = new TSVector(0f, 1f, 0f);
                TSVector direciton = new TSVector(0f, 180f, 0f);

                GameObject perfab = SyncedInstantiate(playerPerfab, position, TSQuaternion.Euler(direciton));

                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.º 3
0
        /**
         *  @brief Rotates game object based on provided axis angles and relative space.
         *
         *  If relative space is SELF then the game object will rotate based on its forward vector.
         **/
        public void Rotate(TSVector eulerAngles, Space relativeTo)
        {
            TSQuaternion result = TSQuaternion.identity;

            if (relativeTo == Space.Self)
            {
                result = this.rotation * TSQuaternion.Euler(eulerAngles);
            }
            else
            {
                result = TSQuaternion.Euler(eulerAngles) * this.rotation;
            }

            result.Normalize();
            this.rotation = result;
        }