예제 #1
0
 void Awake()
 {
     inPublicRoom = PlayerPrefs.GetInt("isInPublicWorld");
     friendsPreviousAccessories = new Dictionary <int, List <GameObject> >();
     itemLoader = GameObject.FindGameObjectWithTag("ItemLoader");
     if (!photonView.IsMine)
     {
         otherPlayer = true;
         if (inPublicRoom == 1)
         {
             ChatManager = (GameObject.FindGameObjectWithTag("ChatManager") as GameObject).GetComponent <PublicWorldChatManager>();
         }
     }
     else
     {
         charSetup = PlayerPrefs.GetString("myCharacter");
         SetUpCharacter(charSetup);
         mainCam = Resources.Load("Main Camera") as GameObject;
         mainCam = Instantiate(mainCam);
         PlayerFollow cameraScript = mainCam.GetComponent <PlayerFollow>();
         cameraScript.SetCameraTarget(characterController.transform, inPublicRoom);
         GameObject itemControllerObject = GameObject.FindGameObjectWithTag("ItemPlacementController") as GameObject;
         PV                 = transform.GetComponent <PhotonView>();
         username           = PlayerPrefs.GetString("username");
         previousAccesories = new List <GameObject>();
         PV.RPC("RPC_ChangeCharacterName", RpcTarget.AllBuffered, username, PV.ViewID);
         PV.RPC("RPC_SetCharacterAccessories", RpcTarget.AllBuffered, charSetup, PV.ViewID);
         if (inPublicRoom == 1)
         {
             ChatManager = (GameObject.FindGameObjectWithTag("ChatManager") as GameObject).GetComponent <PublicWorldChatManager>();
             ChatManager.SetMainCharacter(this);
             publicWorldInterestGroup = -1;
             currentlyTalkingTo       = "";
             GameObject.FindGameObjectWithTag("Canvas").GetComponent <InputHandler>().SetTarget(this);
             itemLoader.GetComponent <ItemLoaderStore>().ShareProperties(mainCam.GetComponent <PlayerFollow>(), transform);
             uiManager = itemLoader.GetComponent <ItemLoaderStore>().ReturnUIManager();
             uiManager.GetComponent <UIManagerPublicScript>().AddPlayerToOtherComponents(this);
             uiManager.GetComponent <UIManagerPublicScript>().SetSitDownListeners(SitDown, StandUp);
             SetParticipateInConvoCollider();
             StartCoroutine(ActivateChat());
         }
         else
         {
             roomID   = PlayerPrefs.GetString("currentRoomID");
             myRoomID = PlayerPrefs.GetString("myRoomID");
             myRoom   = roomID == myRoomID;
             itemLoader.GetComponent <ItemLoader>().SetCamera(mainCam.GetComponent <PlayerFollow>());
             uiManager = itemLoader.GetComponent <ItemLoader>().ReturnUIManager();
             uiManager.GetComponent <UIManagerScript>().SetSitDownListeners(SitDown, StandUp);
             uiManager.GetComponent <UIManagerScript>().SetGamingManagerCharacter(this);
             uiManager.GetComponent <UIManagerScript>().AddCameraToCustomizer(mainCam.GetComponent <PlayerFollow>());
             SetParticipateInConvoCollider();
             if (myRoom)
             {
                 GameObject itemController = GameObject.FindGameObjectWithTag("ItemPlacementController");
                 itemController.GetComponent <ItemPlacementController>().SetTarget(transform);
                 CharacterChange charChange = GameObject.FindGameObjectWithTag("CharacterChange").GetComponent <CharacterChange>();
                 charChange.SetTargetCharacter(this);
                 // charChange.UpdateAccessories(accessories);
                 GameObject notificationManager = GameObject.FindGameObjectWithTag("NotificationManager");
                 notificationManager.GetComponent <InnerNotifManagerScript>().SetCharacterTarget(transform, username, myRoomID);
             }
             else
             {
                 GameObject notificationManager = GameObject.FindGameObjectWithTag("NotificationManager");
                 notificationManager.GetComponent <InnerNotifManagerScript>().SetCoinsforUser(username);
             }
         }
     }
 }