Commit 062757c0 authored by czy's avatar czy

添加得分

parent ac35d6d6
...@@ -51,6 +51,12 @@ public class BattleUI : MonoBehaviour ...@@ -51,6 +51,12 @@ public class BattleUI : MonoBehaviour
public GameObject Text100C; public GameObject Text100C;
public Text PurseText; public Text PurseText;
[Header("得分2")]
public Text PlayerText;
public Text Competitor1Text;
public Text Competitor2Text;
public Action onStartBtn; public Action onStartBtn;
public Action onPosUpBtn; public Action onPosUpBtn;
public Action onPosDownBtn; public Action onPosDownBtn;
...@@ -59,6 +65,8 @@ public class BattleUI : MonoBehaviour ...@@ -59,6 +65,8 @@ public class BattleUI : MonoBehaviour
public Action onClawMoveSpeedAddBtn; public Action onClawMoveSpeedAddBtn;
public Action onClawMoveSpeedDownBtn; public Action onClawMoveSpeedDownBtn;
//private Text m_ShowOrHideMouseText;//显示或隐藏手指text //private Text m_ShowOrHideMouseText;//显示或隐藏手指text
...@@ -183,7 +191,7 @@ public class BattleUI : MonoBehaviour ...@@ -183,7 +191,7 @@ public class BattleUI : MonoBehaviour
//开始游戏 //开始游戏
void StartBtn() void StartBtn()
{ {
//print("点击开始按钮"); print("点击开始按钮");
onStartBtn?.Invoke(); onStartBtn?.Invoke();
//m_startBtn.gameObject.SetActive(false); //m_startBtn.gameObject.SetActive(false);
m_startLogoObj.SetActive(false); m_startLogoObj.SetActive(false);
...@@ -360,6 +368,7 @@ public class BattleUI : MonoBehaviour ...@@ -360,6 +368,7 @@ public class BattleUI : MonoBehaviour
//设置战斗UI状态 //设置战斗UI状态
public void SetBattleObjState(bool bool_) public void SetBattleObjState(bool bool_)
{ {
print("显示m_battleObj:"+bool_);
m_battleObj.SetActive(bool_); m_battleObj.SetActive(bool_);
//m_successResultObj.SetActive(bool_); //m_successResultObj.SetActive(bool_);
//m_successResultMaskObj.SetActive(!bool_); //m_successResultMaskObj.SetActive(!bool_);
...@@ -491,6 +500,24 @@ public class BattleUI : MonoBehaviour ...@@ -491,6 +500,24 @@ public class BattleUI : MonoBehaviour
} }
} }
public void UpdateScore2(string name,string text)
{
print("name:" + name + ",text" + text);
switch (name)
{
case "Player":
PlayerText.text = text;
break;
case "Competitor1":
Competitor1Text.text = text;
break;
case "Competitor2":
Competitor2Text.text = text;
break;
default:
break;
}
}
void OnDestroy() void OnDestroy()
{ {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -51,6 +51,7 @@ public class AIMove : MonoBehaviour ...@@ -51,6 +51,7 @@ public class AIMove : MonoBehaviour
public AIState aiState; public AIState aiState;
private float vertigoTime = 0.0f; private float vertigoTime = 0.0f;
private AnimationManager animationManager; private AnimationManager animationManager;
public int Score=0;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
...@@ -76,6 +77,7 @@ public class AIMove : MonoBehaviour ...@@ -76,6 +77,7 @@ public class AIMove : MonoBehaviour
//Destroy(other.gameObject); //Destroy(other.gameObject);
//print("吃到食物。"); //print("吃到食物。");
UpdateScore(1);
HaveFoodNumber++; HaveFoodNumber++;
if (RandomFoodNumberToPush<= HaveFoodNumber && targetWall!=null) if (RandomFoodNumberToPush<= HaveFoodNumber && targetWall!=null)
{ {
...@@ -102,6 +104,11 @@ public class AIMove : MonoBehaviour ...@@ -102,6 +104,11 @@ public class AIMove : MonoBehaviour
Destroy(other.gameObject); Destroy(other.gameObject);
} }
} }
public void UpdateScore(int addNumber)
{
Score+=addNumber;
BattleUI.instance.UpdateScore2(gameObject.name, gameObject.name + ":" + Score);
}
private void Scale(float x, float y, float z) private void Scale(float x, float y, float z)
{ {
......
...@@ -34,6 +34,7 @@ public class BossMove : MonoBehaviour ...@@ -34,6 +34,7 @@ public class BossMove : MonoBehaviour
public float Timer1 = 5; public float Timer1 = 5;
public bool isDeltaTime = false; public bool isDeltaTime = false;
private bool isAttacking=false; private bool isAttacking=false;
public enum BossState public enum BossState
{ {
...@@ -43,6 +44,8 @@ public class BossMove : MonoBehaviour ...@@ -43,6 +44,8 @@ public class BossMove : MonoBehaviour
} }
public BossState bossState= BossState.Sleep; public BossState bossState= BossState.Sleep;
void Start() void Start()
{ {
...@@ -162,7 +165,7 @@ public class BossMove : MonoBehaviour ...@@ -162,7 +165,7 @@ public class BossMove : MonoBehaviour
if (Vector3.Distance(pos1, pos2) < 10f) if (Vector3.Distance(pos1, pos2) < 10f)
{ {
isAttacking = true;
//print("boss附近敌人个数:"+ EnemyNumber+"技能是否不能使用:"+ isDeltaTime); //print("boss附近敌人个数:"+ EnemyNumber+"技能是否不能使用:"+ isDeltaTime);
if (EnemyNumber >= 2&& !isDeltaTime) if (EnemyNumber >= 2&& !isDeltaTime)
{ {
...@@ -176,6 +179,7 @@ public class BossMove : MonoBehaviour ...@@ -176,6 +179,7 @@ public class BossMove : MonoBehaviour
else else
{ {
//print("2222222222222"); //print("2222222222222");
isAttacking = true;
animator.SetBool("HurricaneKick", false); animator.SetBool("HurricaneKick", false);
animator.SetBool("LegSweep", true); animator.SetBool("LegSweep", true);
bossAttack.attackType = AttackType.LegSweep; bossAttack.attackType = AttackType.LegSweep;
...@@ -214,17 +218,19 @@ public class BossMove : MonoBehaviour ...@@ -214,17 +218,19 @@ public class BossMove : MonoBehaviour
if (isAttacking) if (isAttacking)
{ {
xDelta = 0;
zDelta = 0;
//yDelta = 0;
} }
//print("isAttacking:" + isAttacking+"Boss开始移动:" + new Vector3(xDelta, yDelta, zDelta)); else
characterController.Move(new Vector3(xDelta, yDelta, zDelta));//移动 {
//print("isAttacking:" + isAttacking+"Boss开始移动:" + new Vector3(xDelta, yDelta, zDelta));
characterController.Move(new Vector3(xDelta, yDelta, zDelta));//移动
}
//移动 //移动
MoveSpeed = Vector3.Distance(Vector3.zero, characterController.velocity); MoveSpeed = new Vector3(xDelta,0,zDelta).magnitude;
//是否在地面 //是否在地面
Grounded = characterController.isGrounded; Grounded = characterController.isGrounded;
animator.SetFloat("MoveSpeed", MoveSpeed); animator.SetFloat("MoveSpeed", MoveSpeed);
......
...@@ -4,6 +4,7 @@ using UnityEngine; ...@@ -4,6 +4,7 @@ using UnityEngine;
public class AttackTrigger : MonoBehaviour public class AttackTrigger : MonoBehaviour
{ {
public GameObject Root;
public Animator animator; public Animator animator;
public List<string> OtherTagList = new List<string> { "Competitor","Boss" }; public List<string> OtherTagList = new List<string> { "Competitor","Boss" };
public GameObject targetWall; public GameObject targetWall;
...@@ -51,7 +52,7 @@ public class AttackTrigger : MonoBehaviour ...@@ -51,7 +52,7 @@ public class AttackTrigger : MonoBehaviour
ps= Instantiate(hitEffects, hitPos.transform.position, hitPos.transform.rotation); 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")
{ {
...@@ -59,6 +60,7 @@ public class AttackTrigger : MonoBehaviour ...@@ -59,6 +60,7 @@ public class AttackTrigger : MonoBehaviour
ps=Instantiate(hitEffects, hitPos.transform.position, hitPos.transform.rotation); 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 == "Boss") else if (other.tag == "Boss")
{ {
...@@ -66,6 +68,14 @@ public class AttackTrigger : MonoBehaviour ...@@ -66,6 +68,14 @@ public class AttackTrigger : MonoBehaviour
ps = Instantiate(hitEffects, hitPos.transform.position, hitPos.transform.rotation); ps = Instantiate(hitEffects, hitPos.transform.position, hitPos.transform.rotation);
ps.gameObject.AddComponent<DestroyMySel>(); ps.gameObject.AddComponent<DestroyMySel>();
Handheld.Vibrate();//手机震动 Handheld.Vibrate();//手机震动
if (Root.name == "Player")
{
Root.GetComponentInChildren<PlayerMove>().UpdateScore(2);
}
else if (Root.name == "Competitor")
{
Root.GetComponentInChildren<AIMove>().UpdateScore(2);
}
} }
} }
} }
......
...@@ -49,7 +49,8 @@ public class PlayerMove : MonoBehaviour ...@@ -49,7 +49,8 @@ public class PlayerMove : MonoBehaviour
private AnimationManager animationManager; private AnimationManager animationManager;
public RiseBridge riseBridge; public RiseBridge riseBridge;
public int Score = 0;
...@@ -73,6 +74,7 @@ public class PlayerMove : MonoBehaviour ...@@ -73,6 +74,7 @@ public class PlayerMove : MonoBehaviour
if (other.tag == "Food") if (other.tag == "Food")
{ {
//print("吃到食物。"); //print("吃到食物。");
UpdateScore(1);
if (scale >= (1 + MaxFood * addScale)) if (scale >= (1 + MaxFood * addScale))
{ {
scale = 1 + MaxFood * addScale; scale = 1 + MaxFood * addScale;
...@@ -90,17 +92,22 @@ public class PlayerMove : MonoBehaviour ...@@ -90,17 +92,22 @@ public class PlayerMove : MonoBehaviour
//print("1111" + other.gameObject.tag + "+" + other.gameObject.name); //print("1111" + other.gameObject.tag + "+" + other.gameObject.name);
} }
public void UpdateScore(int addNumber)
{
Score += addNumber;
BattleUI.instance.UpdateScore2(gameObject.name, gameObject.name + ":" + Score);
}
private void OnControllerColliderHit(ControllerColliderHit hit) private void OnControllerColliderHit(ControllerColliderHit hit)
{ {
if (hit.gameObject== targetWall) if (hit.gameObject== targetWall)
{ {
//print("碰到墙"); print("Player碰到墙:"+ scale);
if (scale>1) if (scale>1)
{ {
print("推墙");
hit.gameObject.GetComponent<Rigidbody>().AddForce(new Vector3(0, 0, 100)); hit.gameObject.GetComponent<Rigidbody>().AddForce(new Vector3(0, 0, 100));
scale -= reduceStep; scale -= reduceStep;
ReduceIsPlayChangeModeEffect(); ReduceIsPlayChangeModeEffect();
......
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