| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using DG.Tweening;
- /* PK模式的轮换选手的准备界面 */
- public class PKGameReadyView_Challenge : MonoBehaviour
- {
- GameMode gameMode;
- [System.NonSerialized] public int currentPlayerIndex = 0;
- bool isDiscarded = false;//丢弃的
- static PKGameReadyView_Challenge ins;
- void Awake()
- {
- if (ins) {
- ins.isDiscarded = true;
- Destroy(ins.gameObject);
- }
- ins = this;
- GameMgr.ins.addLockerForGamePause(this);
- }
- void Start()
- {
- if (isDiscarded) return;
- gameMode = GameMgr.ins.gameMode;
- GameObject.FindObjectOfType<ArmBow>().Hide();
- RenderPlayerInfo();
- RunAnimation();
- }
- void RenderPlayerInfo() {
- if (GlobalData.pkMatchType == PKMatchType.LocalPK) {
- int curPlayerIndex = ((ChallengeGameModeLocalPK) gameMode).GetCurrentPlayIndex();
- (Sprite avatar, string nickName) = RoleMgr.GetRoleInfo(PKGameMode.playerRoleIDs[curPlayerIndex]);
- this.transform.Find("Panel/Avatar/Sprite").GetComponent<Image>().sprite = avatar;
- this.transform.Find("Panel/Name").GetComponent<Text>().text = nickName;
- }
- else if (GlobalData.pkMatchType == PKMatchType.OnlinePK) {
- int curPlayerIndex = ((ChallengeGameModeLocalPK) gameMode).GetCurrentPlayIndex();
- Sprite avatar = RoleMgr.GetAvatar(GlobalData.matchPlayerInfos[curPlayerIndex].avatarID);
- string nickname = GlobalData.matchPlayerInfos[curPlayerIndex].nickname;
- this.transform.Find("Panel/Avatar/Sprite").GetComponent<Image>().sprite = avatar;
- this.transform.Find("Panel/Name").GetComponent<Text>().text = nickname;
- }
- }
- void RunAnimation() {
- Image mask = this.transform.Find("Mask").GetComponent<Image>();
- Transform panel = this.transform.Find("Panel");
- Sequence seq = DOTween.Sequence();
- seq.AppendCallback(delegate() {
- mask.gameObject.SetActive(true);
- });
- seq.Append(mask.DOFade(1, 0.5f));
- seq.AppendCallback(delegate() {
- panel.gameObject.SetActive(true);
- });
- seq.Append(mask.DOFade(0, 1f));
- seq.AppendInterval(1f);
- seq.Append(panel.DOScaleX(0, 0.4f));
- seq.AppendCallback(delegate() {
- Destroy(this.gameObject);
- });
- seq.SetUpdate(true);
- }
- void OnDestroy()
- {
- if (ins == this) ins = null;
- if (GameMgr.ins) GameMgr.ins.removeLockerForGamePause(this);
- if (isDiscarded) return;
- if (ArmBow.ins) ArmBow.ins.Show();
- gameMode.UnbanBowReady();
- }
- }
|