Commit c9d66a03 authored by czy's avatar czy

速度等级不同更换不同模型

parent 716504db
...@@ -27,6 +27,11 @@ public class AIMove : MonoBehaviour ...@@ -27,6 +27,11 @@ public class AIMove : MonoBehaviour
public Transform raySeeWayPos; public Transform raySeeWayPos;
[Header("AI策略")] [Header("AI策略")]
public AIStrategy aIStrategy; public AIStrategy aIStrategy;
[Header("模型控制")]
public Transform ModelParent;
public GameObject Model1;
public GameObject Model2;
public GameObject Model3;
private RaycastHit RHit; private RaycastHit RHit;
private CharacterController characterController; private CharacterController characterController;
...@@ -62,6 +67,7 @@ public class AIMove : MonoBehaviour ...@@ -62,6 +67,7 @@ public class AIMove : MonoBehaviour
//动画 //动画
private Animator animator; private Animator animator;
//状态 //状态
[HideInInspector]
public float MoveSpeed = 0.0f; public float MoveSpeed = 0.0f;
private bool Grounded = false; private bool Grounded = false;
private GameObject targetObj; private GameObject targetObj;
...@@ -85,6 +91,7 @@ public class AIMove : MonoBehaviour ...@@ -85,6 +91,7 @@ public class AIMove : MonoBehaviour
m_thumbRT = GameServices.inputService.joyStick.thumb; m_thumbRT = GameServices.inputService.joyStick.thumb;
//获取animator组件 //获取animator组件
animator = GetComponentInChildren<Animator>(); animator = GetComponentInChildren<Animator>();
ChangeModel();
} }
private void OnTriggerEnter(Collider other) private void OnTriggerEnter(Collider other)
...@@ -96,6 +103,7 @@ public class AIMove : MonoBehaviour ...@@ -96,6 +103,7 @@ public class AIMove : MonoBehaviour
SpeedLevel += 1; SpeedLevel += 1;
BattleCtrl.instance.Score++; BattleCtrl.instance.Score++;
BattleCtrl.instance.updateScore?.Invoke(); BattleCtrl.instance.updateScore?.Invoke();
ChangeModel();
} }
Destroy(other.gameObject); Destroy(other.gameObject);
} }
...@@ -104,6 +112,7 @@ public class AIMove : MonoBehaviour ...@@ -104,6 +112,7 @@ public class AIMove : MonoBehaviour
if (this.SpeedLevel > 1) if (this.SpeedLevel > 1)
{ {
this.SpeedLevel--; this.SpeedLevel--;
ChangeModel();
} }
} }
} }
...@@ -373,7 +382,7 @@ public class AIMove : MonoBehaviour ...@@ -373,7 +382,7 @@ public class AIMove : MonoBehaviour
if (transform.position.z < maxZ) if (transform.position.z < maxZ)
{ {
//print("前方障碍物,开始躲避AvoidDir:"+ AvoidDir+ "transform.position.x:"+ transform.position.x + "avoidX:" + avoidX); //print("前方障碍物,开始躲避AvoidDir:"+ AvoidDir+ "transform.position.x:"+ transform.position.x + "avoidX:" + avoidX);
//前方右障碍物,开始躲避。 //前方右障碍物,开始躲避。
//关闭金币导航 //关闭金币导航
deltaX = 0; deltaX = 0;
...@@ -626,7 +635,27 @@ public class AIMove : MonoBehaviour ...@@ -626,7 +635,27 @@ public class AIMove : MonoBehaviour
} }
public void ChangeModel()
{
switch (SpeedLevel)
{
case 1:
Model1.SetActive(true);
Model2.SetActive(false);
Model3.SetActive(false);
break;
case 2:
Model1.SetActive(false);
Model2.SetActive(true);
Model3.SetActive(false);
break;
case 3:
Model1.SetActive(false);
Model2.SetActive(false);
Model3.SetActive(true);
break;
}
}
private void OnDestroy() private void OnDestroy()
{ {
m_targetTrans = null; m_targetTrans = null;
......
...@@ -21,14 +21,18 @@ public class PlayerMove : MonoBehaviour ...@@ -21,14 +21,18 @@ public class PlayerMove : MonoBehaviour
public float AddSpeed = 10.0f; public float AddSpeed = 10.0f;
[Tooltip("控制左右移动的速度。")] [Tooltip("控制左右移动的速度。")]
public float HSpeed = 10.0f; public float HSpeed = 10.0f;
[Tooltip("主角移动方式")] [Tooltip("主角移动方式")]
public MoveType moveType= MoveType.MoveType3; public MoveType moveType= MoveType.MoveType3;
[Header("地面检测")] [Header("地面检测")]
public Transform ray1Pos; public Transform ray1Pos;
public Transform ray2Pos; public Transform ray2Pos;
[Header("模型控制")]
public Transform ModelParent;
public GameObject Model1;
public GameObject Model2;
public GameObject Model3;
private RaycastHit RHit; private RaycastHit RHit;
private CharacterController characterController; private CharacterController characterController;
...@@ -59,6 +63,7 @@ public class PlayerMove : MonoBehaviour ...@@ -59,6 +63,7 @@ public class PlayerMove : MonoBehaviour
//动画 //动画
private Animator animator; private Animator animator;
//状态 //状态
[HideInInspector]
public float MoveSpeed=0.0f; public float MoveSpeed=0.0f;
private bool Grounded = false; private bool Grounded = false;
...@@ -91,6 +96,7 @@ public class PlayerMove : MonoBehaviour ...@@ -91,6 +96,7 @@ public class PlayerMove : MonoBehaviour
//m_rigidBody = GetComponent<Rigidbody>(); //m_rigidBody = GetComponent<Rigidbody>();
//获取characterController组件 //获取characterController组件
characterController = GetComponent<CharacterController>(); characterController = GetComponent<CharacterController>();
ChangeModel();
} }
private void OnTriggerEnter(Collider other) private void OnTriggerEnter(Collider other)
...@@ -104,6 +110,7 @@ public class PlayerMove : MonoBehaviour ...@@ -104,6 +110,7 @@ public class PlayerMove : MonoBehaviour
SpeedLevel += 1; SpeedLevel += 1;
BattleCtrl.instance.Score++; BattleCtrl.instance.Score++;
BattleCtrl.instance.updateScore?.Invoke(); BattleCtrl.instance.updateScore?.Invoke();
ChangeModel();
} }
} }
else if (other.tag== "Prickle") else if (other.tag== "Prickle")
...@@ -111,6 +118,7 @@ public class PlayerMove : MonoBehaviour ...@@ -111,6 +118,7 @@ public class PlayerMove : MonoBehaviour
if (this.SpeedLevel > 1) if (this.SpeedLevel > 1)
{ {
this.SpeedLevel--; this.SpeedLevel--;
ChangeModel();
} }
} }
//else if (other.tag == "Prop" && DoRanking._instance.rankingList[2]!=gameObject) //自己不是最前面的人。 //else if (other.tag == "Prop" && DoRanking._instance.rankingList[2]!=gameObject) //自己不是最前面的人。
...@@ -499,9 +507,26 @@ public class PlayerMove : MonoBehaviour ...@@ -499,9 +507,26 @@ public class PlayerMove : MonoBehaviour
//timerVertigo += time; //累加眩晕时长 //timerVertigo += time; //累加眩晕时长
} }
private void OnControllerColliderHit(ControllerColliderHit hit) public void ChangeModel()
{ {
switch (SpeedLevel)
{
case 1:
Model1.SetActive(true);
Model2.SetActive(false);
Model3.SetActive(false);
break;
case 2:
Model1.SetActive(false);
Model2.SetActive(true);
Model3.SetActive(false);
break;
case 3:
Model1.SetActive(false);
Model2.SetActive(false);
Model3.SetActive(true);
break;
}
} }
private void OnDestroy() private void OnDestroy()
......
...@@ -24,7 +24,7 @@ Transform: ...@@ -24,7 +24,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4004674577979274087} m_GameObject: {fileID: 4004674577979274087}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.7755992, y: -8.060598, z: 13.473129} m_LocalPosition: {x: 0.7755992, y: -8.260598, z: 13.473129}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 4004674578049485334} - {fileID: 4004674578049485334}
......
...@@ -9,7 +9,7 @@ PrefabInstance: ...@@ -9,7 +9,7 @@ PrefabInstance:
m_Modifications: m_Modifications:
- target: {fileID: 1684007911718038, guid: 18c5fed9cca812a458ccf567688e3a1f, type: 3} - target: {fileID: 1684007911718038, guid: 18c5fed9cca812a458ccf567688e3a1f, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: SM_Veh_Car_Sports_01 value: SM_Veh_Car_Sports_01 Variant
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4996138570027138, guid: 18c5fed9cca812a458ccf567688e3a1f, type: 3} - target: {fileID: 4996138570027138, guid: 18c5fed9cca812a458ccf567688e3a1f, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
...@@ -17,7 +17,7 @@ PrefabInstance: ...@@ -17,7 +17,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4996138570027138, guid: 18c5fed9cca812a458ccf567688e3a1f, type: 3} - target: {fileID: 4996138570027138, guid: 18c5fed9cca812a458ccf567688e3a1f, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: 0.48127 value: -0.064
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4996138570027138, guid: 18c5fed9cca812a458ccf567688e3a1f, type: 3} - target: {fileID: 4996138570027138, guid: 18c5fed9cca812a458ccf567688e3a1f, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
......
This diff is collapsed.
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