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; }
public void OnDeath() { float posture = UnityEngine.Random.Range(0, 200)/200f; this.MyAnimator.SetFloat("DeathPosture", posture); this.MyAnimator.SetTrigger("Death"); CurrentAnimState = new HumanAnimStateDeath(this); IsBodyLocked = true; MyAimIK.solver.SmoothDisable(9); MyLeftHandIK.SmoothDisable(12); MyHeadIK.solver.SmoothDisable(9); }
// This constructor will create new state taking values from old state public HumanAnimStateSneakIdle(HumanAnimStateBase state) : this(state.ParentCharacter) { }
// This constructor will create new state taking values from old state public HumanAnimStateIdle(HumanAnimStateBase state) :this(state.ParentCharacter) { }
// This constructor will create new state taking values from old state public HumanAnimStateGoForward(HumanAnimStateBase state) : this(state.ParentCharacter) { }
// This constructor will create new state taking values from old state public HumanAnimStateSneakForward(HumanAnimStateBase state) : this(state.ParentCharacter) { }
// This constructor will create new state taking values from old state public HumanAnimStateAction(HumanAnimStateBase state) : this(state.ParentCharacter) { }
// This constructor will create new state taking values from old state public HumanAnimStateDeath(HumanAnimStateBase state) : this(state.ParentCharacter) { }
public void Initialize() { //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; LoadCharacterModel(this.CharacterID); this.MyEventHandler = GetComponent<CharacterEventHandler>(); this.Destination = transform.position; MyNavAgent = GetComponent<NavMeshAgent>(); UpperBodyState = HumanUpperBodyStates.Idle; ActionState = HumanActionStates.None; Markers = new CharacterMarkerSet(); this.MyStatus = new CharacterStatus(); this.MyStatus.Initialize(); this.Stealth = new CharacterStealth(this); this.Inventory = new CharacterInventory(); //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(CharacterCommands.Unarm); MyAI = GetComponent<AI>(); MyAI.Initialize(this); this.ArmorSystem = new ArmorSystem(this); _meleeStrikeStage = 0; _isLowThrow = false; }
public void OnStrangledDeath() { MyStatus.Health = 0; MyAI.OnDeath(); Stealth.OnDeath(); CurrentAnimState = new HumanAnimStateDeath(this); IsBodyLocked = true; MyAimIK.solver.SmoothDisable(9); MyLeftHandIK.SmoothDisable(12); MyHeadIK.SmoothDisable(9); MyNavAgent.enabled = false; MyReference.Flashlight.Toggle(false); CapsuleCollider collider = GetComponent<CapsuleCollider>(); collider.height = 0.5f; collider.radius = 0.6f; collider.center = new Vector3(0, 0, 0); collider.isTrigger = true; }
public void OnDeath() { MyAI.OnDeath(); Stealth.OnDeath(); float posture = UnityEngine.Random.Range(0.1f, 200)/200f; this.MyAnimator.SetFloat("DeathPosture", posture); this.MyAnimator.SetBool("IsDead", true); CurrentAnimState = new HumanAnimStateDeath(this); IsBodyLocked = true; MyAimIK.solver.SmoothDisable(9); MyLeftHandIK.SmoothDisable(12); MyHeadIK.SmoothDisable(9); MyNavAgent.enabled = false; MyReference.Flashlight.Toggle(false); CapsuleCollider collider = GetComponent<CapsuleCollider>(); collider.height = 0.5f; collider.radius = 0.6f; collider.center = new Vector3(0, 0, 0); collider.isTrigger = true; }