예제 #1
0
    public override void SetCombatHandler(CombatHandler ch)
    {
        base.SetCombatHandler(ch);

        if (ch.GetRopeCount() > 0)
        {
            SetStatus(ABILITY_STATUS.AVAILABLE);
        }
    }
예제 #2
0
    void Update()
    {
        if (!photonView.isMine || GameController.GC.CurrentPlayerCharacter == null || Owner == null)
        {
            return;
        }

        if (Owner.transform != GameController.GC.CurrentPlayerCharacter)
        {
            return;
        }

        _intSys = StartTarget.GetComponent <InteractionSystem> ();

        _rb = StartTarget.GetComponent <Rigidbody> ();

        //retrieve if close to either of the point
        float retrievalDist = 2f;

        if (Owner == GameController.GC.CurrentPlayerCharacter.GetComponent <CombatHandler> () &&
            (Vector3.Distance(Owner.transform.position, EndPoint.position) < retrievalDist ||
             Vector3.Distance(Owner.transform.position, StartPoint.position) < retrievalDist))
        {
            if (Input.GetButtonDown(InputHelper.UNROPE) && !Owner.CheckAbilitiesInUse())
            {
//				print ("Rope retrieved");
                Destroy();
                Owner.SetRopeCount(Owner.GetRopeCount() + 1);
            }
        }

        if (StartTarget.transform != GameController.GC.CurrentPlayerCharacter)
        {
            return;
        }

        if (IsSetup && StartTarget.gameObject == Owner.gameObject && _rb != null)
        {
            //move while hanging(swinging)
            if (Input.GetKey(KeyCode.W) && !_grounded && _isEndPointHigher)
            {
                if (_holdRopeDistance > 0)
                {
                    _rb.velocity += CameraController.CC.CombatCamera.transform.forward * 3f * Time.deltaTime;
                }
            }

            //destroy when unrope
            if (Input.GetButtonDown(InputHelper.UNROPE) && !Owner.CheckAbilitiesInUse())
            {
                if (EndTarget.GetComponent <RopeArrow> ())
                {
                    Destroy(EndTarget.gameObject);
                }
                Destroy();
//				StartTarget.GetComponent<CombatHandler> ().SetRopeCount (StartTarget.GetComponent<CombatHandler> ().GetRopeCount () + 1);
            }

//			//rope length adjust when hanging
//			if (!_grounded && _isEndPointHigher && _holdRopeDistance != 0f) {
//				if (Input.GetKey (KeyCode.LeftShift)) {
//					if (_holdRopeDistance < 0f) {
//						_holdRopeDistance = 0f;
////						print ("Rope retrieved by adjusting length");
////						Destroy ();
////						Owner.SetRopeCount (Owner.GetRopeCount () + 1);
//					} else {
////						print ("shortening : " + _holdRopeDistance);
//						_holdRopeDistance -= _lengthAdjustStrength * Time.deltaTime;
//					}
//				}
//				if (Input.GetKey (KeyCode.Space)) {
//					if (_holdRopeDistance > _maxRopeDistance) {
//						_holdRopeDistance = _maxRopeDistance;
//					} else {
////						print ("extending : " + _holdRopeDistance);
//						_holdRopeDistance += _lengthAdjustStrength * Time.deltaTime;
//					}
//				}
//			}
        }
    }