예제 #1
0
    /// <summary>
    /// リモートユーザから受信したメッセージのハンドラ
    /// リモートユーザキャラクターのTransformをUpdateする
    /// </summary>
    /// <param name="msg"></param>
    private void UpdateRemoteCharacterTransform(NetworkInMessage msg)
    {
        long userID = msg.ReadInt64();      // ユーザIDを取得
        // Transformを取得
        Vector3    remoteCharaPos   = EasySharingMessages.Instance.ReadVector3(msg);
        Quaternion remoteCharaRot   = EasySharingMessages.Instance.ReadQuaternion(msg);
        Vector3    remoteCharaScale = EasySharingMessages.Instance.ReadVector3(msg);
        // キャラクタータイプを取得
        int remoteCharTypeInt = msg.ReadInt32();
        // データ反映
        RemoteCharacterInfo remoteCharaInfo = GetRemoteCharacterInfo(userID);

        if (remoteCharaInfo.characterType == CharacterType.None)
        {
            remoteCharaInfo.characterType   = remoteCharTypeInt == 0 ? CharacterType.Unity_Chan : CharacterType.Nanica_Chan;
            remoteCharaInfo.characterObject = Instantiate(prefabs[remoteCharTypeInt]);
            remoteCharaInfo.characterObject.transform.parent = transform;
            remoteCharaInfo.characterObject.name             = "remote player : " + userID;
            // remotePlayerのTransformControllerはけす
            remoteCharaInfo.characterObject.GetComponent <TransformControllerActivater>().enabled = false;
        }
        // Transformの設定
        remoteCharaInfo.characterObject.transform.localPosition = remoteCharaPos;
        remoteCharaInfo.characterObject.transform.localRotation = remoteCharaRot;
        remoteCharaInfo.characterObject.transform.localScale    = remoteCharaScale;
    }
예제 #2
0
    /// <summary>
    /// リストに入れるオブジェクトの生成
    /// </summary>
    /// <param name="userId"></param>
    /// <returns></returns>
    private RemoteCharacterInfo GetRemoteCharacterInfo(long userId)
    {
        RemoteCharacterInfo characterInfo;

        if (!remoteCharacters.TryGetValue(userId, out characterInfo))
        {
            characterInfo               = new RemoteCharacterInfo();
            characterInfo.UserID        = userId;
            characterInfo.characterType = CharacterType.None;

            remoteCharacters.Add(userId, characterInfo);
        }
        return(characterInfo);
    }