private void Start() { if (GetComponent <Animator> () != null) { _animator = GetComponent <Animator> (); } else { print("WARNING : Animator not loaded"); } // get the transform of the main camera if (Camera.main != null) { _Cam = Camera.main.transform; } else { Debug.LogWarning( "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls."); // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them! } // get the third person character ( this should never be null due to require component ) _PMH = GetComponent <CharacterMovementHandler> (); _isTurnAllowed = true; }
void Start() { _player = GameObject.FindWithTag("Player"); _attacker = GetComponent <Attacker>(); _health = GetComponent <Health>(); _initialPosition = transform.position; _mover = GetComponent <CharacterMovementHandler>(); }
/// <summary> /// Handles dealing damage to the contact object(enemy) /// Also handles pushback and staggering the target. /// </summary> /// <param name="osh">Target's ObjectStatusHandler</param> protected void dealDamange(ObjectStatusHandler osh) { //inflict damage osh.SubtractHealth(_weapon.GetDamage()); //disable hit target's damaging points if (_weapon.GetDisablesTargetDamagingPointOnhit()) { if (osh.GetComponent <CombatHandler> ()) { // disableDamagingPoints (osh.GetComponent<CombatHandler> ()); osh.GetComponent <CombatHandler> ().DisableDamagingPoints(); } } //add to ultimate guage _weapon.GetOwner().AddUltimatePoint(_weapon.GetDamage() / 25); //add more if it's a killing blow if (osh.GetHealth() - _weapon.GetDamage() <= 0) { _weapon.GetOwner().AddUltimatePoint(5); } //drop if hanging CharacterMovementHandler cmh = osh.GetComponent <CharacterMovementHandler> (); // HangHandler hh = cmh.HangHandler; if (cmh && cmh.Hanging) { // hh.HangToDrop (); cmh.HangToDrop(); } else { //push object back //Duke (8/6/2016) //BUG : disabled because push direction changes as target rotates. make it absolute direction //Log : //Duke(8/11/2016) : Code is correct, suspect problem with pre-existing photon view enemies. Instantiating all characters may solve it. Enabled pushback to test it. //Duke(8/27/2016) : Problem occured again, there must be something wrong // Seems to be fixed with setting position i nstead of translate pushBack(osh, _pushDuration); //if character, stagger it //Note : Stagger animation will transit from AnyState for minions and certain character via animator // Player characters at the moment does not have AnyState linked to Stagger, so their action will not get interrupted by getting attack CharacterStatusHandler csh = osh.GetComponent <CharacterStatusHandler> (); if (csh != null) { // csh.Stagger (_pushDuration); csh.Stagger(_staggerDuration); } } }
public void Destroy() { CharacterMovementHandler cmh = StartTarget.GetComponent <CharacterMovementHandler> (); if (cmh) { cmh.Roped = false; if (_rb != null && _rb.gameObject == GameController.GC.CurrentPlayerCharacter) { _rb.drag = 1f; } } cmh = EndPoint.GetComponent <CharacterMovementHandler> (); if (cmh) { cmh.Roped = false; } // print ("Destroying rope"); //destroy spikes if (StartAttachPoint.parent != null && StartAttachPoint.parent.name.Contains("RopeSpike")) { Destroy(StartAttachPoint.parent.gameObject); } if (EndAttachPoint.parent != null && EndAttachPoint.parent.name.Contains("RopeSpike")) { Destroy(EndAttachPoint.parent.gameObject); } //destory arrows if (StartAttachPoint.name.Contains("RopeArrow")) { Destroy(StartAttachPoint.gameObject); } if (EndAttachPoint.name.Contains("RopeArrow")) { Destroy(EndAttachPoint.gameObject); } Owner.MyRope = null; if (StartTarget.GetComponent <CombatHandler> ()) { StartTarget.GetComponent <CombatHandler> ().RopeSlotStart = null; } if (EndTarget.GetComponent <CombatHandler> ()) { EndTarget.GetComponent <CombatHandler> ().RopeSlotEnd = null; } PhotonNetwork.Destroy(gameObject); }
void LateUpdate() { if (!photonView.isMine) { return; } if (GameController.GC.CurrentPlayerCharacter == null || Owner == null || Owner.transform != GameController.GC.CurrentPlayerCharacter) { return; } CharacterMovementHandler cmh = StartTarget.GetComponent <CharacterMovementHandler> (); if (cmh) { cmh.Roped = false; if (_rb != null && _rb.gameObject == GameController.GC.CurrentPlayerCharacter) { _rb.drag = 1f; } } cmh = EndPoint.GetComponent <CharacterMovementHandler> (); if (cmh) { cmh.Roped = false; } //rotate body //Since it moves character rig, it must be in LateUpdate(after animation calculation is finished) //Also cannot smooth(Lerp or etc) as last position isn't accurate if (!_grounded && _isEndPointHigher) { // print ("Endpoint is higher than startpoint"); Vector3 lookDir; if (_bendingPoint != null) { lookDir = ((Vector3)_bendingPoint - StartPoint.position).normalized; } else { lookDir = (EndPoint.position - StartPoint.position).normalized; } Quaternion lookRot = Quaternion.LookRotation(lookDir); // StartAttachPoint.parent.transform.rotation = lookRot; StartAttachPoint.transform.rotation = lookRot; // cmh = StartTarget.GetComponent <CharacterMovementHandler> (); if (cmh) { cmh.Roped = true; if (_rb != null && _rb.transform == GameController.GC.CurrentPlayerCharacter) { _rb.drag = 0.1f; // print ("Setting drag : " + _rb.name); // Debug.Break (); } else { // print (_rb.name); } } cmh = EndPoint.GetComponent <CharacterMovementHandler> (); if (cmh) { cmh.Roped = true; } } else { // print (_grounded.ToString () + ", " + _isEndPointHigher.ToString ()); } }
void Start() { _characterMovementHandler = GetComponent <CharacterMovementHandler>(); }