Commit 73657235 authored by czy's avatar czy

眩晕特效

parent 5df3f12e
...@@ -46,12 +46,16 @@ AnimatorStateMachine: ...@@ -46,12 +46,16 @@ AnimatorStateMachine:
- serializedVersion: 1 - serializedVersion: 1
m_State: {fileID: 2643154680664092511} m_State: {fileID: 2643154680664092511}
m_Position: {x: 270, y: -40, z: 0} m_Position: {x: 270, y: -40, z: 0}
- serializedVersion: 1
m_State: {fileID: -5151482140390748444}
m_Position: {x: 740, y: -100, z: 0}
m_ChildStateMachines: [] m_ChildStateMachines: []
m_AnyStateTransitions: [] m_AnyStateTransitions:
- {fileID: 7789786087314244433}
m_EntryTransitions: [] m_EntryTransitions: []
m_StateMachineTransitions: {} m_StateMachineTransitions: {}
m_StateMachineBehaviours: [] m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 290, y: -240, z: 0} m_AnyStatePosition: {x: 570, y: -200, z: 0}
m_EntryPosition: {x: 290, y: -150, z: 0} m_EntryPosition: {x: 290, y: -150, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0} m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
...@@ -106,6 +110,33 @@ AnimatorStateTransition: ...@@ -106,6 +110,33 @@ AnimatorStateTransition:
m_InterruptionSource: 0 m_InterruptionSource: 0
m_OrderedInterruption: 1 m_OrderedInterruption: 1
m_CanTransitionToSelf: 1 m_CanTransitionToSelf: 1
--- !u!1102 &-5151482140390748444
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Vertigo
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 8848785005566343156}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: ee242bb4bb7f631408dbca2d01b22fd7, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1109 &-2799690864505386981 --- !u!1109 &-2799690864505386981
AnimatorTransition: AnimatorTransition:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
...@@ -235,6 +266,12 @@ AnimatorController: ...@@ -235,6 +266,12 @@ AnimatorController:
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 0}
- m_Name: Vertigo
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers: m_AnimatorLayers:
- serializedVersion: 5 - serializedVersion: 5
m_Name: Base Layer m_Name: Base Layer
...@@ -337,6 +374,31 @@ AnimatorState: ...@@ -337,6 +374,31 @@ AnimatorState:
m_MirrorParameter: m_MirrorParameter:
m_CycleOffsetParameter: m_CycleOffsetParameter:
m_TimeParameter: m_TimeParameter:
--- !u!1101 &1572285795481017674
AnimatorStateTransition:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 3
m_ConditionEvent: MoveSpeed
m_EventTreshold: 0.2
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 8650196453075220448}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.87288135
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &2643154680664092511 --- !u!1102 &2643154680664092511
AnimatorState: AnimatorState:
serializedVersion: 5 serializedVersion: 5
...@@ -527,6 +589,31 @@ AnimatorStateTransition: ...@@ -527,6 +589,31 @@ AnimatorStateTransition:
m_InterruptionSource: 0 m_InterruptionSource: 0
m_OrderedInterruption: 1 m_OrderedInterruption: 1
m_CanTransitionToSelf: 1 m_CanTransitionToSelf: 1
--- !u!1101 &7789786087314244433
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Vertigo
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -5151482140390748444}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &8583691091879068204 --- !u!1101 &8583691091879068204
AnimatorStateTransition: AnimatorStateTransition:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
...@@ -606,3 +693,28 @@ AnimatorStateTransition: ...@@ -606,3 +693,28 @@ AnimatorStateTransition:
m_InterruptionSource: 0 m_InterruptionSource: 0
m_OrderedInterruption: 1 m_OrderedInterruption: 1
m_CanTransitionToSelf: 1 m_CanTransitionToSelf: 1
--- !u!1101 &8848785005566343156
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: Vertigo
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 0}
m_Solo: 0
m_Mute: 0
m_IsExit: 1
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.87288135
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
This diff is collapsed.
...@@ -33,6 +33,8 @@ public class AIMove : MonoBehaviour ...@@ -33,6 +33,8 @@ public class AIMove : MonoBehaviour
public GameObject targetWall; public GameObject targetWall;
//path pos0 //path pos0
public GameObject pathPos0; public GameObject pathPos0;
//眩晕特效
public ParticleSystem vertigoEffect;
public enum AIState public enum AIState
{ {
...@@ -42,6 +44,7 @@ public class AIMove : MonoBehaviour ...@@ -42,6 +44,7 @@ public class AIMove : MonoBehaviour
TurnBackToPathPos0=3 //返回Pos0 TurnBackToPathPos0=3 //返回Pos0
} }
public AIState aiState; public AIState aiState;
private float vertigoTime = 0.0f;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
...@@ -112,9 +115,15 @@ public class AIMove : MonoBehaviour ...@@ -112,9 +115,15 @@ public class AIMove : MonoBehaviour
if (power < 1) if (power < 1)
{ {
power = 1; power = 1;
AddVertigo(1);
} }
Scale(power, power, power); Scale(power, power, power);
} }
//增加眩晕时长眩晕
public void AddVertigo(float time)
{
vertigoTime += time;
}
private void FixedUpdate() private void FixedUpdate()
{ {
...@@ -192,9 +201,25 @@ public class AIMove : MonoBehaviour ...@@ -192,9 +201,25 @@ public class AIMove : MonoBehaviour
Vector3 speed=( targetObj.transform.position - transform.position).normalized*VSpeed; Vector3 speed=( targetObj.transform.position - transform.position).normalized*VSpeed;
xDelta = speed.x * Time.deltaTime; xDelta = speed.x * Time.deltaTime;
zDelta = speed.z * Time.deltaTime; zDelta = speed.z * Time.deltaTime;
Move(); if (vertigoTime > 0)
{
//眩晕
vertigoTime -= Time.deltaTime;
vertigoEffect.gameObject.SetActive(true);
animator.SetBool("Vertigo", true);
animator.SetBool("Push", false);
animator.SetBool("Punch", false);
}
else
{
vertigoEffect.gameObject.SetActive(false);
vertigoTime = 0;
animator.SetBool("Vertigo", false);
Move();
}
} }
......
...@@ -4,22 +4,35 @@ using UnityEngine; ...@@ -4,22 +4,35 @@ using UnityEngine;
public class RandomFood : MonoBehaviour public class RandomFood : MonoBehaviour
{ {
public int foodNumber = 10; [Header("生成食物个数")]
public int foodNumber = 20;
[Header("食物补齐时间间隔/秒")]
public float timeSpan=10;
private float timer = 0;
public List<Transform> foodPoint; public List<Transform> foodPoint;
public List<GameObject> foods; public List<GameObject> foods;
void Start() void Start()
{ {
GenerateRandomFood(10); GenerateRandomFood(foodNumber);
} }
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
timer += Time.deltaTime;
if (timer >= timeSpan)
{
timer = 0;
//补全20个食物
complementFood();
}
GameObject[] currFoods= GameObject.FindGameObjectsWithTag("Food"); GameObject[] currFoods= GameObject.FindGameObjectsWithTag("Food");
if (currFoods.Length == 0) if (currFoods.Length == 0)
{ {
GenerateRandomFood(10); timer = 0;
GenerateRandomFood(foodNumber);
} }
} }
...@@ -44,5 +57,14 @@ public class RandomFood : MonoBehaviour ...@@ -44,5 +57,14 @@ public class RandomFood : MonoBehaviour
{ {
return foods[Random.Range(0, foods.Count)]; return foods[Random.Range(0, foods.Count)];
} }
/// <summary>
/// 补全食物个数到foodNumber个。
/// </summary>
public void complementFood()
{
GameObject[] currFoods = GameObject.FindGameObjectsWithTag("Food");
int addFood = foodNumber - currFoods.Length;
//print("生成食物:"+ addFood);
GenerateRandomFood(addFood);
}
} }
...@@ -33,8 +33,7 @@ public class PlayerMove : MonoBehaviour ...@@ -33,8 +33,7 @@ public class PlayerMove : MonoBehaviour
private float yDelta = 0; private float yDelta = 0;
private float zDelta = 0; private float zDelta = 0;
//眩晕时长
private float timerVertigo = 0.0f;
//动画 //动画
private Animator animator; private Animator animator;
//状态 //状态
...@@ -43,7 +42,10 @@ public class PlayerMove : MonoBehaviour ...@@ -43,7 +42,10 @@ public class PlayerMove : MonoBehaviour
private bool Grounded = false; private bool Grounded = false;
public GameObject targetWall; public GameObject targetWall;
public GameObject children; public GameObject children;
//眩晕
public float vertigoTime = 0.0f;
public ParticleSystem vertigoEffect;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
...@@ -80,7 +82,7 @@ public class PlayerMove : MonoBehaviour ...@@ -80,7 +82,7 @@ public class PlayerMove : MonoBehaviour
//Destroy(other.gameObject); //Destroy(other.gameObject);
//print("吃到食物。"); //print("吃到食物。");
power+=0.3f; power+=0.1f;
Scale(power,power,power); Scale(power,power,power);
Destroy(other.gameObject); Destroy(other.gameObject);
} }
...@@ -93,7 +95,7 @@ public class PlayerMove : MonoBehaviour ...@@ -93,7 +95,7 @@ public class PlayerMove : MonoBehaviour
if (power>1) if (power>1)
{ {
hit.gameObject.GetComponent<Rigidbody>().AddForce(new Vector3(0, 0, 100)); hit.gameObject.GetComponent<Rigidbody>().AddForce(new Vector3(0, 0, 100));
power -= 0.01f; power -= 0.023f;
} }
else else
{ {
...@@ -109,9 +111,15 @@ public class PlayerMove : MonoBehaviour ...@@ -109,9 +111,15 @@ public class PlayerMove : MonoBehaviour
if (power < 1) if (power < 1)
{ {
power = 1; power = 1;
AddVertigo(1);
} }
Scale(power, power, power); Scale(power, power, power);
} }
//增加眩晕时长眩晕
public void AddVertigo(float time)
{
vertigoTime += time;
}
private void Scale(float x,float y,float z) private void Scale(float x,float y,float z)
{ {
...@@ -240,20 +248,22 @@ public class PlayerMove : MonoBehaviour ...@@ -240,20 +248,22 @@ public class PlayerMove : MonoBehaviour
if ( !BattleCtrl.instance.IsScoreSettlementStatus) if ( !BattleCtrl.instance.IsScoreSettlementStatus)
{ {
//print("控制摇杆"); if (vertigoTime >0)
if (timerVertigo <= 0)
{ {
timerVertigo = 0; //眩晕
//移动控制。 vertigoTime -= Time.deltaTime;
UpdateJoystick(); vertigoEffect.gameObject.SetActive(true);
animator.SetBool("Vertigo", true);
animator.SetBool("Push", false);
animator.SetBool("Punch", false);
} }
else else
{ {
//眩晕 vertigoEffect.gameObject.SetActive(false);
timerVertigo -= Time.deltaTime; vertigoTime = 0;
xDelta = 0;//避免眩晕期间不会执行UpdateJoystick();造成偏移现象。 animator.SetBool("Vertigo", false);
UpdateJoystick();
} }
} }
else else
{ {
......
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