| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using Cysharp.Threading.Tasks; |
| | | using DG.Tweening; |
| | | using UnityEngine; |
| | |
| | | [SerializeField] Text awardCntText; |
| | | //攻击区 |
| | | [SerializeField] UIHeroController bossModel; |
| | | |
| | | [SerializeField] Transform atkTargetPos; |
| | | [SerializeField] HorseController heroModel; |
| | | [SerializeField] Transform attackArea1; |
| | | [SerializeField] Transform attackArea2; |
| | | [SerializeField] Transform attackArea3; |
| | | [SerializeField] Transform[] attackAreas; |
| | | [SerializeField] RectTransform attackAreaParent; |
| | | [SerializeField] GuildBossOtherPlayer otherPlayer; //创建多个用 |
| | | [SerializeField] GuildBossOtherPlayerAttack otherPlayerAttack; //创建多个用 |
| | | List<GuildBossOtherPlayer> otherPlayers; |
| | | [SerializeField] GuildBossOtherPlayerAttack[] otherPlayerAttacks; |
| | | |
| | | //自己的攻击 |
| | | [SerializeField] UIEffectPlayer hurtEffect; |
| | |
| | | [SerializeField] Image[] awardIcons; |
| | | [SerializeField] Transform pos1; |
| | | [SerializeField] Transform pos2; |
| | | [SerializeField] Transform[] dropBoxes; |
| | | [SerializeField] Transform targetPos; |
| | | |
| | | |
| | | [SerializeField] Transform fakeRedBZ; |
| | | [SerializeField] Transform fakeRedAward; |
| | |
| | | beforeLayerNum = (int)layer; |
| | | } |
| | | ShowDynamicUI(); |
| | | ShowDropBox(); |
| | | ShowOtherAttacker(); |
| | | } |
| | | |
| | | void ShowRank() |
| | |
| | | endTimeText.text = Language.Get("Arena14", TimeUtility.SecondsToHMS((int)(TimeUtility.GetTodayEndTime() - TimeUtility.ServerNow).TotalSeconds)); |
| | | var bossAction = GuildBossManager.Instance.GetGuildBossAction(); |
| | | ShowBzInfo(bossAction); |
| | | OtherPlayerAnimation(); |
| | | } |
| | | |
| | | void ShowProcess(float value) |
| | |
| | | |
| | | void OnBzBtnClick() |
| | | { |
| | | int curLayer = 0; |
| | | var bossAction = GuildBossManager.Instance.GetGuildBossAction(); |
| | | if (bossAction != null) |
| | | { |
| | | curLayer = (int)bossAction.Value3; |
| | | } |
| | | // int curLayer = 0; |
| | | // var bossAction = GuildBossManager.Instance.GetGuildBossAction(); |
| | | // if (bossAction != null) |
| | | // { |
| | | // curLayer = (int)bossAction.Value3; |
| | | // } |
| | | |
| | | // if (curLayer >= GuildBossManager.Instance.bzMaxLevel) |
| | | // { |
| | |
| | | bossModel.onComplete = null; |
| | | }; |
| | | bossModel.PlayAnimation("chuxian"); |
| | | lastValueIndex = FindHurtIndex(); |
| | | |
| | | for (int i = 0; i < dropBoxes.Length; i++) |
| | | { |
| | | dropBoxes[i].transform.localScale = Vector3.zero; |
| | | } |
| | | |
| | | for (int i = otherPlayers.Count - 1; i >= 0; i--) |
| | | { |
| | | otherPlayers[i].moveState = 0; |
| | | } |
| | | for (int i = 0; i < otherPlayerAttacks.Length; i++) |
| | | { |
| | | otherPlayerAttacks[i].Hide(); |
| | | //置底 |
| | | otherPlayerAttacks[i].transform.SetAsLastSibling(); |
| | | } |
| | | } |
| | | |
| | | int lastValueIndex = -1; // -1 未达标 |
| | | void ShowDropBox() |
| | | { |
| | | int index = FindHurtIndex(); |
| | | if (index > lastValueIndex) |
| | | { |
| | | var showBoxCnt = index - lastValueIndex; |
| | | lastValueIndex = index; |
| | | for (int i = 0; i < dropBoxes.Length; i++) |
| | | { |
| | | if (i < showBoxCnt) |
| | | { |
| | | dropBoxes[i].transform.localScale = Vector3.one*0.5f; |
| | | |
| | | var startPos = new Vector3(UnityEngine.Random.Range(-80, 80), 30, 0); |
| | | //随机方向返回1或者-1 |
| | | int randDir = UnityEngine.Random.Range(0, 2) == 0 ? 1 : -1; |
| | | |
| | | dropBoxes[i].localPosition = startPos; |
| | | int _index = i; |
| | | dropBoxes[i].DOLocalPath(new Vector3[] { startPos, |
| | | new Vector3(startPos.x + randDir * 10, startPos.y + 30f, 0), |
| | | new Vector3(startPos.x + randDir * 25, startPos.y - 60, 0) }, 0.5f, PathType.CatmullRom).SetEase(Ease.InOutSine).OnComplete(()=> |
| | | { |
| | | dropBoxes[_index].DOLocalMove(targetPos.localPosition, 0.3f).OnComplete(()=> |
| | | { |
| | | dropBoxes[_index].transform.localScale = Vector3.zero; |
| | | awardBtn.GetComponent<ScaleTween>().Play(); |
| | | }); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | dropBoxes[i].transform.localScale = Vector3.zero; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | int FindHurtIndex() |
| | | { |
| | | for (int i = 0; i < GuildBossManager.Instance.allBXCumulativeDamageList.Count; i++) |
| | | { |
| | | if (GuildBossManager.Instance.m_BoxHurt < GuildBossManager.Instance.allBXCumulativeDamageList[i]) |
| | | { |
| | | return i - 1; |
| | | } |
| | | } |
| | | return GuildBossManager.Instance.allBXCumulativeDamageList.Count; |
| | | } |
| | | |
| | | void ShowOtherAttacker() |
| | | { |
| | | CreateOtherAttacker(); |
| | | var cnt = GuildBossManager.Instance.playerBossHurtRank.Count; |
| | | //伤害高的在上面,逆序显示 |
| | | for (int i = otherPlayers.Count - 1; i >= 0; i--) |
| | | { |
| | | if (i < cnt) |
| | | { |
| | | otherPlayers[i].SetActive(true); |
| | | otherPlayers[i].Display(GuildBossManager.Instance.playerBossHurtRank[cnt - i - 1]); |
| | | } |
| | | else |
| | | { |
| | | otherPlayers[i].SetActive(false); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | void CreateOtherAttacker() |
| | | { |
| | | if (otherPlayers.IsNullOrEmpty()) |
| | | { |
| | | otherPlayers = new List<GuildBossOtherPlayer>(); |
| | | } |
| | | |
| | | int addCnt = GuildBossManager.Instance.playerBossHurtRank.Count - otherPlayers.Count; |
| | | for (int i = 0; i < addCnt; i++) |
| | | { |
| | | var inst = Instantiate(otherPlayer, attackAreaParent); |
| | | //坐标从attackAreas 随机一个组件,然后在组件的范围内随机,父类为attackAreaParent |
| | | int pos = UnityEngine.Random.Range(0, attackAreas.Length); |
| | | var rect = attackAreas[pos] as RectTransform; |
| | | inst.transform.localPosition = attackAreas[pos].transform.localPosition + |
| | | new Vector3(UnityEngine.Random.Range(-rect.rect.width / 2, rect.rect.width / 2), |
| | | UnityEngine.Random.Range(-rect.rect.height / 2, rect.rect.height / 2), 0); |
| | | inst.NotePos(); |
| | | otherPlayers.Add(inst); |
| | | } |
| | | } |
| | | |
| | | void OtherPlayerAnimation() |
| | | { |
| | | if (GuildBossManager.Instance.taofaAtkData.Keys.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | var keys = GuildBossManager.Instance.taofaAtkData.Keys.ToList(); |
| | | keys.Sort(); |
| | | int index = keys.IndexOf(GuildBossManager.Instance.lastPlayTick) + 1; |
| | | if (index >= keys.Count) |
| | | { |
| | | index = 0; |
| | | } |
| | | GuildBossManager.Instance.lastPlayTick = keys[index]; |
| | | var atkData = GuildBossManager.Instance.taofaAtkData[keys[index]]; |
| | | var atkPlayerID = atkData.playerID; |
| | | for (int i = 0; i < otherPlayers.Count; i++) |
| | | { |
| | | if (!otherPlayers[i].isActiveAndEnabled) |
| | | { |
| | | continue; |
| | | } |
| | | if (otherPlayers[i].moveState != 0) |
| | | { |
| | | continue; |
| | | } |
| | | // 突进 |
| | | if (otherPlayers[i].playerID == atkPlayerID) |
| | | { |
| | | if (otherPlayers[i].moveState != 1) |
| | | { |
| | | otherPlayers[i].moveState = 1; |
| | | //向目标 atkTargetPos 突进80后回原位置 |
| | | Vector3 currentPos = otherPlayers[i].transform.localPosition; |
| | | Vector3 targetPos = atkTargetPos.localPosition; |
| | | |
| | | // 计算从当前点到目标点的方向向量 |
| | | Vector3 direction = (targetPos - currentPos).normalized; |
| | | |
| | | // 向目标方向移动80的距离 |
| | | Vector3 attackPos = currentPos + direction * 50f; |
| | | |
| | | // 记录原位置,用于后续返回 |
| | | Vector3 originalPos = currentPos; |
| | | |
| | | // 先移动到攻击位置,然后返回原位置 |
| | | // 先停止原位置的移动 |
| | | int _index = i; |
| | | int valueIndex = i % otherPlayerAttacks.Length; |
| | | otherPlayerAttacks[valueIndex].transform.localPosition = currentPos + direction * 160f; |
| | | otherPlayerAttacks[valueIndex].Display(atkData); |
| | | |
| | | otherPlayers[i].transform.DOKill(); |
| | | otherPlayers[i].transform.DOLocalMove(attackPos, 0.2f).SetEase(Ease.OutQuad) |
| | | .OnComplete(() => |
| | | { |
| | | otherPlayers[_index].transform.DOLocalMove(originalPos, 0.2f).SetEase(Ease.InQuad); |
| | | otherPlayers[_index].moveState = 0; |
| | | }); |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | otherPlayers[i].transform.DOKill(); |
| | | //缓慢移动 |
| | | var randomPos = otherPlayers[i].startPos + new Vector3(UnityEngine.Random.Range(-50, 50), UnityEngine.Random.Range(-50, 50), 0); |
| | | otherPlayers[i].transform.DOLocalMove(randomPos, 2f).SetEase(Ease.InOutSine); |
| | | |
| | | } |
| | | } |
| | | } |