Commit 6388d74e authored by czy's avatar czy

用食物个数控制准确控制过桥

parent 860fc557
......@@ -447,6 +447,11 @@ PrefabInstance:
propertyPath: m_Layer
value: 13
objectReference: {fileID: 0}
- target: {fileID: -1695411754959855279, guid: 092b5adfc35664b43a5e216c3aba0c4d,
type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 9464194c960614a43a6a515b5694837c, type: 2}
- target: {fileID: -927199367670048503, guid: 092b5adfc35664b43a5e216c3aba0c4d,
type: 3}
propertyPath: m_Name
......@@ -4494,9 +4499,9 @@ Transform:
- {fileID: 1673827126}
- {fileID: 331692064}
- {fileID: 8011702164409445993}
- {fileID: 1758950347}
- {fileID: 1810808136}
- {fileID: 331233293}
- {fileID: 1758950347}
- {fileID: 354878097}
m_Father: {fileID: 1682241237}
m_RootOrder: 0
......@@ -4685,7 +4690,7 @@ GameObject:
- component: {fileID: 331233291}
- component: {fileID: 331233290}
m_Layer: 0
m_Name: path (1)
m_Name: path3
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
......@@ -4764,7 +4769,7 @@ Transform:
m_Children:
- {fileID: 1527153766}
m_Father: {fileID: 316360034}
m_RootOrder: 10
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &331692063
PrefabInstance:
......@@ -5390,7 +5395,7 @@ GameObject:
- component: {fileID: 354878098}
- component: {fileID: 354878099}
m_Layer: 0
m_Name: path (3)
m_Name: path4
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
......@@ -7497,7 +7502,7 @@ MonoBehaviour:
HurricaneKickCoolingTime: 5
CurrentHurricaneKickCoolingTime: 0
isDeltaTime: 0
LegSweepCoolingTime: 1
LegSweepCoolingTime: 3
CurrentLegSweepCoolingTime: 0
isDeltaTime2: 0
ps: {fileID: 1539289411}
......@@ -7811,7 +7816,7 @@ PrefabInstance:
- target: {fileID: 2378810921855438409, guid: c0584c7c6c5cb2f448487b9cb51f45fc,
type: 3}
propertyPath: m_RootOrder
value: 2
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2378810921855438409, guid: c0584c7c6c5cb2f448487b9cb51f45fc,
type: 3}
......@@ -7846,7 +7851,7 @@ PrefabInstance:
- target: {fileID: 2384245972812640027, guid: c0584c7c6c5cb2f448487b9cb51f45fc,
type: 3}
propertyPath: m_Name
value: dungeon-wall-stone3
value: dungeon-wall-stone1
objectReference: {fileID: 0}
- target: {fileID: 2384245972812640027, guid: c0584c7c6c5cb2f448487b9cb51f45fc,
type: 3}
......@@ -8481,6 +8486,7 @@ MonoBehaviour:
Force: 301
foodPhysicM: {fileID: 13400000, guid: cdd3c635b87625448950bf1323a8ffd4, type: 2}
topPOS: {fileID: 1074946583}
Count: 0
--- !u!54 &616173311
Rigidbody:
m_ObjectHideFlags: 0
......@@ -10670,6 +10676,38 @@ Transform:
type: 3}
m_PrefabInstance: {fileID: 6348171781088263581}
m_PrefabAsset: {fileID: 0}
--- !u!1 &839613504
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 839613505}
m_Layer: 0
m_Name: Test
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &839613505
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 839613504}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 76.35839, y: 25.687569, z: 87.09975}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1811285457}
- {fileID: 896120886}
m_Father: {fileID: 0}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &847189836 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 5957448837244393581, guid: 15d49ef1e12d35a46b7c6fb953021b43,
......@@ -10914,7 +10952,16 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 267d4e345a9b9c44fa9acb5159d7815f, type: 3}
m_Name:
m_EditorClassIdentifier:
ps: {fileID: 19844352, guid: 632339e29e2ddd64aab6f9dd68facc82, type: 3}
changeModelEffect: {fileID: 19844352, guid: 632339e29e2ddd64aab6f9dd68facc82, type: 3}
targetPath: {fileID: 1810808132}
stepNumberToEnd: 20
isMove: 0
isMoveComplete: 1
Speed: 10
pathLength: 0
stepLength: 0
tempBeginPos: {x: 0, y: 0, z: 0}
targetPos: {x: 0, y: 0, z: 0}
--- !u!54 &866649277
Rigidbody:
m_ObjectHideFlags: 0
......@@ -11668,6 +11715,7 @@ MonoBehaviour:
foodPhysicM: {fileID: 13400000, guid: cdd3c635b87625448950bf1323a8ffd4, type: 2}
Force: 301
topPOS: {fileID: 658860373}
Count: 0
--- !u!4 &883198006
Transform:
m_ObjectHideFlags: 0
......@@ -11848,11 +11896,11 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 896120885}
m_LocalRotation: {x: -0.31653008, y: -0.019398104, z: 0.021550622, w: 0.9481393}
m_LocalPosition: {x: -0.014041255, y: 0.25684795, z: -0.050959602}
m_LocalScale: {x: 0.15305078, y: 1, z: 0.23619002}
m_LocalPosition: {x: -76.37243, y: -25.430721, z: -87.1507}
m_LocalScale: {x: 0.1530508, y: 1, z: 0.23619002}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_Father: {fileID: 839613505}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: -36.826, y: -3.6120002, z: 3.8070002}
--- !u!1001 &902348201
PrefabInstance:
......@@ -12031,9 +12079,9 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 581802052}
- {fileID: 388813335596933293}
- {fileID: 1931419791}
- {fileID: 581802052}
m_Father: {fileID: 1682241237}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -12130,7 +12178,16 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 267d4e345a9b9c44fa9acb5159d7815f, type: 3}
m_Name:
m_EditorClassIdentifier:
ps: {fileID: 19844352, guid: 632339e29e2ddd64aab6f9dd68facc82, type: 3}
changeModelEffect: {fileID: 19844352, guid: 632339e29e2ddd64aab6f9dd68facc82, type: 3}
targetPath: {fileID: 331233289}
stepNumberToEnd: 20
isMove: 0
isMoveComplete: 1
Speed: 10
pathLength: 0
stepLength: 0
tempBeginPos: {x: 0, y: 0, z: 0}
targetPos: {x: 0, y: 0, z: 0}
--- !u!54 &916250631
Rigidbody:
m_ObjectHideFlags: 0
......@@ -12565,7 +12622,16 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 267d4e345a9b9c44fa9acb5159d7815f, type: 3}
m_Name:
m_EditorClassIdentifier:
ps: {fileID: 19844352, guid: 632339e29e2ddd64aab6f9dd68facc82, type: 3}
changeModelEffect: {fileID: 19844352, guid: 632339e29e2ddd64aab6f9dd68facc82, type: 3}
targetPath: {fileID: 1758950343}
stepNumberToEnd: 20
isMove: 0
isMoveComplete: 1
Speed: 10
pathLength: 0
stepLength: 0
tempBeginPos: {x: 0, y: 0, z: 0}
targetPos: {x: 0, y: 0, z: 0}
--- !u!54 &952561890
Rigidbody:
m_ObjectHideFlags: 0
......@@ -17580,6 +17646,7 @@ MonoBehaviour:
Force: 301
foodPhysicM: {fileID: 13400000, guid: cdd3c635b87625448950bf1323a8ffd4, type: 2}
topPOS: {fileID: 861607386}
Count: 0
--- !u!54 &1342203614
Rigidbody:
m_ObjectHideFlags: 0
......@@ -19739,7 +19806,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 88224c51f1a97cf40895dff846d2a5b3, type: 3}
m_Name:
m_EditorClassIdentifier:
foodNumber: 40
foodNumber: 20
timeSpan: 10
foodPoint:
- {fileID: 297527856}
......@@ -23060,7 +23127,7 @@ GameObject:
- component: {fileID: 1758950345}
- component: {fileID: 1758950344}
m_Layer: 0
m_Name: path (2)
m_Name: path1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
......@@ -23139,7 +23206,7 @@ Transform:
m_Children:
- {fileID: 497489067}
m_Father: {fileID: 316360034}
m_RootOrder: 11
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &1760404843 stripped
Transform:
......@@ -23564,7 +23631,7 @@ GameObject:
- component: {fileID: 1810808134}
- component: {fileID: 1810808133}
m_Layer: 0
m_Name: path
m_Name: path2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
......@@ -23643,7 +23710,7 @@ Transform:
m_Children:
- {fileID: 1135896825}
m_Father: {fileID: 316360034}
m_RootOrder: 9
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1811285456
GameObject:
......@@ -23669,11 +23736,11 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1811285456}
m_LocalRotation: {x: -0.31653008, y: -0.019398104, z: 0.021550622, w: 0.9481393}
m_LocalPosition: {x: 0.1324, y: 0.2646, z: -0.0476}
m_LocalScale: {x: 0.4465608, y: 1, z: 0.23619002}
m_LocalPosition: {x: -76.22599, y: -25.422968, z: -87.14735}
m_LocalScale: {x: 0.44656083, y: 1, z: 0.23619002}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 8
m_Father: {fileID: 839613505}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: -36.826, y: -3.6120002, z: 3.8070002}
--- !u!1001 &1819019859
PrefabInstance:
......@@ -25085,7 +25152,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!114 &1925409514
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -25258,7 +25325,7 @@ PrefabInstance:
- target: {fileID: 2378810921855438409, guid: c0584c7c6c5cb2f448487b9cb51f45fc,
type: 3}
propertyPath: m_RootOrder
value: 1
value: 2
objectReference: {fileID: 0}
- target: {fileID: 2378810921855438409, guid: c0584c7c6c5cb2f448487b9cb51f45fc,
type: 3}
......@@ -25293,7 +25360,7 @@ PrefabInstance:
- target: {fileID: 2384245972812640027, guid: c0584c7c6c5cb2f448487b9cb51f45fc,
type: 3}
propertyPath: m_Name
value: dungeon-wall-stone2
value: dungeon-wall-stone3
objectReference: {fileID: 0}
- target: {fileID: 2384245972812640027, guid: c0584c7c6c5cb2f448487b9cb51f45fc,
type: 3}
......@@ -32317,7 +32384,7 @@ PrefabInstance:
- target: {fileID: 2378810921855438409, guid: c0584c7c6c5cb2f448487b9cb51f45fc,
type: 3}
propertyPath: m_RootOrder
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2378810921855438409, guid: c0584c7c6c5cb2f448487b9cb51f45fc,
type: 3}
......@@ -32352,7 +32419,7 @@ PrefabInstance:
- target: {fileID: 2384245972812640027, guid: c0584c7c6c5cb2f448487b9cb51f45fc,
type: 3}
propertyPath: m_Name
value: dungeon-wall-stone1
value: dungeon-wall-stone2
objectReference: {fileID: 0}
- target: {fileID: 2384245972812640027, guid: c0584c7c6c5cb2f448487b9cb51f45fc,
type: 3}
......@@ -39505,7 +39572,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!222 &6165904641564313620
CanvasRenderer:
m_ObjectHideFlags: 0
......@@ -40690,7 +40757,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!222 &7517467192947893870
CanvasRenderer:
m_ObjectHideFlags: 0
......@@ -59,6 +59,8 @@ public class AIMove : MonoBehaviour
public float Force = 300;
public PhysicMaterial foodPhysicM;
public GameObject topPOS;
public int Count = 0;
// Start is called before the first frame update
void Start()
......@@ -75,41 +77,81 @@ public class AIMove : MonoBehaviour
private void OnTriggerEnter(Collider other)
{
//print("OnTriggerEnter:"+other.name);
//if (other.tag == "Food")
//{
// //print("吃到食物。");
// UpdateScore(1);
// HaveFoodNumber++;
// if (RandomFoodNumberToPush <= HaveFoodNumber && targetWall != null)
// {
// //推墙
// //targetObj = targetWall;
// aiState = AIState.GoToPathPos0; //到路径起点,准备去推墙
// }
// else if (RandomFoodNumberToPush <= HaveFoodNumber && targetWall == null)
// {
// aiState = AIState.PlayBoss;
// }
// if (scale >= (1 + MaxFood * addScale))
// {
// scale = 1 + MaxFood * addScale;
// }
// else
// {
// scale += addScale;
// //进行食物累计和缩放模型。
// AddIsPlayChangeModeEffect();
// }
// ChangeAnimationscaleState(scale);
// //Scale(scale, scale, scale);
// Destroy(other.gameObject);
//}
if (other.tag == "Food")
{
//other.gameObject.GetComponentInChildren<Gold>().PlayParticle();//吃金币特效
//Vector2 screenPoint = Camera.main.WorldToScreenPoint(other.gameObject.transform.position);
//BattleUI.instance.GenerateAddMoneyUI(100, screenPoint);
//Destroy(other.gameObject);
//print("吃到食物。");
UpdateScore(1);
HaveFoodNumber++;
if (RandomFoodNumberToPush<= HaveFoodNumber && targetWall!=null)
if (RandomFoodNumberToPush <= HaveFoodNumber && targetWall != null)
{
//推墙
//targetObj = targetWall;
aiState = AIState.GoToPathPos0; //到路径起点,准备去推墙
}else if (RandomFoodNumberToPush <= HaveFoodNumber && targetWall == null)
}
else if (RandomFoodNumberToPush <= HaveFoodNumber && targetWall == null)
{
aiState = AIState.PlayBoss;
}
if (scale >= (1 + MaxFood * addScale))
if (CurrentFood >= MaxFood)
{
scale = 1 + MaxFood * addScale;
CurrentFood = MaxFood;
}
else
{
scale += addScale;
//进行食物累计和缩放模型。
AddIsPlayChangeModeEffect();
}
CurrentFood++;
scale = 1 + CurrentFood * addScale;
ChangeAnimationscaleState(scale);
//Scale(scale, scale, scale);
switch (CurrentFood)
{
case 5:
case 10:
case 15:
case 20:
Scale(scale, scale, scale);
ParticleSystem ps = Instantiate(changeModeEffect, transform.position, transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>();
break;
default:
break;
}
}
Destroy(other.gameObject);
}
}
public void UpdateScore(int addNumber)
{
......@@ -125,70 +167,158 @@ public class AIMove : MonoBehaviour
{
if (hit.gameObject==targetWall)
{
//print("碰到墙");
if (scale > 1)
////print("碰到墙");
//if (scale > 1)
//{
// hit.gameObject.GetComponent<Rigidbody>().AddForce(new Vector3(0, 0, 100));
// scale -= reduceStep;
// ReduceIsPlayChangeModeEffect("PushWall");
//}
//else
//{
// scale = 1;
// RandomFoodNumberToPush = Random.Range(1,11);
// HaveFoodNumber = 0;
// //targetObj = GetTargetPos();
// //print("改变状态为回到起点2");
// aiState = AIState.TurnBackToPathPos0; //到路径起点,准备去找食物
//}
//ChangeAnimationscaleState(scale);
////Scale(scale, scale, scale);
//print("Player碰到墙:"+ scale);
if (CurrentFood >= 1)
{
//print("推墙");
int aa = hit.gameObject.GetComponent<Wall>().MakeWallMove();
Count += aa;
CurrentFood -= aa;
//Debug.LogError("CurrentFood:" + CurrentFood+"aa:"+aa);
scale -= aa * addScale;
switch (CurrentFood)
{
hit.gameObject.GetComponent<Rigidbody>().AddForce(new Vector3(0, 0, 100));
scale -= reduceStep;
ReduceIsPlayChangeModeEffect("PushWall");
case 0:
Scale(scale, scale, scale);
break;
case 5:
case 10:
case 15:
case 20:
Scale(scale, scale, scale);
ParticleSystem ps = Instantiate(changeModeEffect, transform.position, transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>();
break;
default:
break;
}
}
else
{
scale = 1;
RandomFoodNumberToPush = Random.Range(1,11);
RandomFoodNumberToPush = Random.Range(1, 11);
HaveFoodNumber = 0;
//targetObj = GetTargetPos();
//print("改变状态为回到起点2");
aiState = AIState.TurnBackToPathPos0; //到路径起点,准备去找食物
}
ChangeAnimationscaleState(scale);
//Scale(scale, scale, scale);
}
}
//受到伤害
public void Hurt(float hurt)
public void Hurt(int hurt)
{
scale -= hurt;
if (scale < 1)
//scale -= hurt;
//if (scale < 1)
//{
// scale = 1;
// RefreshVertigo(hurt);
//}
//ChangeAnimationscaleState(scale);
//ReduceIsPlayChangeModeEffect("Hurt");
//进行判断是否播放特效
CurrentFood -= hurt;
if (CurrentFood <= 0)
{
CurrentFood = 0;
scale = 1;
RefreshVertigo(hurt);
RefreshVertigo(1);
}
ChangeAnimationscaleState(scale);
ReduceIsPlayChangeModeEffect("Hurt");
//Scale(scale, scale, scale);
}
//食物增加时,判断是否播放改变模型特效
public void AddIsPlayChangeModeEffect()
{
CurrentFood++;
if (CurrentFood == 5 || CurrentFood == 10 || CurrentFood == 15 || CurrentFood == 20)
switch (CurrentFood)
{
case 0:
Scale(scale, scale, scale);
ParticleSystem ps = Instantiate(changeModeEffect, transform.position, transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>();
}
}
/// <summary>
/// 减少时,判断是否播放改变模型特效
/// </summary>
public void ReduceIsPlayChangeModeEffect(string type)
{
int tempFood = CurrentFood;
CurrentFood = (int)((scale - 1.0f) / addScale);
if (tempFood != CurrentFood && (CurrentFood == 0||CurrentFood == 5 || CurrentFood == 10 || CurrentFood == 15 || CurrentFood == 20))
{
break;
case 5:
case 10:
case 15:
case 20:
Scale(scale, scale, scale);
ParticleSystem ps = Instantiate(changeModeEffect, transform.position, transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>();
if (type == "Hurt")
{
GenerateRandomFoodAroundPos(5, transform.position, 5);//生成5个食物距离为5
break;
default:
break;
}
}
}
////食物增加时,判断是否播放改变模型特效
//public void AddIsPlayChangeModeEffect()
//{
// CurrentFood++;
// if (CurrentFood == 5 || CurrentFood == 10 || CurrentFood == 15 || CurrentFood == 20)
// {
// Scale(scale, scale, scale);
// ParticleSystem ps = Instantiate(changeModeEffect, transform.position, transform.rotation);
// ps.gameObject.AddComponent<DestroyMySel>();
// }
//}
///// <summary>
///// 减少时,判断是否播放改变模型特效
///// </summary>
//public void ReduceIsPlayChangeModeEffect(string type)
//{
// int tempFood = CurrentFood;
// CurrentFood = (int)((scale - 1.0f) / addScale);
// if (tempFood != CurrentFood && CurrentFood == 0)
// {
// Scale(scale, scale, scale);
// }
// if (tempFood != CurrentFood && (CurrentFood == 5 || CurrentFood == 10 || CurrentFood == 15 || CurrentFood == 20))
// {
// Scale(scale, scale, scale);
// ParticleSystem ps = Instantiate(changeModeEffect, transform.position, transform.rotation);
// ps.gameObject.AddComponent<DestroyMySel>();
// if (type == "Hurt")
// {
// GenerateRandomFoodAroundPos(5, transform.position, 5);//生成5个食物距离为5
// }
// }
//}
//scale
......@@ -480,6 +610,7 @@ public class AIMove : MonoBehaviour
public void GenerateRandomFoodAroundPos(int number, Vector3 targetPos, float radius)
{
//return;
float randomAngle = UnityEngine.Random.Range(0, 360);
for (int i = 0; i < number; i++)
{
GameObject obj = foods[UnityEngine.Random.Range(0, foods.Count)];
......@@ -496,7 +627,7 @@ public class AIMove : MonoBehaviour
go.tag = "Untagged";
go.GetComponent<Food>().isUnNomalFood = true;
//rig.AddForce(Quaternion.Euler(new Vector3(UnityEngine.Random.Range(-80, -20), UnityEngine.Random.Range(0, 360), 0)) * Vector3.forward * Force);
rig.AddForce(Quaternion.Euler(new Vector3(-45, i*360.0f / number, 0)) * Vector3.forward * Force);
rig.AddForce(Quaternion.Euler(new Vector3(-45, randomAngle+i * 360.0f / number, 0)) * Vector3.forward * Force);
}
}
......
......@@ -23,7 +23,7 @@ public class BossAttackDamageRange : MonoBehaviour
if (other.tag == "Player")
{
other.gameObject.GetComponentInChildren<PlayerMove>().Hurt(0.5f);
other.gameObject.GetComponentInChildren<PlayerMove>().Hurt(1);
ps = Instantiate(hitEffects, hitPos, transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>();
Handheld.Vibrate();//手机震动
......@@ -31,7 +31,7 @@ public class BossAttackDamageRange : MonoBehaviour
}
else if (other.tag == "Competitor")
{
other.gameObject.GetComponentInChildren<AIMove>().Hurt(0.5f);
other.gameObject.GetComponentInChildren<AIMove>().Hurt(1);
ps = Instantiate(hitEffects, hitPos, transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>();
//Handheld.Vibrate();//手机震动
......
......@@ -53,7 +53,7 @@ public class AttackTrigger : MonoBehaviour
//print(other.name+"受到伤害:");
if (other.tag == "Player")
{
other.gameObject.GetComponentInChildren<PlayerMove>().Hurt(0.5f);
other.gameObject.GetComponentInChildren<PlayerMove>().Hurt(1);
ps= Instantiate(hitEffects, hitPos.transform.position, hitPos.transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>();
//Handheld.Vibrate();//手机震动
......@@ -61,7 +61,7 @@ public class AttackTrigger : MonoBehaviour
}
else if (other.tag == "Competitor")
{
other.gameObject.GetComponentInChildren<AIMove>().Hurt(0.5f);
other.gameObject.GetComponentInChildren<AIMove>().Hurt(1);
ps=Instantiate(hitEffects, hitPos.transform.position, hitPos.transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>();
if (Root.tag == "Player")
......
using System.Collections;
using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using DG.Tweening.Core;
using HedgehogTeam.EasyTouch;
using TMPro;
using System;
public class PlayerMove : MonoBehaviour
......@@ -61,7 +55,7 @@ public class PlayerMove : MonoBehaviour
public GameObject topPOS;
public int Count = 0;
// Start is called before the first frame update
......@@ -79,27 +73,38 @@ public class PlayerMove : MonoBehaviour
private void OnTriggerEnter(Collider other)
{
//print("OnTriggerEnter:"+other.tag+"--"+other.name);
if (other.tag == "Food")
{
//print("吃到食物。");
Handheld.Vibrate();//手机震动
UpdateScore(1);
if (scale >= (1 + MaxFood * addScale))
if (CurrentFood >= MaxFood)
{
scale = 1 + MaxFood * addScale;
CurrentFood = MaxFood;
}
else
{
scale += addScale;
//进行食物累计和缩放模型。
AddIsPlayChangeModeEffect();
}
CurrentFood++;
scale = 1 + CurrentFood * addScale;
ChangeAnimationscaleState(scale);
switch (CurrentFood)
{
case 5:
case 10:
case 15:
case 20:
Scale(scale, scale, scale);
ParticleSystem ps = Instantiate(changeModeEffect, transform.position, transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>();
break;
default:
break;
}
}
Destroy(other.gameObject);
}
//print("1111" + other.gameObject.tag + "+" + other.gameObject.name);
}
public void UpdateScore(int addNumber)
......@@ -112,66 +117,73 @@ public class PlayerMove : MonoBehaviour
private void OnControllerColliderHit(ControllerColliderHit hit)
{
if (hit.gameObject== targetWall)
if (hit.gameObject == targetWall)
{
//print("Player碰到墙:"+ scale);
if (scale>1)
if (CurrentFood >=1)
{
//print("推墙");
hit.gameObject.GetComponent<Rigidbody>().AddForce(new Vector3(0, 0, 100));
scale -= reduceStep;
ReduceIsPlayChangeModeEffect("PushWall");
int aa=hit.gameObject.GetComponent<Wall>().MakeWallMove();
Count += aa;
CurrentFood -= aa;
//Debug.LogError("CurrentFood:" + CurrentFood+"aa:"+aa);
scale -= aa*addScale;
switch (CurrentFood)
{
case 0:
Scale(scale, scale, scale);
break;
case 5:
case 10:
case 15:
case 20:
Scale(scale, scale, scale);
ParticleSystem ps = Instantiate(changeModeEffect, transform.position, transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>();
break;
default:
break;
}
}
else
{
scale = 1;
CurrentFood = 0;
}
ChangeAnimationscaleState(scale);
}
//print("22222"+hit.gameObject.tag+"+"+hit.gameObject.name);
}
//受到伤害
public void Hurt(float hurt)
public void Hurt(int hurt)
{
//进行判断是否播放特效
scale -= hurt;
if (scale < 1)
CurrentFood -= hurt;
if (CurrentFood <= 0)
{
CurrentFood = 0;
scale = 1;
RefreshVertigo(hurt);
RefreshVertigo(1);
}
ChangeAnimationscaleState(scale);
ReduceIsPlayChangeModeEffect("Hurt");
}
//食物增加时,判断是否播放改变模型特效
public void AddIsPlayChangeModeEffect()
{
CurrentFood++;
if (CurrentFood == 5 || CurrentFood == 10 || CurrentFood == 15 || CurrentFood == 20)
switch (CurrentFood)
{
case 0:
Scale(scale, scale, scale);
ParticleSystem ps = Instantiate(changeModeEffect, transform.position, transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>();
}
}
/// <summary>
/// 减少时,判断是否播放改变模型特效
/// </summary>
public void ReduceIsPlayChangeModeEffect(string type)
{
int tempFood = CurrentFood;
CurrentFood = (int)((scale - 1.0f) / addScale);
if (tempFood != CurrentFood && (CurrentFood == 0||CurrentFood == 5 || CurrentFood == 10 || CurrentFood == 15 || CurrentFood == 20))
{
break;
case 5:
case 10:
case 15:
case 20:
Scale(scale, scale, scale);
ParticleSystem ps = Instantiate(changeModeEffect, transform.position, transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>();
if (type == "Hurt")
{
GenerateRandomFoodAroundPos(5, transform.position, 5);//生成5个食物距离为5
}
break;
default:
break;
}
}
......@@ -435,6 +447,7 @@ public class PlayerMove : MonoBehaviour
/// <param name="radius"></param>
public void GenerateRandomFoodAroundPos(int number, Vector3 targetPos,float radius)
{
float randomAngle = UnityEngine.Random.Range(0, 360);
//return;
for (int i = 0; i < number; i++)
{
......@@ -452,7 +465,7 @@ public class PlayerMove : MonoBehaviour
go.tag = "Untagged";
go.GetComponent<Food>().isUnNomalFood = true;
//rig.AddForce(Quaternion.Euler(new Vector3(UnityEngine.Random.Range(-80, -20), UnityEngine.Random.Range(0, 360), 0)) * Vector3.forward * Force);
rig.AddForce(Quaternion.Euler(new Vector3(-45, i*360.0f/number,0)) * Vector3.forward * Force);
rig.AddForce(Quaternion.Euler(new Vector3(-45, randomAngle+i * 360.0f/number,0)) * Vector3.forward * Force);
}
}
......
......@@ -4,18 +4,32 @@ using UnityEngine;
public class Wall : MonoBehaviour
{
//public AttackTrigger target;
public ParticleSystem ps;
[Header("改变模型特效")]
public ParticleSystem changeModelEffect;
[Header("墙的移动")]
public GameObject targetPath;
public int stepNumberToEnd = 30;
public bool isMove = false;
public bool isMoveComplete = true;
public float Speed = 10;
public float pathLength;
public float stepLength;
public Vector3 tempBeginPos;
public Vector3 targetPos;
void Start()
{
pathLength = targetPath.GetComponent<Collider>().bounds.size.z;
stepLength = pathLength / stepNumberToEnd;
tempBeginPos = transform.position;
targetPos = transform.position + new Vector3(0, 0, stepLength);
}
private void OnTriggerEnter(Collider other)
{
if (other.name == "PathEndTrigger")
{
ParticleSystem particleSystem= Instantiate(ps, transform.position+new Vector3(0,2,0), transform.rotation);
ParticleSystem particleSystem= Instantiate(changeModelEffect, transform.position+new Vector3(0,2,0), transform.rotation);
particleSystem.gameObject.AddComponent<DestroyMySel>();
particleSystem.transform.localScale = new Vector3(2,2,2);
particleSystem.Play();
......@@ -26,6 +40,49 @@ public class Wall : MonoBehaviour
void Update()
{
if (isMove == false)
{
tempBeginPos = transform.position;
targetPos = transform.position + new Vector3(0, 0, stepLength);
isMoveComplete = true;
}
else
{
//均速移动一定的距离
if (targetPos.z-transform.position.z >Speed/20.0) //速度太快会有问题。
{
isMoveComplete = false;
//transform.position = Vector3.Lerp(tempBeginPos, targetPos, timer/stepLengthCoseTime);
transform.position +=(targetPos - tempBeginPos) * Time.deltaTime*1/(stepLength/Speed);
}else
{
isMove = false;
isMoveComplete = true;
transform.position = targetPos;
tempBeginPos = transform.position;
targetPos = transform.position + new Vector3(0, 0, stepLength);
}
}
}
public void Move()
{
}
public int MakeWallMove()
{
if (!isMoveComplete) {
//墙还在移动中
return 0;
}
else
{
//墙静止
isMove = true;
isMoveComplete = false;
return 1;
}
}
}
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