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.MyReference.LiveCollider = transform.GetComponent <CapsuleCollider>(); if (this.MyReference.DeathCollider != null) { this.MyReference.DeathCollider.GetComponent <DeathCollider>().ParentCharacter = this; this.MyReference.DeathCollider.enabled = false; } 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; this.MyAnimEventHandler.OnMeleeStrikeHalfWay -= OnMeleeStrikeHalfWay; this.MyAnimEventHandler.OnMeleeStrikeHalfWay += OnMeleeStrikeHalfWay; this.MyAnimEventHandler.OnStartStrangle -= OnStartStrangle; this.MyAnimEventHandler.OnStartStrangle += OnStartStrangle; this.MyAnimEventHandler.OnEndStrangle -= OnEndStrangle; this.MyAnimEventHandler.OnEndStrangle += OnEndStrangle; this.MyAnimEventHandler.OnFootStep -= OnFootStep; this.MyAnimEventHandler.OnFootStep += OnFootStep; }
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; }
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; }