Commit baadb64f authored by czy's avatar czy

物理模拟击退效果,

parent 362a1dd4
...@@ -8466,3 +8466,10 @@ AnimationClip: ...@@ -8466,3 +8466,10 @@ AnimationClip:
floatParameter: 0 floatParameter: 0
intParameter: 2 intParameter: 2
messageOptions: 0 messageOptions: 0
- time: 1.8333334
functionName: ChangeAttackType
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
intParameter: 0
messageOptions: 0
...@@ -31,12 +31,12 @@ AnimationClip: ...@@ -31,12 +31,12 @@ AnimationClip:
m_AdditiveReferencePoseClip: {fileID: 0} m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0 m_AdditiveReferencePoseTime: 0
m_StartTime: 0 m_StartTime: 0
m_StopTime: 0.98333335 m_StopTime: 1
m_OrientationOffsetY: 0 m_OrientationOffsetY: 0
m_Level: 0 m_Level: 0
m_CycleOffset: 0 m_CycleOffset: 0
m_HasAdditiveReferencePose: 0 m_HasAdditiveReferencePose: 0
m_LoopTime: 1 m_LoopTime: 0
m_LoopBlend: 0 m_LoopBlend: 0
m_LoopBlendOrientation: 0 m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0 m_LoopBlendPositionY: 0
...@@ -51,8 +51,15 @@ AnimationClip: ...@@ -51,8 +51,15 @@ AnimationClip:
m_HasGenericRootTransform: 0 m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0 m_HasMotionFloatCurves: 0
m_Events: m_Events:
- time: 0.98333335 - time: 0
functionName: HurricaneKickBeforEnd functionName: ChangeAttackType
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
intParameter: 0
messageOptions: 0
- time: 1
functionName: ChangeAttackType
data: data:
objectReferenceParameter: {fileID: 0} objectReferenceParameter: {fileID: 0}
floatParameter: 0 floatParameter: 0
......
fileFormatVersion: 2 fileFormatVersion: 2
guid: d266a3801edfb2d4ebf814eeea93f5d2 guid: 1e8ba1c691d0bb6409b39a59d55e5c4b
NativeFormatImporter: NativeFormatImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 0 mainObjectFileID: 0
......
...@@ -37079,10 +37079,17 @@ AnimationClip: ...@@ -37079,10 +37079,17 @@ AnimationClip:
m_HasGenericRootTransform: 0 m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0 m_HasMotionFloatCurves: 0
m_Events: m_Events:
- time: 0 - time: 0.6
functionName: ChangeAttackType functionName: ChangeAttackType
data: data:
objectReferenceParameter: {fileID: 0} objectReferenceParameter: {fileID: 0}
floatParameter: 0 floatParameter: 0
intParameter: 1 intParameter: 1
messageOptions: 0 messageOptions: 0
- time: 1.4666667
functionName: ChangeAttackType
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
intParameter: 0
messageOptions: 0
...@@ -6,7 +6,7 @@ AnimationClip: ...@@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: Running2 m_Name: RunningBoss2
serializedVersion: 6 serializedVersion: 6
m_Legacy: 0 m_Legacy: 0
m_Compressed: 0 m_Compressed: 0
......
...@@ -161,9 +161,9 @@ AnimatorStateTransition: ...@@ -161,9 +161,9 @@ AnimatorStateTransition:
m_Mute: 0 m_Mute: 0
m_IsExit: 0 m_IsExit: 0
serializedVersion: 3 serializedVersion: 3
m_TransitionDuration: 0.25 m_TransitionDuration: 0.048737466
m_TransitionOffset: 0 m_TransitionOffset: 0
m_ExitTime: 0.75 m_ExitTime: 0.9825936
m_HasExitTime: 1 m_HasExitTime: 1
m_HasFixedDuration: 1 m_HasFixedDuration: 1
m_InterruptionSource: 0 m_InterruptionSource: 0
...@@ -313,9 +313,9 @@ AnimatorStateTransition: ...@@ -313,9 +313,9 @@ AnimatorStateTransition:
m_Mute: 0 m_Mute: 0
m_IsExit: 0 m_IsExit: 0
serializedVersion: 3 serializedVersion: 3
m_TransitionDuration: 0.25 m_TransitionDuration: 0.06047981
m_TransitionOffset: 0 m_TransitionOffset: 0
m_ExitTime: 0.75 m_ExitTime: 0.011724846
m_HasExitTime: 1 m_HasExitTime: 1
m_HasFixedDuration: 1 m_HasFixedDuration: 1
m_InterruptionSource: 0 m_InterruptionSource: 0
...@@ -419,7 +419,7 @@ AnimatorState: ...@@ -419,7 +419,7 @@ AnimatorState:
m_MirrorParameterActive: 0 m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0 m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0 m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: d266a3801edfb2d4ebf814eeea93f5d2, type: 2} m_Motion: {fileID: 7400000, guid: 1e8ba1c691d0bb6409b39a59d55e5c4b, type: 2}
m_Tag: m_Tag:
m_SpeedParameter: MoveSpeed m_SpeedParameter: MoveSpeed
m_MirrorParameter: m_MirrorParameter:
......
This diff is collapsed.
...@@ -50,7 +50,7 @@ MeshRenderer: ...@@ -50,7 +50,7 @@ MeshRenderer:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7483224581113721909} m_GameObject: {fileID: 7483224581113721909}
m_Enabled: 1 m_Enabled: 0
m_CastShadows: 1 m_CastShadows: 1
m_ReceiveShadows: 1 m_ReceiveShadows: 1
m_DynamicOccludee: 1 m_DynamicOccludee: 1
......
...@@ -50,7 +50,7 @@ MeshRenderer: ...@@ -50,7 +50,7 @@ MeshRenderer:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6039842180593449807} m_GameObject: {fileID: 6039842180593449807}
m_Enabled: 1 m_Enabled: 0
m_CastShadows: 1 m_CastShadows: 1
m_ReceiveShadows: 1 m_ReceiveShadows: 1
m_DynamicOccludee: 1 m_DynamicOccludee: 1
......
...@@ -61,6 +61,8 @@ public class AIMove : MonoBehaviour ...@@ -61,6 +61,8 @@ public class AIMove : MonoBehaviour
public GameObject topPOS; public GameObject topPOS;
public int Count = 0; public int Count = 0;
public int tempFoodNumber = 0; public int tempFoodNumber = 0;
public Rigidbody rig;
private Vector3 DistanceByForce = new Vector3(0, 0, 0);//在各个方向上的位移(模拟力)
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
...@@ -73,6 +75,7 @@ public class AIMove : MonoBehaviour ...@@ -73,6 +75,7 @@ public class AIMove : MonoBehaviour
aiState = AIState.FindFood; aiState = AIState.FindFood;
animationManager = GetComponentInChildren<AnimationManager>(); animationManager = GetComponentInChildren<AnimationManager>();
tempFoodNumber = CurrentFood; tempFoodNumber = CurrentFood;
rig = GetComponentInChildren<Rigidbody>();
} }
...@@ -496,6 +499,22 @@ public class AIMove : MonoBehaviour ...@@ -496,6 +499,22 @@ public class AIMove : MonoBehaviour
//animator.SetBool("Push", false); //animator.SetBool("Push", false);
//animator.SetBool("Punch", false); //animator.SetBool("Punch", false);
animationManager.ChangeAnimatorState(AnimationState.Vertigo); animationManager.ChangeAnimatorState(AnimationState.Vertigo);
//眩晕状态也会被击退
xDelta = 0;
yDelta = 0;
zDelta = 0;
//------------模拟力-----------------------
Vector3 tempDis = DistanceByForce;
DistanceByForce = Vector3.Lerp(DistanceByForce, new Vector3(0, 0, 0), 0.1f);
tempDis -= DistanceByForce;
//print("DistanceByForce:"+ DistanceByForce+ "tempDis:" + tempDis);
xDelta += tempDis.x;
yDelta += tempDis.y;
zDelta += tempDis.z;
//-----------------------------------------
characterController.Move(new Vector3(xDelta, yDelta, zDelta));//移动
} }
else else
{ {
...@@ -570,6 +589,16 @@ public class AIMove : MonoBehaviour ...@@ -570,6 +589,16 @@ public class AIMove : MonoBehaviour
angle = -Mathf.Abs(angle); angle = -Mathf.Abs(angle);
} }
transform.localEulerAngles = new Vector3(0, angle, 0); transform.localEulerAngles = new Vector3(0, angle, 0);
//------------模拟力-----------------------
Vector3 tempDis = DistanceByForce;
DistanceByForce = Vector3.Lerp(DistanceByForce, new Vector3(0, 0, 0), 0.1f);
tempDis -= DistanceByForce;
//print("DistanceByForce:"+ DistanceByForce+ "tempDis:" + tempDis);
xDelta += tempDis.x;
yDelta += tempDis.y;
zDelta += tempDis.z;
//-----------------------------------------
//print(targetObj+"AI开始移动:"+ new Vector3(xDelta, yDelta, zDelta)); //print(targetObj+"AI开始移动:"+ new Vector3(xDelta, yDelta, zDelta));
characterController.Move(new Vector3(xDelta, yDelta, zDelta));//移动 characterController.Move(new Vector3(xDelta, yDelta, zDelta));//移动
...@@ -649,6 +678,13 @@ public class AIMove : MonoBehaviour ...@@ -649,6 +678,13 @@ public class AIMove : MonoBehaviour
rig.AddForce(Quaternion.Euler(new Vector3(-45, randomAngle+i * 360.0f / number, 0)) * Vector3.forward * Force); rig.AddForce(Quaternion.Euler(new Vector3(-45, randomAngle+i * 360.0f / number, 0)) * Vector3.forward * Force);
} }
} }
public void GetHitToBack(Vector3 OtherPostion)
{
Vector3 dic = (transform.position - OtherPostion).normalized * 5;
dic.y = 0;
DistanceByForce = dic;
}
private void OnDestroy() private void OnDestroy()
{ {
......
...@@ -34,6 +34,7 @@ public class BossAttack : MonoBehaviour ...@@ -34,6 +34,7 @@ public class BossAttack : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
print(attackType);
switch (attackType) switch (attackType)
{ {
case AttackType.Null: case AttackType.Null:
......
...@@ -164,7 +164,7 @@ public class BossMove : MonoBehaviour ...@@ -164,7 +164,7 @@ public class BossMove : MonoBehaviour
{ {
//print("游戏是否开始:"+ BattleCtrl.instance.isStartBattle); //print("游戏是否开始:"+ BattleCtrl.instance.isStartBattle);
//print("游戏是否结束:"+ BattleCtrl.instance.isEndBattle); //print("游戏是否结束:"+ BattleCtrl.instance.isEndBattle);
print(bossState); //print(bossState);
//----技能冷却-------------------------------------------------------------- //----技能冷却--------------------------------------------------------------
if (isDeltaTime) if (isDeltaTime)
...@@ -256,7 +256,7 @@ public class BossMove : MonoBehaviour ...@@ -256,7 +256,7 @@ public class BossMove : MonoBehaviour
} }
else else
{ {
print("LegSweepIsFinsh:" + LegSweepIsFinsh+ "HurricaneKickIsFinsh:"+ HurricaneKickIsFinsh+ "dic >= 10:" + (dic >= 10)+ "dic:" + dic); //print("LegSweepIsFinsh:" + LegSweepIsFinsh+ "HurricaneKickIsFinsh:"+ HurricaneKickIsFinsh+ "dic >= 10:" + (dic >= 10)+ "dic:" + dic);
print("攻击动画未完成,或者目标在攻击范围"); print("攻击动画未完成,或者目标在攻击范围");
} }
...@@ -290,7 +290,7 @@ public class BossMove : MonoBehaviour ...@@ -290,7 +290,7 @@ public class BossMove : MonoBehaviour
// isHurricaneKick = false; // isHurricaneKick = false;
//} //}
bossAnimationManager.ChangeAnimatorState(BossAnimationState.HurricaneKick); bossAnimationManager.ChangeAnimatorState(BossAnimationState.HurricaneKick);
bossAttack.attackType = AttackType.HurricaneKick; //bossAttack.attackType = AttackType.HurricaneKick; //由帧事件开启。
} }
else if (dic < 10 && !isDeltaTime2) else if (dic < 10 && !isDeltaTime2)
{ {
......
...@@ -53,16 +53,19 @@ public class AttackTrigger : MonoBehaviour ...@@ -53,16 +53,19 @@ public class AttackTrigger : MonoBehaviour
//print(other.name+"受到伤害:"); //print(other.name+"受到伤害:");
if (other.tag == "Player") if (other.tag == "Player")
{ {
other.gameObject.GetComponentInChildren<PlayerMove>().Hurt(5); other.gameObject.GetComponentInChildren<PlayerMove>().Hurt(3);
ps= Instantiate(hitEffects, hitPos.transform.position, hitPos.transform.rotation); other.gameObject.GetComponentInChildren<PlayerMove>().GetHitToBack(Root.transform.position);
ps = Instantiate(hitEffects, hitPos.transform.position, hitPos.transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>(); ps.gameObject.AddComponent<DestroyMySel>();
//Handheld.Vibrate();//手机震动 //Handheld.Vibrate();//手机震动
} }
else if (other.tag == "Competitor") else if (other.tag == "Competitor")
{ {
other.gameObject.GetComponentInChildren<AIMove>().Hurt(5); print(Root.name+"攻击了:"+other.name);
ps=Instantiate(hitEffects, hitPos.transform.position, hitPos.transform.rotation); other.gameObject.GetComponentInChildren<AIMove>().Hurt(3);
other.gameObject.GetComponentInChildren<AIMove>().GetHitToBack(Root.transform.position);
ps =Instantiate(hitEffects, hitPos.transform.position, hitPos.transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>(); ps.gameObject.AddComponent<DestroyMySel>();
if (Root.tag == "Player") if (Root.tag == "Player")
{ {
......
...@@ -56,7 +56,9 @@ public class PlayerMove : MonoBehaviour ...@@ -56,7 +56,9 @@ public class PlayerMove : MonoBehaviour
public int tempFoodNumber=0; public int tempFoodNumber=0;
public int Count = 0; public int Count = 0;
public Rigidbody rig;
private Vector3 DistanceByForce=new Vector3(0,0,0);//在各个方向上的位移(模拟力)
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
...@@ -70,6 +72,7 @@ public class PlayerMove : MonoBehaviour ...@@ -70,6 +72,7 @@ public class PlayerMove : MonoBehaviour
characterController = GetComponentInChildren<CharacterController>(); characterController = GetComponentInChildren<CharacterController>();
animationManager = GetComponentInChildren<AnimationManager>(); animationManager = GetComponentInChildren<AnimationManager>();
tempFoodNumber = CurrentFood; tempFoodNumber = CurrentFood;
rig = GetComponentInChildren<Rigidbody>();
} }
private void OnTriggerEnter(Collider other) private void OnTriggerEnter(Collider other)
...@@ -164,6 +167,9 @@ public class PlayerMove : MonoBehaviour ...@@ -164,6 +167,9 @@ public class PlayerMove : MonoBehaviour
ChangeAnimationscaleState(scale); ChangeAnimationscaleState(scale);
} }
} }
//受到伤害 //受到伤害
public void Hurt(int hurt) public void Hurt(int hurt)
{ {
...@@ -289,13 +295,29 @@ public class PlayerMove : MonoBehaviour ...@@ -289,13 +295,29 @@ public class PlayerMove : MonoBehaviour
CancelInvoke("DelayMoveHandle"); CancelInvoke("DelayMoveHandle");
} }
} }
private void FixedUpdate() private void FixedUpdate()
{ {
//print("游戏是否开始:"+ BattleCtrl.instance.isStartBattle); //print("游戏是否开始:"+ BattleCtrl.instance.isStartBattle);
//print("游戏是否结束:"+ BattleCtrl.instance.isEndBattle); //print("游戏是否结束:"+ BattleCtrl.instance.isEndBattle);
//if (Input.GetKeyDown(KeyCode.W))
//{
// DistanceByForce += new Vector3(0,0,5);
//}
//if (Input.GetKeyDown(KeyCode.S))
//{
// DistanceByForce += new Vector3(0, 0, -5);
//}
//if (Input.GetKeyDown(KeyCode.Q))
//{
// DistanceByForce += new Vector3(-5, 0, 0);
//}
//if (Input.GetKeyDown(KeyCode.D))
//{
// DistanceByForce += new Vector3(5, 0, 0);
//}
reduceStep = 0.023f / 0.1f * addScale; reduceStep = 0.023f / 0.1f * addScale;
if (!BattleCtrl.instance.isStartBattle) if (!BattleCtrl.instance.isStartBattle)
...@@ -309,9 +331,10 @@ public class PlayerMove : MonoBehaviour ...@@ -309,9 +331,10 @@ public class PlayerMove : MonoBehaviour
return; return;
} }
RaycastHit hit; RaycastHit hit;
xDelta = 0; //xDelta = 0;
yDelta = 0; //yDelta = 0;
zDelta = 0; //zDelta = 0;
//不在地面上给物体添加一个模拟重力 //不在地面上给物体添加一个模拟重力
Grounded = characterController.isGrounded; Grounded = characterController.isGrounded;
if (!Grounded) if (!Grounded)
...@@ -353,6 +376,23 @@ public class PlayerMove : MonoBehaviour ...@@ -353,6 +376,23 @@ public class PlayerMove : MonoBehaviour
vertigoEffect.gameObject.SetActive(true); vertigoEffect.gameObject.SetActive(true);
//AnimationManager(AnimationState.Vertigo);//眩晕动画 //AnimationManager(AnimationState.Vertigo);//眩晕动画
animationManager.ChangeAnimatorState(AnimationState.Vertigo); animationManager.ChangeAnimatorState(AnimationState.Vertigo);
//眩晕状态也会被击退
xDelta = 0;
yDelta = 0;
zDelta = 0;
//------------模拟力-----------------------
Vector3 tempDis = DistanceByForce;
DistanceByForce = Vector3.Lerp(DistanceByForce, new Vector3(0, 0, 0), 0.1f);
tempDis -= DistanceByForce;
//print("DistanceByForce:"+ DistanceByForce+ "tempDis:" + tempDis);
xDelta += tempDis.x;
yDelta += tempDis.y;
zDelta += tempDis.z;
//-----------------------------------------
characterController.Move(new Vector3(xDelta, yDelta, zDelta));//移动
} }
else else
{ {
...@@ -427,10 +467,10 @@ public class PlayerMove : MonoBehaviour ...@@ -427,10 +467,10 @@ public class PlayerMove : MonoBehaviour
{ {
//transform.position += transform.right * GameServices.inputService.joyStick.axisX.axisValue * HSpeed * Time.deltaTime; //transform.position += transform.right * GameServices.inputService.joyStick.axisX.axisValue * HSpeed * Time.deltaTime;
xDelta += GameServices.inputService.joyStick.axisX.axisValue * VSpeed * Time.deltaTime; xDelta = GameServices.inputService.joyStick.axisX.axisValue * VSpeed * Time.deltaTime;
//characterController.Move((transform.forward * MoveSpeed + new Vector3(0, _vertSpeed, 0)) * Time.deltaTime + (new Vector3(xDelta, 0, 0))); //characterController.Move((transform.forward * MoveSpeed + new Vector3(0, _vertSpeed, 0)) * Time.deltaTime + (new Vector3(xDelta, 0, 0)));
} }
zDelta += GameServices.inputService.joyStick.axisY.axisValue * VSpeed * Time.deltaTime; zDelta = GameServices.inputService.joyStick.axisY.axisValue * VSpeed * Time.deltaTime;
if (xDelta!=0||zDelta!=0) if (xDelta!=0||zDelta!=0)
{ {
//float angle = Vector3.Angle(new Vector3(transform.forward.x, 0, transform.forward.z), new Vector3(xDelta, 0, zDelta)); //float angle = Vector3.Angle(new Vector3(transform.forward.x, 0, transform.forward.z), new Vector3(xDelta, 0, zDelta));
...@@ -448,6 +488,16 @@ public class PlayerMove : MonoBehaviour ...@@ -448,6 +488,16 @@ public class PlayerMove : MonoBehaviour
{ {
characterController.Move(new Vector3(0,0,0)); characterController.Move(new Vector3(0,0,0));
} }
//------------模拟力-----------------------
Vector3 tempDis = DistanceByForce;
DistanceByForce = Vector3.Lerp(DistanceByForce,new Vector3(0,0,0),0.1f);
tempDis -=DistanceByForce;
//print("DistanceByForce:"+ DistanceByForce+ "tempDis:" + tempDis);
xDelta += tempDis.x;
yDelta += tempDis.y;
zDelta += tempDis.z;
//-----------------------------------------
//print("Player开始移动:" + new Vector3(xDelta, yDelta, zDelta)); //print("Player开始移动:" + new Vector3(xDelta, yDelta, zDelta));
characterController.Move(new Vector3(xDelta, yDelta, zDelta));//移动 characterController.Move(new Vector3(xDelta, yDelta, zDelta));//移动
...@@ -493,7 +543,13 @@ public class PlayerMove : MonoBehaviour ...@@ -493,7 +543,13 @@ public class PlayerMove : MonoBehaviour
} }
} }
public void GetHitToBack(Vector3 OtherPostion)
{
Vector3 dic = (children.transform.position- OtherPostion).normalized *5;
dic.y = 0;
DistanceByForce = dic;
}
void OnDestroy() void OnDestroy()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment