Exemplo n.º 1
0
    public override void Activate()
    {
        //Duke
        //Dev for IK setup 3/15/2017
        RootMotion.FinalIK.AimIK aimIK = _combatHandler.GetComponent <RootMotion.FinalIK.AimIK>();
        if (aimIK)
        {
            aimIK.enabled = true;
        }

        if (_animator.GetCurrentAnimatorStateInfo(0).fullPathHash != AnimationHashHelper.STATE_GROUNDED)
        {
            return;
        }

        SetCancel(false);
        base.Activate();

        if (_combatHandler.GetRopeCount() < 1)
        {
            Debug.LogWarning("WARNING : Ropecount shouldn't be less than 1 here, check and fix");
        }

//		_combatHandler.SetRopeCount (_combatHandler.GetRopeCount () - 1);
    }
Exemplo n.º 2
0
 void Start()
 {
     this.animator = GetComponent<Animator>();
     this.targetIk = GetComponent<AimIK>();
     this.targetIk.solver.target = WeaponLocator;
     this.IKWeight = targetIk.solver.IKPositionWeight;
 }
Exemplo n.º 3
0
    public override void Deactivate()
    {
        //Duke
        //Dev for IK setup 3/15/2017
        RootMotion.FinalIK.AimIK aimIK = _combatHandler.GetComponent <RootMotion.FinalIK.AimIK>();
        if (aimIK)
        {
            aimIK.enabled = false;
        }

        //If this Deactivate was NOT called by parent
        if (!cancel)
        {
            ShootArrow();
        }

        //Normal Deactivate
        //stop animating (set trigger to false)
        //set ability status to be used again
        //unlock controls
        //		_animator.SetBool (_animHash, false);
        //		_status = ABILITY_STATUS.AVAILABLE;
        //		Invoke ("unlockControls", 0.2f);
        base.Deactivate();
    }
Exemplo n.º 4
0
    public void Initialize()
    {
        this.MyAnimator = GetComponentInChildren<Animator>();
        this.MyReference = GetComponentInChildren<CharacterReference>();
        this.MyEventHandler = GetComponentInChildren<CharacterEventHandler>();

        this.MyReference.ParentCharacter = this;

        //setup animator parameters initial values
        this.MyAnimator.SetBool("IsAiming", false);
        this.MyAnimator.SetBool("IsSneaking", false);

        this.Destination = transform.position;
        MyNavAgent = GetComponent<NavMeshAgent>();
        UpperBodyState = HumanUpperBodyStates.Idle;
        ActionState = HumanActionStates.None;

        //load aim target and look target
        GameObject aimTarget = (GameObject)GameObject.Instantiate(Resources.Load("IKAimTargetRoot"));
        GameObject lookTarget = (GameObject)GameObject.Instantiate(Resources.Load("IKLookTarget"));
        AimTargetRoot = aimTarget.transform;
        AimTarget = AimTargetRoot.Find("IKAimTarget").transform;
        LookTarget = lookTarget.transform;

        this.MyAimIK = GetComponentInChildren<AimIK>();
        this.MyAimIK.solver.target = AimTarget;
        this.MyAimIK.solver.IKPositionWeight = 0;
        this.MyAimIK.solver.SmoothDisable();

        this.MyLeftHandIK = GetComponentInChildren<LeftHandIKControl>();
        this.MyLeftHandIK.Initialize();

        this.MyHeadIK = GetComponentInChildren<LookAtIK>();
        this.MyHeadIK.solver.target = LookTarget;

        this.MyStatus = new CharacterStatus();
        this.MyStatus.Initialize();

        //each time a human char is initialized it's added to NPC manager's list of human characters to keep track of
        GameManager.Inst.NPCManager.AddHumanCharacter(this);

        CurrentAnimState = new HumanAnimStateIdle(this);
        //SendCommand(HumanCharCommands.Unarm);

        MyAI = GetComponent<AI>();
        MyAI.Initialize(this);

        //subscribe events
        this.MyEventHandler.OnLongGunPullOutFinish += OnLongGunPullOutFinish;
        this.MyEventHandler.OnLongGunPutAwayFinish += OnLongGunPutAwayFinish;
        this.MyEventHandler.OnPistolPullOutFinish += OnPistolPullOutFinish;
        this.MyEventHandler.OnPistolPutAwayFinish += OnPistolPutAwayFinish;
        this.MyEventHandler.OnReloadFinish += OnReloadFinish;
        this.MyEventHandler.OnThrowFinish += OnThrowFinish;
        this.MyEventHandler.OnThrowLeaveHand += OnThrowLeaveHand;
        this.MyEventHandler.OnBulletInjury += OnBulletInjury;
        this.MyEventHandler.OnDeath += OnDeath;
    }
		protected override void Start() {
			base.Start();
			
			// Find the IK components
			aim = GetComponent<AimIK>();
			ik = GetComponent<FullBodyBipedIK>();
			
			// Disable the IK components to manage their updating
			aim.enabled = false;
			ik.enabled = false;

			// Presuming head is rotated towards character forward at Start
			headLookAxis = ik.references.head.InverseTransformVector(ik.references.root.forward);
			
			// Enable the upper-body aiming pose
			animator.SetLayerWeight(1, 1f);
		}
Exemplo n.º 6
0
    public override void Activate()
    {
        //Duke
        //Dev for IK setup 3/15/2017
        RootMotion.FinalIK.AimIK aimIK = _combatHandler.GetComponent <RootMotion.FinalIK.AimIK> ();
        if (aimIK)
        {
            aimIK.enabled = true;
        }

        if (_animator.GetCurrentAnimatorStateInfo(0).fullPathHash != AnimationHashHelper.STATE_GROUNDED)
        {
            return;
        }
        SetCancel(false);
        base.Activate();
    }
Exemplo n.º 7
0
    //Duke
    //Dev for IK setup 3/15/2017
    void Update()
    {
        if (!_combatHandler.GetComponent <PhotonView> ().isMine || _status != ABILITY_STATUS.IN_USE)
        {
            return;
        }

        RootMotion.FinalIK.AimIK aimIK = _combatHandler.GetComponent <RootMotion.FinalIK.AimIK> ();

        if (aimIK)
        {
            _IK_Bow.localPosition = _IK_Bow_Pos;
            _IK_Bow.localRotation = _IK_Bow_Rot;

            _aimTarget.position = CameraController.CC.CombatCamera.transform.position + CameraController.CC.CombatCamera.transform.forward * 20f;
            //			_aimTarget.position = _shootingPoint.position + _shootingPoint.forward * 20f;

            Vector3    rPos = _aimTarget.transform.position - _combatHandler.transform.position;
            Quaternion tRot = Quaternion.LookRotation(rPos);
            tRot = Quaternion.Euler(new Vector3(0f, tRot.eulerAngles.y, 0f));

//			float angle = Vector3.Angle (_combatHandler.transform.position, _aimTarget.position);
            float angle = Mathf.Abs((tRot.eulerAngles - _combatHandler.transform.eulerAngles).magnitude);

//			print (angle);

            if (angle > 15f)
            {
                Vector3 relPos = _aimTarget.transform.position - _combatHandler.transform.position;
                //				Quaternion targetRot = Quaternion.LookRotation (_aimTarget.transform.position, _combatHandler.transform.position);
                Quaternion targetRot = Quaternion.LookRotation(relPos);
                targetRot = Quaternion.Euler(new Vector3(0f, targetRot.eulerAngles.y, 0f));
                _combatHandler.transform.rotation = Quaternion.Lerp(_combatHandler.transform.rotation, targetRot, Time.deltaTime * 3.5f);
            }
        }
        else
        {
            print("AIM_IK is null");
        }
    }
Exemplo n.º 8
0
    //Duke
    //Dev for IK setup 3/15/2017
    void Update()
    {
//		print (GetStatus ().ToString ());

        if (!_combatHandler.GetComponent <PhotonView> ().isMine || _status != ABILITY_STATUS.IN_USE)
        {
            return;
        }

        RootMotion.FinalIK.AimIK aimIK = _combatHandler.GetComponent <RootMotion.FinalIK.AimIK>();
        if (aimIK)
        {
            _aimTarget.position = CameraController.CC.CombatCamera.transform.position + CameraController.CC.CombatCamera.transform.forward * 100f;
            float angle = Vector3.Angle(_combatHandler.transform.forward, _aimTarget.position);
            //			print (angle);
            if (angle > 95f)
            {
                Quaternion targetRot = Quaternion.LookRotation(_aimTarget.transform.position, _combatHandler.transform.position);
                targetRot = Quaternion.Euler(new Vector3(0f, targetRot.eulerAngles.y, 0f));
                _combatHandler.transform.rotation = Quaternion.Lerp(_combatHandler.transform.rotation, targetRot, Time.deltaTime * 1.5f);
            }
        }
    }
Exemplo n.º 9
0
	public override void LoadCharacterModel (string prefabName)
	{
		if(this.Model != null)
		{
			GameObject.Destroy(this.Model);
		}

		GameObject o = GameObject.Instantiate(Resources.Load(prefabName)) as GameObject;
		o.transform.parent = this.transform;
		o.transform.localPosition = Vector3.zero;
		o.transform.localEulerAngles = Vector3.zero;

		this.MyAnimator = o.transform.GetComponent<Animator>();
		this.MyReference = o.transform.GetComponent<CharacterReference>();
		this.MyAnimEventHandler = o.transform.GetComponent<AnimationEventHandler>();

		this.MyReference.ParentCharacter = this;

		if(this.MyReference.FixedMeleeLeft != null)
		{
			this.MyReference.FixedMeleeLeft.Attacker = this;
			this.MyReference.FixedMeleeLeft.Rebuild(null, null);
		}

		if(this.MyReference.FixedMeleeRight != null)
		{
			this.MyReference.FixedMeleeRight.Attacker = this;
			this.MyReference.FixedMeleeRight.Rebuild(null, null);
		}

		this.MyAimIK = o.transform.GetComponent<AimIK>();
		this.MyAimIK.solver.target = AimTarget;
		this.MyAimIK.solver.IKPositionWeight = 0;
		this.MyAimIK.solver.SmoothDisable();

		this.MyLeftHandIK = o.transform.GetComponent<LeftHandIKControl>();
		this.MyLeftHandIK.Initialize();

		this.MyHeadIK = o.transform.GetComponent<HeadIKControl>();
		this.MyHeadIK.Initialize();
		this.MyHeadIK.LookTarget = LookTarget;


		//setup animator parameters initial values
		this.MyAnimator.SetInteger("AlertLevel", 0);

		this.Model = o;
		this.Model.name = prefabName;

		if(this.MyAI != null)
		{
			this.MyAI.BlackBoard.EquippedWeapon = null;
		}


		//subscribe events
		this.MyAnimEventHandler.OnMeleeStrikeLeftFinish -= OnMeleeStrikeFinish;
		this.MyAnimEventHandler.OnMeleeStrikeLeftFinish += OnMeleeStrikeFinish;

		this.MyAnimEventHandler.OnMeleeStrikeRightFinish -= OnMeleeStrikeFinish;
		this.MyAnimEventHandler.OnMeleeStrikeRightFinish += OnMeleeStrikeFinish;

		this.MyAnimEventHandler.OnMeleeBlocked -= OnMeleeBlocked;
		this.MyAnimEventHandler.OnMeleeBlocked += OnMeleeBlocked;

		this.MyAnimEventHandler.OnHitReover -= OnInjuryRecover;
		this.MyAnimEventHandler.OnHitReover += OnInjuryRecover;

		this.MyAnimEventHandler.OnAnimationActionEnd -= OnAnimationActionEnd;
		this.MyAnimEventHandler.OnAnimationActionEnd += OnAnimationActionEnd;
	}
Exemplo n.º 10
0
 void Start()
 {
     aim = gameObject.GetComponent<AimIK>();
 }
        protected override void Start()
        {
            base.Start();

            // Find the IK components
            aim = GetComponent<AimIK>();
            ik = GetComponent<FullBodyBipedIK>();

            // Disable the IK components to manage their updating
            aim.Disable();
            ik.Disable();

            fpsCamDefaultRot = firstPersonCam.transform.localRotation;
        }
Exemplo n.º 12
0
	public override void LoadCharacterModel(string prefabName)
	{
		if(this.Model != null)
		{
			GameObject.Destroy(this.Model);
		}

		GameObject o = GameObject.Instantiate(Resources.Load(prefabName)) as GameObject;
		o.transform.parent = this.transform;
		o.transform.localPosition = Vector3.zero;
		o.transform.localEulerAngles = Vector3.zero;

		this.MyAnimator = o.transform.GetComponent<Animator>();
		this.MyReference = o.transform.GetComponent<CharacterReference>();
		this.MyAnimEventHandler = o.transform.GetComponent<AnimationEventHandler>();

		this.MyReference.ParentCharacter = this;

		this.MyAimIK = o.transform.GetComponent<AimIK>();
		this.MyAimIK.solver.target = AimTarget;
		this.MyAimIK.solver.IKPositionWeight = 0;
		this.MyAimIK.solver.SmoothDisable();

		this.MyLeftHandIK = o.transform.GetComponent<LeftHandIKControl>();
		this.MyLeftHandIK.Initialize();

		this.MyHeadIK = o.transform.GetComponent<HeadIKControl>();
		this.MyHeadIK.Initialize();
		this.MyHeadIK.LookTarget = LookTarget;


		//setup animator parameters initial values
		this.MyAnimator.SetBool("IsAiming", false);
		this.MyAnimator.SetBool("IsSneaking", false);

		this.Model = o;
		this.Model.name = prefabName;

		if(this.MyAI != null)
		{
			this.MyAI.BlackBoard.EquippedWeapon = null;
		}


		//subscribe events
		this.MyAnimEventHandler.OnLongGunPullOutFinish -= OnLongGunPullOutFinish;
		this.MyAnimEventHandler.OnLongGunPullOutFinish += OnLongGunPullOutFinish;

		this.MyAnimEventHandler.OnLongGunPutAwayFinish -= OnLongGunPutAwayFinish;
		this.MyAnimEventHandler.OnLongGunPutAwayFinish += OnLongGunPutAwayFinish;

		this.MyAnimEventHandler.OnPistolPullOutFinish -= OnPistolPullOutFinish;
		this.MyAnimEventHandler.OnPistolPullOutFinish += OnPistolPullOutFinish;

		this.MyAnimEventHandler.OnPistolPutAwayFinish -= OnPistolPutAwayFinish;
		this.MyAnimEventHandler.OnPistolPutAwayFinish += OnPistolPutAwayFinish;

		this.MyAnimEventHandler.OnGrenadePullOutFinish -= OnGrenadePullOutFinish;
		this.MyAnimEventHandler.OnGrenadePullOutFinish += OnGrenadePullOutFinish;

		this.MyAnimEventHandler.OnMeleePullOutFinish -= OnMeleePullOutFinish;
		this.MyAnimEventHandler.OnMeleePullOutFinish += OnMeleePullOutFinish;

		this.MyAnimEventHandler.OnReloadFinish -= OnReloadFinish;
		this.MyAnimEventHandler.OnReloadFinish += OnReloadFinish;

		this.MyAnimEventHandler.OnThrowFinish -= OnThrowFinish;
		this.MyAnimEventHandler.OnThrowFinish += OnThrowFinish;

		this.MyAnimEventHandler.OnThrowLeaveHand -= OnThrowLeaveHand;
		this.MyAnimEventHandler.OnThrowLeaveHand += OnThrowLeaveHand;

		this.MyAnimEventHandler.OnStartStrangle -= OnStartStrangle;
		this.MyAnimEventHandler.OnStartStrangle += OnStartStrangle;

		this.MyAnimEventHandler.OnEndStrangle -= OnEndStrangle;
		this.MyAnimEventHandler.OnEndStrangle += OnEndStrangle;

		this.MyAnimEventHandler.OnDeath -= OnDeath;
		this.MyAnimEventHandler.OnDeath += OnDeath;

		this.MyAnimEventHandler.OnStrangledDeath -= OnStrangledDeath;
		this.MyAnimEventHandler.OnStrangledDeath += OnStrangledDeath;

		this.MyAnimEventHandler.OnHitReover -= OnInjuryRecover;
		this.MyAnimEventHandler.OnHitReover += OnInjuryRecover;

		this.MyAnimEventHandler.OnSwitchWeapon -= OnSwitchWeapon;
		this.MyAnimEventHandler.OnSwitchWeapon += OnSwitchWeapon;

		this.MyAnimEventHandler.OnFinishTakeObject -= OnTakeObjectFinish;
		this.MyAnimEventHandler.OnFinishTakeObject += OnTakeObjectFinish;

		this.MyAnimEventHandler.OnMeleeStrikeHalfWay -= OnMeleeStrikeHalfWay;
		this.MyAnimEventHandler.OnMeleeStrikeHalfWay += OnMeleeStrikeHalfWay;

		this.MyAnimEventHandler.OnMeleeComboStageTwo -= OnMeleeComboStageTwo;
		this.MyAnimEventHandler.OnMeleeComboStageTwo += OnMeleeComboStageTwo;

		this.MyAnimEventHandler.OnMeleeStrikeLeftFinish -= OnMeleeStrikeLeftFinish;
		this.MyAnimEventHandler.OnMeleeStrikeLeftFinish += OnMeleeStrikeLeftFinish;

		this.MyAnimEventHandler.OnMeleeStrikeRightFinish -= OnMeleeStrikeRightFinish;
		this.MyAnimEventHandler.OnMeleeStrikeRightFinish += OnMeleeStrikeRightFinish;

		this.MyAnimEventHandler.OnMeleeBlockFinish -= OnMeleeBlockFinish;
		this.MyAnimEventHandler.OnMeleeBlockFinish += OnMeleeBlockFinish;
	}