Commit 062757c0 authored by czy's avatar czy

添加得分

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