/// <summary> /// Throws the object to a given position by converting the final position to velocity. /// </summary> /// <param name="_finalPosition">Final position where the object is supposed to be at the end of the trajectory.</param> /// <param name="_angle">Throw angle.</param> /// <param name="_bonusDamage">Bonus damages added to the attack.</param> public virtual void Throw(Vector3 _finalPosition, float _angle, int _bonusDamage) { if (!isHeld) { return; } if (owner.photonView.isMine) { // Throw the throwable for other players TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, GetType(), "Throw"), new object[] { transform.position.x, transform.position.y, transform.position.z, _finalPosition.x, _finalPosition.y, _finalPosition.z, _angle, _bonusDamage }); } if (PhotonNetwork.isMasterClient) { ActivateHitbox(_bonusDamage); } transform.SetParent(null, true); rigidbody.isKinematic = false; rigidbody.velocity = TDS_ThrowUtility.GetProjectileVelocityAsVector3(transform.position, _finalPosition, _angle); collider.enabled = true; isHeld = false; owner.RemoveThrowable(); }
/// <summary> /// Set the animation state of the Fat Lady's animator. /// </summary> /// <param name="_state"></param> public void SetFatLadyAnim(FatLadyAnimState _state) { if (photonView.isMine) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, GetType(), "SetFatLadyAnim"), new object[] { (int)_state }); } switch (_state) { case FatLadyAnimState.Angry: animator.SetBool("IsAngry", true); break; case FatLadyAnimState.Cool: animator.SetBool("IsAngry", false); break; case FatLadyAnimState.Snack: animator.SetTrigger("Snack"); break; case FatLadyAnimState.PrepareAttack: animator.SetTrigger("PrepareAttack"); break; default: break; } }
/// <summary> /// Spawns a specific FX at a given position. /// </summary> /// <param name="_fxtype">Type of FX to instantiate.</param> /// <param name="_position">Position where to spawn the FX.</param> public void SpawnEffect(FXType _fxtype, Vector3 _position) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.All, TDS_RPCManager.GetInfo(photonView, GetType(), "SpawnEffect"), new object[] { (int)_fxtype, _position.x, _position.y, _position.z }); }
/// <summary> /// Instantiate the fire effect for burning. /// </summary> protected virtual void InstantiateFireEffect() { if (photonView.isMine) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "InstantiateFireEffect"), new object[] { }); } burnEffect = ((GameObject)Instantiate(Resources.Load("Fire"), new Vector3(transform.position.x, transform.position.y, transform.position.z - .05f), Quaternion.identity)).GetComponent <Animator>(); burnEffect.transform.SetParent(transform, true); }
/// <summary> /// Try to grab a throwable. /// When grabbed, the object follows the character and can be thrown by this one. /// </summary> /// <param name="_throwable">Throwable to try to grab.</param> /// <returns>Returns true if the throwable was successfully grabbed, false either.</returns> public virtual bool GrabObject(TDS_Throwable _throwable) { // Call this method in master client only if (!PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.MasterClient, TDS_RPCManager.GetInfo(photonView, GetType(), "GrabObject"), new object[] { _throwable.photonView.viewID }); return(false); } // Take the object if possible if (throwable || !_throwable.PickUp(this)) { return(false); } return(true); }
/// <summary> /// Set an animation state of the Fire Eater, used in the animator. /// </summary> /// <param name="_state">State to set in animation.</param> public void SetFireEaterAnim(FireEaterAnimState _state) { if (photonView.isMine) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, GetType(), "SetFireEaterAnim"), new object[] { (int)_state }); } switch (_state) { case FireEaterAnimState.Sober: animator.SetBool("IsDrunk", false); break; case FireEaterAnimState.Drunk: animator.SetBool("IsDrunk", true); break; case FireEaterAnimState.MiniGame: animator.ResetTrigger("Fire"); animator.SetInteger("FireID", 9999999); break; case FireEaterAnimState.Spit: animator.SetInteger("FireID", 9999999); break; case FireEaterAnimState.DoNotSpit: animator.SetInteger("FireID", -9999999); break; case FireEaterAnimState.Fire: animator.SetTrigger("Fire"); break; case FireEaterAnimState.Puke: animator.SetTrigger("Puke"); break; default: break; } }
/// <summary> /// Makes this object take damage and decrease its health if it is not invulnerable. /// </summary> /// <param name="_damage">Amount of damage this inflect to this object.</param> /// <returns>Returns true if some damages were inflicted, false if none.</returns> public virtual bool TakeDamage(int _damage) { if (IsInvulnerable || isDead) { return(false); } if (PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, GetType(), "TakeDamage"), new object[] { _damage }); } HealthCurrent -= _damage; OnTakeDamage?.Invoke(_damage); return(true); }
private void PlayRandomTaunt() { if (!audioSource || tauntAudioClips == null || tauntAudioClips.Length == 0) { return; } int _index = (int)Random.Range((int)0, (int)tauntAudioClips.Length); AudioClip _clip = tauntAudioClips[_index]; if (!_clip) { return; } if (audioSource.isPlaying) { audioSource.Stop(); } audioSource.clip = _clip; audioSource.volume = .25f; audioSource.Play(); if (PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "PlayTaunt"), new object[] { _index }); Invoke("PlayRandomTaunt", Random.Range(tauntRateMin, tauntRateMax)); } }
private void PlayCallOutSound(string _enemyName) { if (!audioSource) { return; } AudioClip _clip = null; switch (_enemyName) { case "Fakir": _clip = fakirAudioClip; break; case "Mime": _clip = mimeAudioClip; break; case "Acrobat": _clip = acrobatAudioClip; break; case "MightyMan": _clip = mightyManAudioClip; break; case "Cat": _clip = catAudioClip; break; default: return; } if (audioSource.isPlaying) { audioSource.Stop(); } audioSource.clip = _clip; audioSource.volume = .25f; audioSource.Play(); if (PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "PlayCallOutSound"), new object[] { _enemyName }); } }
/// <summary> /// Load the next level /// If Master client, send the information to the other players /// </summary> public void LoadLevel() { if (!PhotonNetwork.offlineMode) { characterSelectionManager.CharacterSelectionMenu.LocalElement.ClearToggle(); if (IsloadingNextScene) { //if (PhotonNetwork.isMasterClient) // TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "LoadLevel"), new object[] { }); TDS_SceneManager.Instance?.PrepareOnlineSceneLoading(TDS_GameManager.CurrentSceneIndex + 1, (int)UIState.InGame); } else { if (PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, GetType(), "LoadLevel"), new object[] { }); } TDS_LevelManager.Instance.Spawn(); ActivateMenu(UIState.InGame); } return; } if (IsloadingNextScene) { TDS_SceneManager.Instance?.PrepareSceneLoading(TDS_GameManager.CurrentSceneIndex + 1, (int)UIState.InGame); } else { TDS_LevelManager.Instance?.Spawn(); ActivateMenu(UIState.InGame); } characterSelectionManager.CharacterSelectionMenu.CharacterSelectionElements.ToList().ForEach(e => e.ClearToggle()); }
private void SetAnimationState(int _animationID) { switch ((CatAnimationState)_animationID) { case CatAnimationState.Idle: animator.SetBool("isRunning", false); break; case CatAnimationState.Run: animator.SetBool("isRunning", true); break; case CatAnimationState.Hit: animator.SetTrigger("HitTrigger"); break; case CatAnimationState.Jump: animator.SetTrigger("JumpTrigger"); break; case CatAnimationState.EndJump: animator.SetTrigger("EndJumpTrigger"); break; case CatAnimationState.Die: animator.SetBool("isDead", true); break; default: break; } if (PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "SetAnimationState"), new object[] { (int)_animationID }); } }
/// <summary> /// Activate or desactivate Menu depending of the uistate /// </summary> /// <param name="_state">State</param> public void ActivateMenu(UIState _state) { uiState = _state; switch (uiState) { case UIState.InMainMenu: TDS_SoundManager.Instance.PlayMusic(Music.TitleScreen, 1f); mainMenuParent.SetActive(true); roomSelectionMenuParent.SetActive(false); characterSelectionMenuParent.SetActive(false); inGameMenuParent.SetActive(false); pauseMenuParent.SetActive(false); gameOverScreenParent.SetActive(false); TDS_GameManager.PlayersInfo.Clear(); characterSelectionManager.CharacterSelectionMenu.CharacterSelectionElements.ToList().ForEach(e => e.ClearToggle()); Selectable.allSelectables.FirstOrDefault()?.Select(); break; case UIState.InRoomSelection: if (!PhotonNetwork.connected) { StartCoroutine(PrepareConnectionToPhoton()); break; } mainMenuParent.SetActive(false); roomSelectionMenuParent.SetActive(true); characterSelectionMenuParent.SetActive(false); inGameMenuParent.SetActive(false); pauseMenuParent.SetActive(false); gameOverScreenParent.SetActive(false); Selectable.allSelectables.FirstOrDefault()?.Select(); if (roomSelectionManager) { StartCoroutine(roomSelectionManager.UpdatePlayerCount()); } if (checkInputCoroutine != null) { StopCoroutine(checkInputCoroutine); } checkInputCoroutine = StartCoroutine(CheckInputMenu(UIState.InRoomSelection)); break; case UIState.InCharacterSelection: if (addPlayerText) { addPlayerText.gameObject.SetActive(PhotonNetwork.offlineMode); } mainMenuParent.SetActive(false); roomSelectionMenuParent.SetActive(false); characterSelectionMenuParent.SetActive(true); inGameMenuParent.SetActive(false); pauseMenuParent.SetActive(false); gameOverScreenParent.SetActive(false); if (checkInputCoroutine != null) { StopCoroutine(checkInputCoroutine); } checkInputCoroutine = StartCoroutine(CheckInputMenu(UIState.InCharacterSelection)); break; case UIState.InGame: mainMenuParent.SetActive(false); roomSelectionMenuParent.SetActive(false); characterSelectionMenuParent.SetActive(false); inGameMenuParent.SetActive(true); pauseMenuParent.SetActive(false); gameOverScreenParent.SetActive(false); if (checkInputCoroutine != null) { StopCoroutine(checkInputCoroutine); } checkInputCoroutine = StartCoroutine(CheckInputMenu(UIState.InGame)); break; case UIState.InPause: pauseMenuParent.SetActive(true); Selectable.allSelectables.FirstOrDefault()?.Select(); if (checkInputCoroutine != null) { StopCoroutine(checkInputCoroutine); } checkInputCoroutine = StartCoroutine(CheckInputMenu(UIState.InPause)); break; case UIState.InGameOver: mainMenuParent.SetActive(false); roomSelectionMenuParent.SetActive(false); characterSelectionMenuParent.SetActive(false); inGameMenuParent.SetActive(false); pauseMenuParent.SetActive(false); gameOverScreenParent.SetActive(true); Selectable.allSelectables.FirstOrDefault()?.Select(); StopAllCoroutines(); if (!PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.MasterClient, TDS_RPCManager.GetInfo(photonView, this.GetType(), "UpdateReadySettings"), new object[] { PhotonNetwork.player.ID, false }); } break; default: break; } }
public void StartLeavingRoom() { TDS_GameManager.PlayersInfo.Clear(); if (!TDS_GameManager.IsOnline) { PhotonNetwork.Disconnect(); PhotonNetwork.offlineMode = false; ActivateMenu(UIState.InMainMenu); Selectable.allSelectables.First().Select(); return; } if (PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "StartLeavingRoom"), new object[] { }); } StartCoroutine(characterSelectionManager.PreapreLeavingRoom()); roomSelectionManager.RoomSelectionElements.First().RoomSelectionButton.Select(); }
/// <summary> /// Call when the Restart Button is pressed /// If not master client, send a message to say the player is ready /// If master, send a message to everybody to reset the level /// </summary> public void OnRestartButtonPressed() { beardLadyLifeBar.ResetLifeBar(); fatLadyLifeBar.ResetLifeBar(); fireEaterLifeBar.ResetLifeBar(); jugglerLifeBar.ResetLifeBar(); if (PhotonNetwork.offlineMode) { ResetLevel(); return; } if (PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "ResetLevel"), new object[] { }); ResetLevel(); } else { TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.MasterClient, TDS_RPCManager.GetInfo(photonView, this.GetType(), "UpdateReadySettings"), new object[] { PhotonNetwork.player.ID, true }); } }
/// <summary> /// Makes the animal flee a certain collider. /// </summary> /// <param name="_collider">Collider to flee.</param> /// <returns></returns> protected override IEnumerator Flee(Collider _collider) { yield return(new WaitForSeconds(fleeDelay)); // Trigger animation SetAnimationOnline(1); float _xMinDistance = _collider.bounds.extents.x + detector.Collider.bounds.size.x; float _zMinDistance = _collider.bounds.extents.z + detector.Collider.bounds.size.z; Vector3 _actualDestination = new Vector3(); Vector3 _newDestination = new Vector3(); float _direction = 0; // Move while in range while ((Mathf.Abs(_direction = (detector.Collider.bounds.center.x - _collider.bounds.center.x)) < _xMinDistance) && (Mathf.Abs(_collider.bounds.center.z - detector.Collider.bounds.center.z) < _zMinDistance)) { _direction = Mathf.Sign(_direction); _newDestination = new Vector3(_collider.bounds.center.x + (_xMinDistance * 1.5f * _direction), transform.position.y, transform.position.z); if (_newDestination != _actualDestination) { if (_direction != isFacingRight.ToSign()) { transform.Rotate(Vector3.up, 180); transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y, transform.localScale.z * -1); isFacingRight = !isFacingRight; } // New destination ignored, got to be fixed _actualDestination = _newDestination; Debug.Log(_actualDestination); agent.SetDestination(_actualDestination); // Set destination for other clients TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, GetType(), "SetDestination"), new object[] { _actualDestination.x, _actualDestination.y, _actualDestination.z }); } yield return(null); } // Trigger animation SetAnimationOnline(0); fleeCoroutine = null; }
/// <summary> /// Inflict damages to a specified target. /// </summary> /// <param name="_target">Target to hit.</param> private void InflictDamages(TDS_Damageable _target) { // Attack the target if (CurrentAttack.Attack(this, _target) < -1) { return; } // Call local method on the character who hit if (Owner) { if (PhotonNetwork.offlineMode && (Owner is TDS_Player _player)) { _player.HitCallback(_target.Collider.bounds.center.x, _target.Collider.bounds.max.y, _target.transform.position.z); } else { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", Owner.photonView.owner, TDS_RPCManager.GetInfo(Owner.photonView, Owner.GetType(), "HitCallback"), new object[] { _target.Collider.bounds.center.x, _target.Collider.bounds.max.y, _target.transform.position.z }); } } // Triggers event OnTouch?.Invoke(); }
/// <summary> /// Load the scene async and display the loading screen during the loading time /// </summary> /// <param name="_sceneIndex">Index of the scene in the build</param> /// <returns></returns> private IEnumerator LoadSceneOnline(int _sceneIndex, int _nextUIState) { if (PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, GetType(), "PrepareOnlineSceneLoading"), new object[] { _sceneIndex, _nextUIState }); } TDS_UIManager.Instance?.DisplayLoadingScreen(true); yield return(new WaitForSeconds(1f)); AsyncOperation _async = SceneManager.LoadSceneAsync(_sceneIndex, LoadSceneMode.Single); while (!_async.isDone) { yield return(null); } TDS_GameManager.CurrentSceneIndex = _sceneIndex; if (PhotonNetwork.connected && PhotonNetwork.isMasterClient && PlayerSceneLoaded.Count > 0) { while (PlayerSceneLoaded.Any(p => p.Value == false)) { yield return(null); } TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "OnEverySceneReady"), new object[] { }); } else if (PhotonNetwork.connected && !PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.MasterClient, TDS_RPCManager.GetInfo(photonView, this.GetType(), "PlayerHasLoadScene"), new object[] { PhotonNetwork.player.ID }); while (!sceneIsReady) { yield return(null); } } // Call OnEveryOneSceneLoaded online OnEveryOneSceneLoaded(); TDS_UIManager.Instance.ActivateMenu(_nextUIState); }
/// <summary> /// Get the next destination of the rabbit and set it on the navmeshagent /// Flip the rabbit and invert its goright boolean /// </summary> private void Run() { if (!PhotonNetwork.isMasterClient) { return; } float _x = goRight ? boundRight : boundLeft; Vector3 _targetPosition = new Vector3(_x, transform.position.y, transform.position.z); goRight = !goRight; agent.SetDestination(_targetPosition); TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.All, TDS_RPCManager.GetInfo(photonView, this.GetType(), "Flip"), new object[] { }); }
/// <summary> /// Makes this object be healed and restore its health. /// </summary> /// <param name="_heal">Amount of health point to restore.</param> public virtual void Heal(int _heal) { if (PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "Heal"), new object[] { _heal }); } HealthCurrent += _heal; OnHeal?.Invoke(_heal); }
/// <summary> /// Called when a player catch the rabbit /// Heal the player and Destroy the rabbit /// </summary> /// <param name="_player"></param> public override void Use(TDS_Player _player) { if (!PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.MasterClient, TDS_RPCManager.GetInfo(photonView, GetType(), "UseOnline"), new object[] { _player.PhotonID }); return; } int _healingValue = UnityEngine.Random.Range(healingValueMin, healingValueMax); _player.Heal(_healingValue); OnUseRabbit?.Invoke(); TDS_VFXManager.Instance.SpawnEffect(FXType.RabbitPoof, transform.position + Vector3.up); PhotonNetwork.Destroy(gameObject); }
/// <summary> /// Destroys the fire effect object. /// </summary> protected virtual void DestroyFireEffect() { if (photonView.isMine) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "DestroyFireEffect"), new object[] { }); } if (burnEffect) { burnEffect.SetTrigger("Vanish"); } }
/// <summary> /// Select a new character (used in UnityEvent) /// </summary> /// <param name="_newPlayerType">Index of the enum PlayerType</param> public void SelectCharacterOnline() { if (TDS_GameManager.LocalIsReady) { OnLocalPlayerReadyOnline(false); return; } int _newPlayerType = (int)characterSelectionMenu.LocalElement.CurrentSelection.CharacterType; TDS_GameManager.LocalPlayer = (PlayerType)_newPlayerType; TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "UpdatePlayerSelectionInfo"), new object[] { _newPlayerType, PhotonNetwork.player.ID }); OnLocalPlayerReadyOnline(true); }
/// <summary> /// Drop the weared throwable. /// </summary> /// <returns>Returns true if successfully dropped the object, false if not having an object to drop.</returns> public virtual bool DropObject() { // Call this method in owner only if (!photonView.isMine) { TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", photonView.owner, TDS_RPCManager.GetInfo(photonView, GetType(), "DropObject"), new object[] { }); return(false); } // If no throwable, return if (!throwable) { return(false); } // Drooop throwable.Drop(); return(true); }
private void SendInfoToNewPlayer(PhotonPlayer _newPlayer) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", _newPlayer, TDS_RPCManager.GetInfo(photonView, this.GetType(), "ReceiveOnConnectionInfo"), new object[] { PhotonNetwork.player.ID, TDS_GameManager.LocalIsReady, (int)characterSelectionMenu.LocalElement.CurrentSelection.CharacterType }); }
/// <summary> /// Throws the weared throwable. /// </summary> /// <param name="_targetPosition">Position where the object should land</param> public virtual bool ThrowObject(Vector3 _targetPosition) { // Call this method in owner only if (!photonView.isMine) { TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", photonView.owner, TDS_RPCManager.GetInfo(photonView, GetType(), "ThrowObject_A"), new object[] { }); return(false); } // Return false if no throwable if (!throwable) { return(false); } // Alright, then throw it ! throwable.Throw(_targetPosition, aimAngle, RandomThrowBonusDamages); return(true); }
/// <summary> /// When a player select a new character, display the image of the character on the others players /// </summary> /// <param name="_player">Updated player</param> /// <param name="_newCharacterSelectionIndex">New Index</param> public void UpdateLocalCharacterIndex(PhotonPlayer _player, int _newCharacterSelectionIndex) { TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "UpdateOnlineCharacterIndex"), new object[] { _player.ID, _newCharacterSelectionIndex }); }
/// <summary> /// Set this destructible animation state. /// </summary> /// <param name="_state">New animation state of the destructible.</param> public void SetAnimationState(DestructibleAnimState _state) { // Online if (PhotonNetwork.isMasterClient) { // if (!animator) return; TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "SetAnimationState"), new object[] { (int)_state }); } switch (_state) { case DestructibleAnimState.Hit: animator.SetTrigger("Hit"); break; case DestructibleAnimState.Destruction: animator.SetTrigger("Destruction"); break; default: break; } }
/// <summary> /// Called when the toggle is pressed /// Update the ready settings /// If the player has an Unknown PlayerType, the game cannot start /// </summary> public void OnLocalPlayerReadyOnline(bool _isReady) { TDS_CharacterSelectionElement _elem = characterSelectionMenu.CharacterSelectionElements.Where(e => (e.PlayerInfo != null) && (e.PlayerInfo.PhotonPlayer == PhotonNetwork.player)).FirstOrDefault(); if (_elem == null) { return; } _elem.IsLocked = _isReady; TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.All, TDS_RPCManager.GetInfo(photonView, this.GetType(), "SetOnlinePlayerReady"), new object[] { PhotonNetwork.player.ID, TDS_GameManager.LocalIsReady }); if (!_isReady) { TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.All, TDS_RPCManager.GetInfo(photonView, this.GetType(), "UnlockPlayerType"), new object[] { (int)characterSelectionMenu.LocalElement.CurrentSelection.CharacterType }); } if (!PhotonNetwork.isMasterClient) { TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.MasterClient, TDS_RPCManager.GetInfo(photonView, typeof(TDS_UIManager), "UpdateReadySettings"), new object[] { PhotonNetwork.player.ID, TDS_GameManager.LocalIsReady }); return; } TDS_UIManager.Instance?.UpdateReadySettings(PhotonNetwork.player.ID, TDS_GameManager.LocalIsReady); }
/// <summary> /// Spawns a specific FX at a given position. /// </summary> /// <param name="_fxRype">Type of FX to instantiate.</param> /// <param name="_transformPhoton">PhotonView of the transform to use as FX parent.</param> public void SpawnEffect(FXType _fxRype, PhotonView _transformPhotonView) { if (PhotonNetwork.offlineMode) { Instantiate(GetFX((FXType)_fxRype), _transformPhotonView.transform, false); return; } TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.All, TDS_RPCManager.GetInfo(photonView, GetType(), "SpawnEffect"), new object[] { (int)_fxRype, _transformPhotonView }); }
/// <summary> /// Let a character pickup the object. /// </summary> /// <param name="_owner">Character attempting to pick up the object.</param> /// <returns>Returns true is successfully picked up the object, false if a issue has been encountered.</returns> public virtual bool PickUp(TDS_Character _owner) { if (isHeld || owner) { return(false); } isHeld = true; owner = _owner; owner.SetThrowable(this); if (PhotonNetwork.isMasterClient) { if (hitBox.IsActive) { hitBox.Desactivate(); } // Pickup the throwable for other players TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, GetType(), "PickUp"), new object[] { _owner.PhotonID }); } gameObject.layer = _owner.gameObject.layer; if (shadow && !shadow.activeInHierarchy) { shadow.SetActive(true); } rigidbody.isKinematic = true; collider.enabled = false; return(true); }