public override void SendCommand(HumanCharCommands command) { switch(command) { case HumanCharCommands.StopCrouch: UpdateState(HumanBodyStates.StandIdle); break; case HumanCharCommands.ThrowGrenade: break; case HumanCharCommands.FinishThrow: break; } }
public override void SendCommand(HumanCharCommands command) { switch(command) { case HumanCharCommands.GoToPosition: UpdateState(HumanBodyStates.WalkForward); break; case HumanCharCommands.Crouch: UpdateState(HumanBodyStates.CrouchIdle); break; case HumanCharCommands.ThrowGrenade: _aimFreelookAngle = 0; _noAimFreelookAngle = 0; break; case HumanCharCommands.FinishThrow: _aimFreelookAngle = 45; _noAimFreelookAngle = 60; break; } }
public override void SendCommand(HumanCharCommands command) { //following commands are not given by AI or user. All commands that will unlock the body go here if(IsBodyLocked) { return; } //following commands are given by AI or user, and can be locked CurrentAnimState.SendCommand(command); if(command == HumanCharCommands.Crouch) { CapsuleCollider collider = GetComponent<CapsuleCollider>(); collider.height = 1.3f; collider.center = new Vector3(0, 0.6f, 0); } if(command == HumanCharCommands.StopCrouch) { CapsuleCollider collider = GetComponent<CapsuleCollider>(); collider.height = 1.7f; collider.center = new Vector3(0, 1, 0); } if(command == HumanCharCommands.Aim && GetCurrentAnimWeapon() != WeaponAnimType.Unarmed && CurrentStance != HumanStances.Sprint) { if(ActionState == HumanActionStates.None) { UpperBodyState = HumanUpperBodyStates.Aim; MyAimIK.solver.SmoothEnable(2.5f); MyLeftHandIK.SmoothEnable(); MyHeadIK.solver.SmoothDisable(); MyAnimator.SetBool("IsAiming", true); //StartCoroutine(WaitAndEnableAimIK(0.2f)); } else if(ActionState == HumanActionStates.SwitchWeapon) { UpperBodyState = HumanUpperBodyStates.Aim; } } if(command == HumanCharCommands.StopAim && ActionState == HumanActionStates.None) { UpperBodyState = HumanUpperBodyStates.Idle; MyAimIK.solver.SmoothDisable(9); MyHeadIK.solver.SmoothEnable(); MyAnimator.SetBool("IsAiming", false); if(GetCurrentAnimWeapon() == WeaponAnimType.Pistol) { MyLeftHandIK.SmoothDisable(9); } //Debug.Log("stopping aim"); } if(command == HumanCharCommands.Sprint) { if(CurrentStance == HumanStances.Crouch || CurrentStance == HumanStances.CrouchRun) { CurrentStance = HumanStances.CrouchRun; } else { CurrentStance = HumanStances.Sprint; MyAimIK.solver.SmoothDisable(); MyHeadIK.solver.SmoothDisable(); } } if(command == HumanCharCommands.StopSprint) { if(UpperBodyState == HumanUpperBodyStates.Aim) { MyAimIK.solver.SmoothEnable(); } if(CurrentStance == HumanStances.CrouchRun || CurrentStance == HumanStances.Crouch) { CurrentStance = HumanStances.Crouch; } else { CurrentStance = HumanStances.Run; } MyHeadIK.solver.SmoothEnable(); } if(command == HumanCharCommands.SwitchWeapon2) { Debug.Log("current human action state " + ActionState); if(ActionState == HumanActionStates.None) { MyLeftHandIK.SmoothDisable(15); MyAimIK.solver.SmoothDisable(9); MyAnimator.SetInteger("WeaponType", 2); SwitchWeapon("AK47"); ActionState = HumanActionStates.SwitchWeapon; } } if(command == HumanCharCommands.SwitchWeapon1) { if(ActionState == HumanActionStates.None) { if(UpperBodyState == HumanUpperBodyStates.Aim) { //MyLeftHandIK.SmoothEnable(); } else { } MyLeftHandIK.SmoothDisable(15); MyAimIK.solver.SmoothDisable(9); MyAnimator.SetInteger("WeaponType", 1); SwitchWeapon("44MagnumRevolver"); ActionState = HumanActionStates.SwitchWeapon; } } if(command == HumanCharCommands.Unarm) { if(ActionState == HumanActionStates.None) { MyLeftHandIK.SmoothDisable(); UpperBodyState = HumanUpperBodyStates.Idle; MyAimIK.solver.SmoothDisable(); MyHeadIK.solver.SmoothEnable(); MyAnimator.SetBool("IsAiming", false); MyAnimator.SetInteger("WeaponType", 0); SwitchWeapon(""); ActionState = HumanActionStates.SwitchWeapon; } } if(command == HumanCharCommands.PullTrigger) { if(ActionState != HumanActionStates.None || UpperBodyState != HumanUpperBodyStates.Aim) { return; } if(GetCurrentAnimWeapon() == WeaponAnimType.Longgun || GetCurrentAnimWeapon() == WeaponAnimType.Pistol) { // this.MyReference.CurrentWeapon.GetComponent<Gun>().TriggerPull(); } } if(command == HumanCharCommands.ReleaseTrigger) { if(ActionState != HumanActionStates.None || UpperBodyState != HumanUpperBodyStates.Aim) { return; } if(GetCurrentAnimWeapon() == WeaponAnimType.Longgun || GetCurrentAnimWeapon() == WeaponAnimType.Pistol) { // this.MyReference.CurrentWeapon.GetComponent<Gun>().TriggerRelease(); } } if(command == HumanCharCommands.Reload) { if(ActionState == HumanActionStates.None && this.MyReference.CurrentWeapon != null) { if(GetCurrentAnimWeapon() == WeaponAnimType.Longgun || GetCurrentAnimWeapon() == WeaponAnimType.Pistol) { MyAimIK.solver.SmoothDisable(); MyAnimator.SetTrigger("Reload"); MyLeftHandIK.SmoothDisable(); } MyHeadIK.solver.SmoothDisable(); ActionState = HumanActionStates.Reload; } } if(command == HumanCharCommands.CancelReload) { if(ActionState == HumanActionStates.Reload && this.MyReference.CurrentWeapon != null) { Debug.Log("cancel reload"); if(UpperBodyState == HumanUpperBodyStates.Aim) { MyAimIK.solver.SmoothEnable(); MyAnimator.SetTrigger("CancelReload"); } else { MyAnimator.SetTrigger("CancelReload"); } if(MyAnimator.GetInteger("WeaponType") == (int)WeaponAnimType.Longgun) { MyLeftHandIK.SmoothEnable(); } else { Debug.Log("done reloading pistol " + UpperBodyState); if(UpperBodyState == HumanUpperBodyStates.Aim) { MyLeftHandIK.SmoothEnable(); } else { MyLeftHandIK.SmoothDisable(); } } MyHeadIK.solver.SmoothEnable(); ActionState = HumanActionStates.None; } } if(command == HumanCharCommands.ThrowGrenade) { if(ActionState != HumanActionStates.None) { return; } if(UpperBodyState == HumanUpperBodyStates.Aim) { //MyAimIK.solver.SmoothDisable(); } if(this.MyReference.CurrentWeapon != null && MyAnimator.GetInteger("WeaponType") == (int)WeaponAnimType.Longgun) { MyLeftHandIK.SmoothEnable(); } //MyHeadIK.solver.SmoothDisable(1); //move weapon to torso mount so that right hand is free if(this.MyReference.CurrentWeapon != null) { this.MyReference.CurrentWeapon.transform.parent = this.MyReference.TorsoWeaponMount.transform; } MyAnimator.SetTrigger("ThrowGrenade"); _throwTarget = this.AimPoint; _throwDir = this.AimPoint - transform.position; IsBodyLocked = true; ActionState = HumanActionStates.Throw; _thrownObjectInHand = ((GameObject)GameObject.Instantiate(Resources.Load("TestGrenade"))).GetComponent<ThrownObject>(); _thrownObjectInHand.GetComponent<Rigidbody>().isKinematic = true; _thrownObjectInHand.transform.parent = this.MyReference.RightHandWeaponMount.transform; _thrownObjectInHand.transform.localPosition = _thrownObjectInHand.InHandPosition; _thrownObjectInHand.transform.localEulerAngles = _thrownObjectInHand.InHandRotation; } }
public abstract void SendCommand(HumanCharCommands command);
public override void SendCommand(HumanCharCommands command) { }