예제 #1
0
        private void Awake()
        {
            Prefab = "PlayerAnchor";
            //Loud settings from round
            MaxHealth    = (float)RoomManager.I.Settings["PlayerMaxHealth"];
            health       = MaxHealth;
            MaxInventory = (int)RoomManager.I.Settings["PlayerMaxInventory"];
            Squishiness  = (float)RoomManager.I.Settings["PlayerSquishiness"];



            MoveSpeed       = (float)RoomManager.I.Settings["PlayerMoveSpeed"];;
            RunFactor       = (float)RoomManager.I.Settings["PlayerRunFactor"];;
            StaminaMax      = (float)RoomManager.I.Settings["PlayerStaminaMax"];;
            StaminaRecovery = (float)RoomManager.I.Settings["PlayerStaminaRecovery"];;

            CrouchFactor = (float)RoomManager.I.Settings["PlayerCrouchFactor"];;
            CrawlFactor  = (float)RoomManager.I.Settings["PlayerCrawlFactor"];;

            JumpStrength = (float)RoomManager.I.Settings["PlayerJumpStrength"];;
            DriftControl = (float)RoomManager.I.Settings["PlayerDriftControl"];;

            ScaleFactor       = (float)RoomManager.I.Settings["PlayerScaleFactor"];;
            CrouchScaleFactor = (float)RoomManager.I.Settings["PlayerCrouchScaleFactor"];;
            CrawlScaleFactor  = (float)RoomManager.I.Settings["PlayerCrawlScaleFactor"];;

            pv    = gameObject.GetComponent <PhotonView>();
            Stats = MultiMenu.HUD.I.Status;
        }
    private void Awake()
    {
        Destroy(transform.parent.gameObject, 0.5f);
        photonView       = GetComponentInParent <Photon.Pun.PhotonView>();
        this.attack_type = (HitType)photonView.InstantiationData[0];

        model = JsonMapper.ToObject <ActorModel>(photonView.Owner.CustomProperties["model"].ToString());
    }
예제 #3
0
 private void OnTriggerEnter(Collider other)
 {
     Photon.Pun.PhotonView pv = other.GetComponent <Photon.Pun.PhotonView>();
     if (pv != null && pv.IsMine)
     {
         video.Play();
     }
 }
예제 #4
0
 private void Awake()
 {
     if (onlyChangeIfIsNotMine)
     {
         Photon.Pun.PhotonView pv = transform.root.GetComponentInChildren <Photon.Pun.PhotonView>();
         if (pv && !pv.IsMine)
         {
             SetLayerTo(transform, setToLayer);
         }
     }
     else
     {
         SetLayerTo(transform, setToLayer);
     }
 }
예제 #5
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.transform.root.tag == "Player" && !launched)
        {
            Photon.Pun.PhotonView pv = other.transform.root.GetComponent <Photon.Pun.PhotonView>();
            if (pv)
            {
                if (pv.IsMine)
                {
                    Launch(other.transform.root.GetComponent <Rigidbody>());
                    StartCoroutine(Wait());
                }

                if (audioSource)
                {
                    audioSource.Play();
                }
            }
        }
    }
예제 #6
0
    private void Start()
    {
        Photon.Pun.PhotonView photonView = GetComponent <Photon.Pun.PhotonView>();
        if (photonView && !photonView.IsMine)
        {
            Destroy(this);
            return;
        }

        //Busca el InputEventReceiver en la escena y se suscribe a los eventos que nos importan
        InputEventReceiver inputEventReceiver = FindObjectOfType <InputEventReceiver>();

        if (!inputEventReceiver)
        {
            Debug.LogWarning("HookInput necesita que exista un InputEventReceiver en la escena para funcionar.");
            return;
        }

        inputEventReceiver.AddListener(EventTriggerType.PointerDown, (data) => OnPointerDown(data as PointerEventData));
        inputEventReceiver.AddListener(EventTriggerType.PointerUp, (data) => OnPointerUp());
    }
예제 #7
0
 public static void createPV()
 {
     go = PhotonNetwork.Instantiate("NetworkHandler", new Vector3(), new Quaternion());
     PV = go.GetComponent <PhotonView>();
 }
예제 #8
0
 public static void destroyPV()
 {
     PhotonNetwork.Destroy(go);
     PV = null;
 }
예제 #9
0
        public override void OnInspectorGUI()
        {
            this.m_Target = (PhotonView)this.target;
            bool isProjectPrefab = PhotonEditorUtils.IsPrefab(this.m_Target.gameObject);
            bool multiSelected   = Selection.gameObjects.Length > 1;

            if (this.m_Target.ObservedComponents == null)
            {
                this.m_Target.ObservedComponents = new System.Collections.Generic.List <Component>();
            }

            if (this.m_Target.ObservedComponents.Count == 0)
            {
                this.m_Target.ObservedComponents.Add(null);
            }

            EditorGUILayout.BeginHorizontal();

            // Owner
            if (isProjectPrefab)
            {
                EditorGUILayout.LabelField("Owner", "<i>Set at runtime</i>", new GUIStyle("Label")
                {
                    richText = true
                }, GUILayout.MinWidth(120));
            }
            else if (!this.m_Target.IsOwnerActive)
            {
                EditorGUILayout.LabelField("Owner", "Scene", GUILayout.MinWidth(120));
            }
            else
            {
                Player owner     = this.m_Target.Owner;
                string ownerInfo = (owner != null) ? owner.NickName : "<no Player found>";

                if (string.IsNullOrEmpty(ownerInfo))
                {
                    ownerInfo = "<no playername set>";
                }

                EditorGUILayout.LabelField("Owner [" + this.m_Target.OwnerActorNr + "] " + ownerInfo, GUILayout.MinWidth(120));
            }

            // ownership requests
            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            OwnershipOption own = (OwnershipOption)EditorGUILayout.EnumPopup(this.m_Target.OwnershipTransfer, GUILayout.MaxWidth(68), GUILayout.MinWidth(68));

            if (own != this.m_Target.OwnershipTransfer)
            {
                // jf: fixed 5 and up prefab not accepting changes if you quit Unity straight after change.
                // not touching the define nor the rest of the code to avoid bringing more problem than solving.
                EditorUtility.SetDirty(this.m_Target);

                Undo.RecordObject(this.m_Target, "Change PhotonView Ownership Transfer");
                this.m_Target.OwnershipTransfer = own;
            }
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndHorizontal();


            // View ID - Hide if we are multi-selected
            if (!multiSelected)
            {
                if (isProjectPrefab)
                {
                    EditorGUILayout.LabelField("View ID", "<i>Set at runtime</i>", new GUIStyle("Label")
                    {
                        richText = true
                    });
                }
                else if (EditorApplication.isPlaying)
                {
                    EditorGUILayout.LabelField("View ID", this.m_Target.ViewID.ToString());
                }
                else
                {
                    int idValue = EditorGUILayout.IntField("View ID [1.." + (PhotonNetwork.MAX_VIEW_IDS - 1) + "]", this.m_Target.ViewID);
                    if (this.m_Target.ViewID != idValue)
                    {
                        Undo.RecordObject(this.m_Target, "Change PhotonView viewID");
                        this.m_Target.ViewID = idValue;
                    }
                }
            }

            // Locally Controlled
            if (EditorApplication.isPlaying)
            {
                string masterClientHint = PhotonNetwork.IsMasterClient ? "(master)" : "";
                EditorGUILayout.Toggle("Controlled locally: " + masterClientHint, this.m_Target.IsMine);
            }

            // ViewSynchronization (reliability)
            if (this.m_Target.Synchronization == ViewSynchronization.Off)
            {
                GUI.color = Color.grey;
            }

            EditorGUILayout.PropertyField(this.serializedObject.FindProperty("Synchronization"), syncronizationGuiContent);

            GUI.color = Color.white;

            if (this.m_Target.Synchronization != ViewSynchronization.Off)
            {
                if (this.m_Target.ObservedComponents.FindAll(item => item != null).Count == 0)
                {
                    EditorGUILayout.HelpBox("Setting the synchronization option only makes sense if you observe something.", MessageType.Warning);
                }
            }
            else
            {
                // Show warning if there are any observables. The null check is because the list allows nulls.
                if (Selection.gameObjects.Length == 1)
                {
                    var observed = m_Target.ObservedComponents;
                    if (observed.Count > 0)
                    {
                        for (int i = 0, cnt = observed.Count; i < cnt; ++i)
                        {
                            if (observed[i] != null)
                            {
                                EditorGUILayout.HelpBox("Observe Option is set to Off. Select a Syncronization setting in order to sync the listed Observables.", MessageType.Warning);
                                break;
                            }
                        }
                    }
                }
            }

            //GUILayout.Space(5);

            PhotonView.ObservableSearch autoFindObservables = (PhotonView.ObservableSearch)EditorGUILayout.EnumPopup(findObservablesGuiContent, m_Target.observableSearch);

            if (m_Target.observableSearch != autoFindObservables)
            {
                Undo.RecordObject(this.m_Target, "Change Auto Find Observables Toggle");
                m_Target.observableSearch = autoFindObservables;
            }

            m_Target.FindObservables();

            if (!multiSelected)
            {
                EditorGUI.BeginDisabledGroup(autoFindObservables != PhotonView.ObservableSearch.Manual);
                this.DrawObservedComponentsList(autoFindObservables != PhotonView.ObservableSearch.Manual);
                EditorGUI.EndDisabledGroup();
            }

            // Cleanup: save and fix look
            if (GUI.changed)
            {
                PhotonViewHandler.OnHierarchyChanged(); // TODO: check if needed
            }

            GUI.color = Color.white;
        }
예제 #10
0
 public PhotonMessageInfo(Player player, int timestamp, PhotonView view)
 {
     this.Sender     = player;
     this.timeInt    = timestamp;
     this.photonView = view;
 }
예제 #11
0
        public override void OnInspectorGUI()
        {
            this.m_Target = (PhotonView)this.target;
            bool isProjectPrefab = PhotonEditorUtils.IsPrefab(this.m_Target.gameObject);
            bool multiSelected   = Selection.gameObjects.Length > 1;

            if (this.m_Target.ObservedComponents == null)
            {
                this.m_Target.ObservedComponents = new System.Collections.Generic.List <Component>();
            }

            if (this.m_Target.ObservedComponents.Count == 0)
            {
                this.m_Target.ObservedComponents.Add(null);
            }

            GUILayout.Space(5);

            EditorGUILayout.BeginVertical((GUIStyle)"HelpBox");
            // View ID - Hide if we are multi-selected
            if (!multiSelected)
            {
                if (isProjectPrefab)
                {
                    EditorGUILayout.LabelField("View ID", "<i>Set at runtime</i>", new GUIStyle("Label")
                    {
                        richText = true
                    });
                }
                else if (EditorApplication.isPlaying)
                {
                    EditorGUILayout.LabelField("View ID", this.m_Target.ViewID.ToString());
                }
                else
                {
                    int idValue = EditorGUILayout.IntField("View ID [1.." + (PhotonNetwork.MAX_VIEW_IDS - 1) + "]", this.m_Target.ViewID);
                    if (this.m_Target.ViewID != idValue)
                    {
                        Undo.RecordObject(this.m_Target, "Change PhotonView viewID");
                        this.m_Target.ViewID = idValue;
                    }
                }
            }

            // Locally Controlled
            if (EditorApplication.isPlaying)
            {
                string masterClientHint = PhotonNetwork.IsMasterClient ? " (master)" : "";
                EditorGUILayout.LabelField("IsMine:", this.m_Target.IsMine.ToString() + masterClientHint);
                Room   room    = PhotonNetwork.CurrentRoom;
                int    cretrId = this.m_Target.CreatorActorNr;
                Player cretr   = (room != null) ? room.GetPlayer(cretrId) : null;
                Player owner   = this.m_Target.Owner;
                Player ctrlr   = this.m_Target.Controller;
                EditorGUILayout.LabelField("Controller:", (ctrlr != null ? ("[" + ctrlr.ActorNumber + "] '" + ctrlr.NickName + "' " + (ctrlr.IsMasterClient ? " (master)" : "")) : "[0] <null>"));
                EditorGUILayout.LabelField("Owner:", (owner != null ? ("[" + owner.ActorNumber + "] '" + owner.NickName + "' " + (owner.IsMasterClient ? " (master)" : "")) : "[0] <null>"));
                EditorGUILayout.LabelField("Creator:", (cretr != null ? ("[" + cretrId + "] '" + cretr.NickName + "' " + (cretr.IsMasterClient ? " (master)" : "")) : "[0] <null>"));
            }

            EditorGUILayout.EndVertical();

            EditorGUI.BeginDisabledGroup(Application.isPlaying);

            GUILayout.Space(5);

            // Ownership section

            EditorGUILayout.LabelField("Ownership", (GUIStyle)"BoldLabel");

            OwnershipOption own = (OwnershipOption)EditorGUILayout.EnumPopup(ownerTransferGuiContent, this.m_Target.OwnershipTransfer /*, GUILayout.MaxWidth(68), GUILayout.MinWidth(68)*/);

            if (own != this.m_Target.OwnershipTransfer)
            {
                // jf: fixed 5 and up prefab not accepting changes if you quit Unity straight after change.
                // not touching the define nor the rest of the code to avoid bringing more problem than solving.
                EditorUtility.SetDirty(this.m_Target);

                Undo.RecordObject(this.m_Target, "Change PhotonView Ownership Transfer");
                this.m_Target.OwnershipTransfer = own;
            }


            GUILayout.Space(5);

            // Observables section

            EditorGUILayout.LabelField("Observables", (GUIStyle)"BoldLabel");

            EditorGUILayout.PropertyField(this.serializedObject.FindProperty("Synchronization"), syncronizationGuiContent);

            if (this.m_Target.Synchronization == ViewSynchronization.Off)
            {
                // Show warning if there are any observables. The null check is because the list allows nulls.
                var observed = m_Target.ObservedComponents;
                if (observed.Count > 0)
                {
                    for (int i = 0, cnt = observed.Count; i < cnt; ++i)
                    {
                        if (observed[i] != null)
                        {
                            EditorGUILayout.HelpBox("Syncronization is set to Off. Select a Syncronization setting in order to sync the listed Observables.", MessageType.Warning);
                            break;
                        }
                    }
                }
            }


            PhotonView.ObservableSearch autoFindObservables = (PhotonView.ObservableSearch)EditorGUILayout.EnumPopup(observableSearchGuiContent, m_Target.observableSearch);

            if (m_Target.observableSearch != autoFindObservables)
            {
                Undo.RecordObject(this.m_Target, "Change Auto Find Observables Toggle");
                m_Target.observableSearch = autoFindObservables;
            }

            m_Target.FindObservables();

            if (!multiSelected)
            {
                bool disableList = Application.isPlaying || autoFindObservables != PhotonView.ObservableSearch.Manual;

                if (disableList)
                {
                    EditorGUI.BeginDisabledGroup(true);
                }

                this.DrawObservedComponentsList(disableList);

                if (disableList)
                {
                    EditorGUI.EndDisabledGroup();
                }
            }

            // Cleanup: save and fix look
            if (GUI.changed)
            {
                PhotonViewHandler.OnHierarchyChanged(); // TODO: check if needed
            }

            EditorGUI.EndDisabledGroup();
        }
예제 #12
0
 private void Awake()
 {
     this.m_PhotonView = GetComponent <PhotonView>();
     this.m_Animator   = GetComponent <Animator>();
 }
예제 #13
0
        internal static void OnHierarchyChanged()
        {
            // set prefabs to viewID 0 if needed
            // organize resource PVs in a list per viewID

            // process the lists: if more than one photonView is in a list, we have to resolve the clash
            // check if only one view had the viewId earlier
            // apply a new viewID to the others

            // update the cached list of instances and their viewID


            //Debug.LogWarning("OnHierarchyChanged(). isPlaying: " + Application.isPlaying);
            if (Application.isPlaying)
            {
                return;
            }


            PhotonView[]      photonViewResources = Resources.FindObjectsOfTypeAll <PhotonView>();
            List <PhotonView> photonViewInstances = new List <PhotonView>();
            Dictionary <int, List <PhotonView> > viewInstancesPerViewId = new Dictionary <int, List <PhotonView> >();
            List <PhotonView> photonViewsToReassign = new List <PhotonView>();

            foreach (PhotonView view in photonViewResources)
            {
                if (PhotonEditorUtils.IsPrefab(view.gameObject))
                {
                    if (view.ViewID != 0)
                    {
                        view.ViewID = 0;
                        EditorUtility.SetDirty(view);
                    }
                    continue;   // skip prefabs
                }

                photonViewInstances.Add(view);


                // assign a new viewID if the viewId is lower than the minimum for this scene
                if (!IsViewIdOkForScene(view))
                {
                    photonViewsToReassign.Add(view);
                    continue;   // this view definitely gets cleaned up, so it does not count versus duplicates, checked below
                }


                // organize the viewInstances into lists per viewID, so we know duplicate usage
                if (!viewInstancesPerViewId.ContainsKey(view.sceneViewId))
                {
                    viewInstancesPerViewId[view.sceneViewId] = new List <PhotonView>();
                }
                viewInstancesPerViewId[view.sceneViewId].Add(view);
            }

            //Debug.Log("PreviousAssignments: "+PunSceneViews.Instance.Views.Count);

            foreach (List <PhotonView> list in viewInstancesPerViewId.Values)
            {
                if (list.Count <= 1)
                {
                    continue;   // skip lists with just one entry (the viewID is unique)
                }


                PhotonView previousAssignment = null;
                bool       wasAssigned        = PunSceneViews.Instance.Views.TryGetValue(list[0].sceneViewId, out previousAssignment);

                foreach (PhotonView view in list)
                {
                    if (wasAssigned && view.Equals(previousAssignment))
                    {
                        // previously, we cached the used viewID as assigned to the current view. we don't change this.
                        continue;
                    }

                    //Debug.LogWarning("View to reassign due to viewID: "+view, view.gameObject);
                    photonViewsToReassign.Add(view);
                }
            }

            int i;

            foreach (PhotonView view in photonViewsToReassign)
            {
                i = MinSceneViewId(view);
                while (viewInstancesPerViewId.ContainsKey(i))
                {
                    i++;
                }
                view.sceneViewId = i;
                viewInstancesPerViewId.Add(i, null);    // we don't need the lists anymore but we care about getting the viewIDs listed
                EditorUtility.SetDirty(view);
            }


            // update the "semi persistent" list of viewIDs and their PhotonViews
            PunSceneViews.Instance.Views.Clear();
            foreach (PhotonView view in photonViewInstances)
            {
                if (PunSceneViews.Instance.Views.ContainsKey(view.sceneViewId))
                {
                    Debug.LogError("ViewIDs should no longer have duplicates! " + view.sceneViewId, view);
                    continue;
                }

                PunSceneViews.Instance.Views[view.sceneViewId] = view;
            }

            //Debug.Log("photonViewsToReassign.Count: "+photonViewsToReassign.Count + " count of viewIDs in use: "+viewInstancesPerViewId.Values.Count);
            //Debug.Log("PreviousAssignments now counts: "+PunSceneViews.Instance.Views.Count);
        }
예제 #14
0
 private static bool IsViewIdOkForScene(PhotonView view)
 {
     return(view.sceneViewId >= MinSceneViewId(view));
 }
예제 #15
0
        private static int MinSceneViewId(PhotonView view)
        {
            int result = PunSceneSettings.MinViewIdForScene(view.gameObject.scene.name);

            return(result);
        }
        public override void OnInspectorGUI()
        {
            this.m_Target = (PhotonView)this.target;
            bool isProjectPrefab = PhotonEditorUtils.IsPrefab(this.m_Target.gameObject);

            if (this.m_Target.ObservedComponents == null)
            {
                this.m_Target.ObservedComponents = new System.Collections.Generic.List <Component>();
            }

            if (this.m_Target.ObservedComponents.Count == 0)
            {
                this.m_Target.ObservedComponents.Add(null);
            }

            EditorGUILayout.BeginHorizontal();
            // Owner
            if (isProjectPrefab)
            {
                EditorGUILayout.LabelField("Owner:", "Set at runtime");
            }
            else if (!this.m_Target.IsOwnerActive)
            {
                EditorGUILayout.LabelField("Owner", "Scene");
            }
            else
            {
                Player owner     = this.m_Target.Owner;
                string ownerInfo = (owner != null) ? owner.NickName : "<no Player found>";

                if (string.IsNullOrEmpty(ownerInfo))
                {
                    ownerInfo = "<no playername set>";
                }

                EditorGUILayout.LabelField("Owner", "[" + this.m_Target.OwnerActorNr + "] " + ownerInfo);
            }

            // ownership requests
            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            OwnershipOption own = (OwnershipOption)EditorGUILayout.EnumPopup(this.m_Target.OwnershipTransfer, GUILayout.Width(100));

            if (own != this.m_Target.OwnershipTransfer)
            {
                // jf: fixed 5 and up prefab not accepting changes if you quit Unity straight after change.
                // not touching the define nor the rest of the code to avoid bringing more problem than solving.
                EditorUtility.SetDirty(this.m_Target);

                Undo.RecordObject(this.m_Target, "Change PhotonView Ownership Transfer");
                this.m_Target.OwnershipTransfer = own;
            }
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndHorizontal();


            // View ID
            if (isProjectPrefab)
            {
                EditorGUILayout.LabelField("View ID", "Set at runtime");
            }
            else if (EditorApplication.isPlaying)
            {
                EditorGUILayout.LabelField("View ID", this.m_Target.ViewID.ToString());
            }
            else
            {
                int idValue = EditorGUILayout.IntField("View ID [1.." + (PhotonNetwork.MAX_VIEW_IDS - 1) + "]", this.m_Target.ViewID);
                if (this.m_Target.ViewID != idValue)
                {
                    Undo.RecordObject(this.m_Target, "Change PhotonView viewID");
                    this.m_Target.ViewID = idValue;
                }
            }

            // Locally Controlled
            if (EditorApplication.isPlaying)
            {
                string masterClientHint = PhotonNetwork.IsMasterClient ? "(master)" : "";
                EditorGUILayout.Toggle("Controlled locally: " + masterClientHint, this.m_Target.IsMine);
            }

            // ViewSynchronization (reliability)
            if (this.m_Target.Synchronization == ViewSynchronization.Off)
            {
                GUI.color = Color.grey;
            }

            EditorGUILayout.PropertyField(this.serializedObject.FindProperty("Synchronization"), new GUIContent("Observe option:"));

            if (this.m_Target.Synchronization != ViewSynchronization.Off && this.m_Target.ObservedComponents.FindAll(item => item != null).Count == 0)
            {
                GUILayout.BeginVertical(GUI.skin.box);
                GUILayout.Label("Warning", EditorStyles.boldLabel);
                GUILayout.Label("Setting the synchronization option only makes sense if you observe something.");
                GUILayout.EndVertical();
            }

            GUI.color = Color.white;
            this.DrawObservedComponentsList();

            // Cleanup: save and fix look
            if (GUI.changed)
            {
                PhotonViewHandler.HierarchyChange(); // TODO: check if needed
            }

            GUI.color = Color.white;
        }