| | |
| | | |
| | | public Text DoubleHitText; |
| | | |
| | | public GameObject OneTimeKillObj; |
| | | public Image OneTimeKillObj; |
| | | |
| | | public Text OneTimeKillText; |
| | | |
| | | /// <summary> |
| | | /// 连击的CD时间 |
| | | /// </summary> |
| | | private float doubleHitCD = 3f; |
| | | private float doubleHitCD = 0.8f; |
| | | |
| | | private float remainTime; |
| | | |
| | |
| | | private void Start() |
| | | { |
| | | Init(); |
| | | EventCenter.Ins.Add<Agent>((int)KTGMGemClient.EventType.EndlessAgentDead, AgentDead); |
| | | EventCenter.Ins.Add<int>((int)KTGMGemClient.EventType.EndlessAgentDead, AgentDead); |
| | | EventCenter.Ins.Add((int)KTGMGemClient.EventType.EndlessOneHit, OnHit); |
| | | EventCenter.Ins.Add<int>((int)KTGMGemClient.EventType.EndlessOneTimeKillCount, OnTimeKill); |
| | | canvasGroup = DoubleHit.GetComponent<CanvasGroup>(); |
| | |
| | | } |
| | | } |
| | | |
| | | private void AgentDead(Agent agent) |
| | | private void AgentDead(int point) |
| | | { |
| | | if (EndlessGameUI.instance.state == EndlessGameUI.State.GameOver) return; |
| | | AddScore(agent.EnemyData.point); |
| | | AddScore(point); |
| | | } |
| | | |
| | | // Update is called once per frame |
| | |
| | | ++DoubleHitCount; |
| | | openDoubleHit = true; |
| | | DoubleHitText.text = $"{DoubleHitCount}"; |
| | | ShowDoubleHit(); |
| | | if (DoubleHitCount >= 10) |
| | | ShowDoubleHit(); |
| | | remainTime = doubleHitCD; |
| | | |
| | | // 策划说先写死吧 |
| | |
| | | /// <param name="score"></param> |
| | | private void ShowOneTimeKill(int count, int score) |
| | | { |
| | | OneTimeKillText.text = $"{count}连杀 +{score}"; |
| | | OneTimeKillObj.transform.localScale = Vector3.zero; |
| | | OneTimeKillObj.SetActive(true); |
| | | CanvasGroup cg = OneTimeKillObj.GetComponent<CanvasGroup>(); |
| | | DOTween.To(() => OneTimeKillObj.transform.localScale, (Vector3 v) => OneTimeKillObj.transform.localScale = v, Vector3.one, 0.2f); |
| | | Tween t1 = DOTween.To(() => cg.alpha, (float v) => cg.alpha = v, 0f, 0.2f).SetDelay(2f); |
| | | t1.OnComplete(OnShowOneTimeKillComplete); |
| | | } |
| | | |
| | | private void OnShowOneTimeKillComplete() |
| | | { |
| | | OneTimeKillObj.SetActive(false); |
| | | Image obj = Instantiate(OneTimeKillObj); |
| | | obj.transform.SetParent(GameObject.Find("Panel").transform, false); |
| | | obj.sprite = Resources.Load<Sprite>($"UI/DoubleHit/hit_{count}"); |
| | | Destroy(obj.gameObject, 2.05f); |
| | | } |
| | | |
| | | /// <summary> |