备份CatanBuilding瘦身独立工程
This commit is contained in:
124
Assets/Scripts/UI/SmallGame/BankHeistItem.cs
Normal file
124
Assets/Scripts/UI/SmallGame/BankHeistItem.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class BankHeistItem : MonoBehaviour
|
||||
{
|
||||
Image icon;
|
||||
Button btn;
|
||||
//GameObject master;
|
||||
public HeistItem heistItem;
|
||||
//TMP_Text text_num;
|
||||
public Action<BankHeistItem> action;
|
||||
public bool isMaster;
|
||||
Animation anim;
|
||||
ItemData itemData;
|
||||
RewardItemNew rewardItemNew;
|
||||
private void Awake()
|
||||
{
|
||||
//text_num= transform.Find("text_num").GetComponent<TMP_Text>();
|
||||
//master = transform.Find("icon_master").gameObject;
|
||||
icon = transform.Find("icon").GetComponent<Image>();
|
||||
btn = transform.GetComponent<Button>();
|
||||
anim = transform.GetComponent<Animation>();
|
||||
rewardItemNew = transform.Find("reward").GetComponent<RewardItemNew>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn.onClick.AddListener(OnClickBtn);
|
||||
isMaster = true;
|
||||
//master.SetActive(true);
|
||||
}
|
||||
|
||||
public void SetData(HeistItem heistItem, int multiple)
|
||||
{
|
||||
this.heistItem = heistItem;
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon, heistItem.Icon, BasePanel.PanelName);
|
||||
if (heistItem.RewardID > 0)
|
||||
{
|
||||
itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(heistItem.RewardID);
|
||||
if (itemData != null)
|
||||
{
|
||||
itemData.count *= multiple;
|
||||
}
|
||||
}
|
||||
//if (itemData != null)
|
||||
//{
|
||||
// itemData.count *= multiple;
|
||||
// if (heistItem.Type == 1 && text_num != null)
|
||||
// {
|
||||
// text_num.text = $"+{(int)itemData.count}";
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// text_num.text = "";
|
||||
//}
|
||||
//master.SetActive(false);
|
||||
}
|
||||
public void PlayAni()
|
||||
{
|
||||
isMaster = false;
|
||||
|
||||
anim.Play();
|
||||
}
|
||||
void OnClickBtn()
|
||||
{
|
||||
btn.enabled = false;
|
||||
action?.Invoke(this);
|
||||
}
|
||||
//额外道具
|
||||
public void OnGetAdditional()
|
||||
{
|
||||
if (isMaster)
|
||||
{
|
||||
GetReward();
|
||||
}
|
||||
//icon.transform.localScale = Vector3.one * 1.2f;
|
||||
//烟花
|
||||
PlayAni();
|
||||
//对勾
|
||||
}
|
||||
async void GetReward()
|
||||
{
|
||||
rewardItemNew.SetRewardPopupData(itemData, false);
|
||||
rewardItemNew.PlayOpen();
|
||||
|
||||
await Awaiters.Seconds(0.34f);
|
||||
await rewardItemNew.PlayClose();
|
||||
await rewardItemNew.ParticleAttractor();
|
||||
|
||||
}
|
||||
//正常结算
|
||||
public void OnOrdinarySuccess()
|
||||
{
|
||||
//icon.transform.localScale = Vector3.one * 1.2f;
|
||||
//背光
|
||||
PlayAni();
|
||||
}
|
||||
public void EndBomb()
|
||||
{
|
||||
PlayAni();
|
||||
}
|
||||
//炸弹炸完结算
|
||||
public void OnSuccess()
|
||||
{
|
||||
switch (heistItem.Type)
|
||||
{
|
||||
case 0:
|
||||
OnOrdinarySuccess();
|
||||
break;
|
||||
case 1:
|
||||
OnGetAdditional();
|
||||
break;
|
||||
case 2:
|
||||
EndBomb();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SmallGame/BankHeistItem.cs.meta
Normal file
11
Assets/Scripts/UI/SmallGame/BankHeistItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 486dcfd86c0d32245ad399cb1eb2c5ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
86
Assets/Scripts/UI/SmallGame/BankHeistTargetItem.cs
Normal file
86
Assets/Scripts/UI/SmallGame/BankHeistTargetItem.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using asap.core;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class BankHeistTargetItem : MonoBehaviour
|
||||
{
|
||||
List<GameObject> bgs = new List<GameObject>();
|
||||
List<Image> images = new List<Image>();
|
||||
List<GameObject> bgs_gray = new List<GameObject>();
|
||||
List<Image> images_gray = new List<Image>();
|
||||
List<Animation> animations = new List<Animation>();
|
||||
public int itemCount;
|
||||
List<BankHeistItem> bankHeistItems = new List<BankHeistItem>();
|
||||
Animation ani;
|
||||
private void Awake()
|
||||
{
|
||||
ani = transform.GetComponent<Animation>();
|
||||
for (int i = 1; i < 4; i++)
|
||||
{
|
||||
bgs.Add(transform.Find($"icon{i}/bg").gameObject);
|
||||
images.Add(transform.Find($"icon{i}/icon").GetComponent<Image>());
|
||||
bgs_gray.Add(transform.Find($"icon{i}/bg_gray").gameObject);
|
||||
images_gray.Add(transform.Find($"icon{i}/icon_gray").GetComponent<Image>());
|
||||
animations.Add(transform.Find($"icon{i}").GetComponent<Animation>());
|
||||
}
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
//for (int i = 0; i < bgs.Count; i++)
|
||||
//{
|
||||
// ChangeState(i, false);
|
||||
//}
|
||||
}
|
||||
public void SetIcon(string iconName)
|
||||
{
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(images[0], iconName, BasePanel.PanelName);
|
||||
images_gray[0].sprite = images[0].sprite;
|
||||
for (int i = 1; i < images.Count; i++)
|
||||
{
|
||||
images[i].sprite = images[0].sprite;
|
||||
images_gray[i].sprite = images[0].sprite;
|
||||
}
|
||||
//for (int i = 0; i < 3; i++)
|
||||
//{
|
||||
// bgs[i].SetActive(false);
|
||||
// images[i].gameObject.SetActive(false);
|
||||
// bgs_gray[i].SetActive(!true);
|
||||
// images_gray[i].gameObject.SetActive(!true);
|
||||
//}
|
||||
}
|
||||
public void Success()
|
||||
{
|
||||
for (int i = 0; i < bankHeistItems.Count; i++)
|
||||
{
|
||||
bankHeistItems[i].OnOrdinarySuccess();
|
||||
}
|
||||
ani.Play("EventBankHeistPanel_target_done");
|
||||
}
|
||||
public void OnAllShow()
|
||||
{
|
||||
ani.Play("EventBankHeistPanel_target_done");
|
||||
for (int i = 0; i < bgs.Count; i++)
|
||||
{
|
||||
ChangeState(i, true);
|
||||
}
|
||||
}
|
||||
public void OnAddItem(BankHeistItem bankHeistItem)
|
||||
{
|
||||
if (itemCount >= 3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bankHeistItems.Add(bankHeistItem);
|
||||
ChangeState(itemCount, true);
|
||||
itemCount++;
|
||||
}
|
||||
void ChangeState(int index, bool value)
|
||||
{
|
||||
animations[index].Play("EventBankHeistPanel_icon_open");
|
||||
//bgs[index].SetActive(value);
|
||||
//images[index].gameObject.SetActive(value);
|
||||
//bgs_gray[index].SetActive(!value);
|
||||
//images_gray[index].gameObject.SetActive(!value);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SmallGame/BankHeistTargetItem.cs.meta
Normal file
11
Assets/Scripts/UI/SmallGame/BankHeistTargetItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55694d449f1ae6741a110313726abd57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
86
Assets/Scripts/UI/SmallGame/BombBuilding.cs
Normal file
86
Assets/Scripts/UI/SmallGame/BombBuilding.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using asap.core;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UniRx;
|
||||
using TMPro;
|
||||
using GameCore;
|
||||
using DG.Tweening;
|
||||
|
||||
public class BombBuilding : MonoBehaviour
|
||||
{
|
||||
System.IDisposable disposable;
|
||||
public Transform[] bombPos;
|
||||
public PlayableDirector[] bombClip;
|
||||
public CannonRoot cannonRoot;
|
||||
|
||||
int posCount = 10;
|
||||
private void Awake()
|
||||
{
|
||||
cannonRoot = GetComponentInChildren<CannonRoot>();
|
||||
disposable = GContext.OnEvent<BombBuildingDataEvent>().Subscribe(OnBombBuildingDataEvent);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
cannonRoot.virtualCamera1.gameObject.SetActive(false);
|
||||
cannonRoot.shell.gameObject.SetActive(false);
|
||||
if (GContext.container.Resolve<PlayerData>().GetMagnification() > 1)
|
||||
{
|
||||
cannonRoot.text_beilv.text = $"x{GContext.container.Resolve<PlayerData>().GetMagnification()}";
|
||||
}
|
||||
else
|
||||
{
|
||||
cannonRoot.text_beilv.text = "";
|
||||
}
|
||||
}
|
||||
void OnBombBuildingDataEvent(BombBuildingDataEvent e)
|
||||
{
|
||||
if (e.index >= 0)
|
||||
{
|
||||
ShellPlay(e.index);
|
||||
}
|
||||
else if (e.index == -1)
|
||||
{
|
||||
e.bombBuilding = this;
|
||||
e.bombPos = bombPos;
|
||||
}
|
||||
else if (e.index == -2)
|
||||
{
|
||||
cannonRoot.cannon.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
public async void ShellPlay(int index)
|
||||
{
|
||||
Vector3 targetPos = bombPos[index].position;
|
||||
Vector3 position = new Vector3(targetPos.x, cannonRoot.cannon.position.y, targetPos.z);
|
||||
cannonRoot.cannon.DOLookAt(position, 0.5f);
|
||||
cannonRoot.fire.Play();
|
||||
cannonRoot.MoveCamera();
|
||||
await Awaiters.Seconds(cannonRoot.shellShowStay);
|
||||
Vector3 startPos = cannonRoot.shellStartPos.position;
|
||||
cannonRoot.shell.position = startPos;
|
||||
cannonRoot.shell.gameObject.SetActive(true);
|
||||
Vector3[] linePoints = new Vector3[3];
|
||||
linePoints[0] = targetPos;
|
||||
linePoints[1] = new Vector3(targetPos.x, startPos.y, targetPos.z);
|
||||
linePoints[2] = startPos;
|
||||
if (cannonRoot.cameraDuration > cannonRoot.duration * cannonRoot.durationRatio)
|
||||
{
|
||||
cannonRoot.cameraDuration = cannonRoot.duration * cannonRoot.durationRatio;
|
||||
}
|
||||
cannonRoot.shell.DOPath(linePoints, cannonRoot.duration, PathType.CubicBezier, PathMode.Ignore, posCount, Color.red).SetEase(Ease.Linear);
|
||||
cannonRoot.shellSub.DOScale(cannonRoot.shellScaleValue, cannonRoot.duration).SetEase(cannonRoot.shellScaleCurve);
|
||||
await Awaiters.Seconds(cannonRoot.duration * cannonRoot.durationRatio);
|
||||
cannonRoot.virtualCamera1.SetParent(transform);
|
||||
cannonRoot.virtualCamera1.GetComponent<DOTweenAnimation>().DORestart();
|
||||
cannonRoot.shell.gameObject.SetActive(false);
|
||||
bombClip[index].Play();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (disposable != null)
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SmallGame/BombBuilding.cs.meta
Normal file
11
Assets/Scripts/UI/SmallGame/BombBuilding.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa27cf26ddabad44ba2dd73e9db2ccb0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
81
Assets/Scripts/UI/SmallGame/BombHeistTargetItem.cs
Normal file
81
Assets/Scripts/UI/SmallGame/BombHeistTargetItem.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using DG.Tweening;
|
||||
using GameCore;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class BombHeistTargetItem : MonoBehaviour
|
||||
{
|
||||
Button btn;
|
||||
GameObject aim;
|
||||
GameObject aim_disable;
|
||||
RewardItem rewardItem;
|
||||
Animation anim;
|
||||
int index;
|
||||
Action<int> action;
|
||||
bool isSelect = false;
|
||||
private void Awake()
|
||||
{
|
||||
btn = GetComponent<Button>();
|
||||
aim = transform.Find("aim").gameObject;
|
||||
aim_disable = transform.Find("aim_disable").gameObject;
|
||||
rewardItem = transform.Find("reward").GetComponent<RewardItem>();
|
||||
anim = transform.Find("reward").GetComponent<Animation>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn.onClick.AddListener(OnClick);
|
||||
}
|
||||
public void Init(int index, Action<int> action)
|
||||
{
|
||||
this.index = index;
|
||||
this.action = action;
|
||||
aim.SetActive(true);
|
||||
aim_disable.SetActive(false);
|
||||
rewardItem.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void OnSelect(bool value)
|
||||
{
|
||||
btn.onClick.RemoveAllListeners();
|
||||
isSelect = value;
|
||||
aim.SetActive(false);
|
||||
aim_disable.SetActive(false);
|
||||
}
|
||||
//轰炸目标
|
||||
public void MainShowData(ItemData itemData)
|
||||
{
|
||||
rewardItem.gameObject.SetActive(true);
|
||||
rewardItem.SetData(itemData);
|
||||
anim.Play("reward_show1");
|
||||
}
|
||||
//其他目标显示
|
||||
public void ShowData(ItemData itemData)
|
||||
{
|
||||
rewardItem.gameObject.SetActive(true);
|
||||
rewardItem.SetData(itemData);
|
||||
anim.Play("reward_show2");
|
||||
}
|
||||
public void Multiply(ItemData itemData, int multiple)
|
||||
{
|
||||
//翻倍特效
|
||||
anim.Play("reward_beilv");
|
||||
int count = itemData.count;
|
||||
int endCount = count * multiple;
|
||||
DOTween.To(() => count, x => count = x, endCount, 1f).OnUpdate(() =>
|
||||
{
|
||||
rewardItem.text_num.text = ConvertTools.GetNumberString(count, true);
|
||||
})
|
||||
.OnComplete
|
||||
(
|
||||
() =>
|
||||
{
|
||||
rewardItem.text_num.text = ConvertTools.GetNumberString(endCount);
|
||||
}
|
||||
);
|
||||
}
|
||||
void OnClick()
|
||||
{
|
||||
action(index);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SmallGame/BombHeistTargetItem.cs.meta
Normal file
11
Assets/Scripts/UI/SmallGame/BombHeistTargetItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64448bff33e416c47ad2ac9fce8aed91
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
75
Assets/Scripts/UI/SmallGame/CannonRoot.cs
Normal file
75
Assets/Scripts/UI/SmallGame/CannonRoot.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using Cinemachine;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
|
||||
public class CannonRoot : MonoBehaviour
|
||||
{
|
||||
public Transform cannon;
|
||||
public PlayableDirector fire;
|
||||
public TMP_Text text_beilv;
|
||||
public Transform shellStartPos;
|
||||
[Header("点击按钮之后")]
|
||||
[Tooltip("播放开炮动画后炮弹出现时间")]
|
||||
public float shellShowStay = 0.55f;
|
||||
[Header("炮弹出现之后参数")]
|
||||
[Tooltip("炮弹飞行时间")]
|
||||
public float duration = 1.3f;
|
||||
[Tooltip("炮弹消失时间")]
|
||||
[Range(0, 2)]
|
||||
public float durationRatio = 1f;
|
||||
[Header("点击按钮之后相机时间轴")]
|
||||
[Tooltip("相机开始跟随时间")]
|
||||
public float cameraStartStayDuration = 0.8f;
|
||||
[Tooltip("相机飞行时间")]
|
||||
public float cameraDuration = 1.5f;
|
||||
[Tooltip("相机滞留时间")]
|
||||
public float cameraStayDuration = 0.8f;
|
||||
|
||||
public Transform virtualCamera;
|
||||
|
||||
|
||||
[Header("炮弹缩放参数")]
|
||||
public float shellScaleValue = 4.5f;
|
||||
public AnimationCurve shellScaleCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 0.5f), new Keyframe(1, 1));
|
||||
[HideInInspector]
|
||||
public Transform shell;
|
||||
[HideInInspector]
|
||||
public Transform shellSub;
|
||||
[HideInInspector]
|
||||
public Transform virtualCamera1;
|
||||
private void Reset()
|
||||
{
|
||||
cannon = transform.Find("animationcannon/cannon").GetComponent<Transform>();
|
||||
fire = transform.Find("fire").GetComponent<PlayableDirector>();
|
||||
text_beilv = transform.Find("animationcannon/cannon/cannon1/text_beilv").GetComponent<TMP_Text>();
|
||||
shellStartPos = transform.Find("animationcannon/cannon/cannon1/shellstartpos").GetComponent<Transform>();
|
||||
virtualCamera = transform.Find("cannoncamera").GetComponent<Transform>();
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
Transform cannonObj = transform.parent.Find("shell");
|
||||
if (cannonObj == null)
|
||||
{
|
||||
Debug.LogError("这是一个放在错误位置的轰炸相机和配置节点,干掉他");
|
||||
return;
|
||||
}
|
||||
shell = transform.parent.Find("shell").GetComponent<Transform>();
|
||||
shellSub = shell.Find("shell");
|
||||
virtualCamera1 = shell.Find("cannoncamera1").GetComponent<Transform>();
|
||||
}
|
||||
|
||||
public async void MoveCamera()
|
||||
{
|
||||
await Awaiters.Seconds(cameraStartStayDuration);
|
||||
virtualCamera1.position = virtualCamera.position;
|
||||
virtualCamera1.rotation = virtualCamera.rotation;
|
||||
virtualCamera1.gameObject.SetActive(true);
|
||||
virtualCamera1.SetParent(shell);
|
||||
await Awaiters.Seconds(cameraDuration);
|
||||
virtualCamera1.GetComponent<CinemachineVirtualCamera>().Follow = null;
|
||||
virtualCamera1.SetParent(transform.parent);
|
||||
await Awaiters.Seconds(cameraStayDuration);
|
||||
virtualCamera1.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SmallGame/CannonRoot.cs.meta
Normal file
11
Assets/Scripts/UI/SmallGame/CannonRoot.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32fe1ef35e8c48349972140037997d36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
187
Assets/Scripts/UI/SmallGame/EventBankHeistOpponentPopupPanel.cs
Normal file
187
Assets/Scripts/UI/SmallGame/EventBankHeistOpponentPopupPanel.cs
Normal file
@@ -0,0 +1,187 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EventBankHeistOpponentPopupPanel : MonoBehaviour
|
||||
{
|
||||
Button mask;
|
||||
Button btn_close;
|
||||
Toggle tab1;
|
||||
Toggle tab2;
|
||||
GameObject selected_tab1;
|
||||
GameObject selected_tab2;
|
||||
OpponentItem itemRandom;
|
||||
GameObject btn_gray;
|
||||
|
||||
GameObject item1;
|
||||
Transform content;
|
||||
List<OpponentItem> items;
|
||||
List<OpponentItemData> opponentFriend;
|
||||
List<OpponentItemData> opponentEnemy;
|
||||
int changeCount = 0;
|
||||
SmallGameData smallGameData;
|
||||
private void Awake()
|
||||
{
|
||||
smallGameData = GContext.container.Resolve<SmallGameData>();
|
||||
mask = transform.Find("mask").GetComponent<Button>();
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
tab1 = transform.Find("root/tab/text_tab1").GetComponent<Toggle>();
|
||||
tab2 = transform.Find("root/tab/text_tab2").GetComponent<Toggle>();
|
||||
selected_tab1 = transform.Find("root/tab/selected_tab1").gameObject;
|
||||
selected_tab2 = transform.Find("root/tab/selected_tab2").gameObject;
|
||||
|
||||
itemRandom = transform.Find("root/ScrollView/Viewport/Content/Item").GetComponent<OpponentItem>();
|
||||
btn_gray = transform.Find("root/ScrollView/Viewport/Content/Item/btn_gray").gameObject;
|
||||
content = transform.Find("root/ScrollView/Viewport/Content");
|
||||
item1 = transform.Find("root/ScrollView/Viewport/Content/Item1").gameObject;
|
||||
item1.SetActive(false);
|
||||
items = new List<OpponentItem>();
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
//smallGameData.LoadData();
|
||||
opponentFriend = smallGameData.opponentFriend;
|
||||
opponentEnemy = smallGameData.GetOpponentEnemy();
|
||||
SelectRandom();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
mask.onClick.AddListener(Close);
|
||||
btn_close.onClick.AddListener(Close);
|
||||
itemRandom.action = RandomPlayer;
|
||||
SetRandomText();
|
||||
tab1.onValueChanged.AddListener((bool isOn) =>
|
||||
{
|
||||
if (isOn)
|
||||
{
|
||||
SelectRandom();
|
||||
}
|
||||
});
|
||||
tab2.onValueChanged.AddListener((bool isOn) =>
|
||||
{
|
||||
if (isOn)
|
||||
{
|
||||
SelectFriend();
|
||||
}
|
||||
});
|
||||
//for (int i = 0; i < itemDatas.Count; i++)
|
||||
//{
|
||||
// GameObject go = Instantiate(item1, content);
|
||||
// go.SetActive(true);
|
||||
// OpponentItem item = go.GetComponent<OpponentItem>();
|
||||
// item.action = SelectPlayer;
|
||||
// items.Add(item);
|
||||
// item.SetData(itemDatas[i]);
|
||||
//}
|
||||
}
|
||||
void SelectRandom()
|
||||
{
|
||||
selected_tab1.SetActive(true);
|
||||
selected_tab2.SetActive(false);
|
||||
int count = items.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
items[i].gameObject.SetActive(false);
|
||||
}
|
||||
itemRandom.gameObject.SetActive(true);
|
||||
if (opponentEnemy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GameObject go;
|
||||
OpponentItem item;
|
||||
for (int i = 0; i < opponentEnemy.Count; i++)
|
||||
{
|
||||
if (i < count)
|
||||
{
|
||||
item = items[i];
|
||||
go = items[i].gameObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
go = Instantiate(item1, content);
|
||||
item = go.GetComponent<OpponentItem>();
|
||||
items.Add(item);
|
||||
item.action = SelectPlayer;
|
||||
}
|
||||
go.SetActive(true);
|
||||
item.SetData(opponentEnemy[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void SelectFriend()
|
||||
{
|
||||
selected_tab1.SetActive(false);
|
||||
selected_tab2.SetActive(true);
|
||||
int count = items.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
items[i].gameObject.SetActive(false);
|
||||
}
|
||||
itemRandom.gameObject.SetActive(false);
|
||||
GameObject go;
|
||||
OpponentItem item;
|
||||
for (int i = 0; i < opponentFriend.Count; i++)
|
||||
{
|
||||
if (i < count)
|
||||
{
|
||||
item = items[i];
|
||||
go = items[i].gameObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
go = Instantiate(item1, content);
|
||||
item = go.GetComponent<OpponentItem>();
|
||||
items.Add(item);
|
||||
item.action = SelectPlayer;
|
||||
}
|
||||
go.SetActive(true);
|
||||
item.SetData(opponentFriend[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void SetRandomText()
|
||||
{
|
||||
int count = GContext.container.Resolve<Tables>().TbAquariumConfig.RaidChangeTimes;
|
||||
itemRandom.SetTextInfo(LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_1", count - changeCount, count));
|
||||
}
|
||||
|
||||
//随机玩家
|
||||
void RandomPlayer(OpponentItemData opponentItemData, bool random)
|
||||
{
|
||||
opponentItemData = smallGameData.RandomItem();
|
||||
if (GContext.container.Resolve<SmallGameData>().opponentData.playFabID == opponentItemData.playFabID)
|
||||
{
|
||||
opponentItemData = smallGameData.RandomItem();
|
||||
}
|
||||
changeCount++;
|
||||
SetRandomText();
|
||||
if (changeCount >= GContext.container.Resolve<Tables>().TbAquariumConfig.RaidChangeTimes)
|
||||
{
|
||||
itemRandom.SetGray();
|
||||
btn_gray.SetActive(true);
|
||||
}
|
||||
SelectPlayer(opponentItemData, true);
|
||||
}
|
||||
//选中一位玩家
|
||||
void SelectPlayer(OpponentItemData opponentItemData, bool random = false)
|
||||
{
|
||||
if (GContext.container.Resolve<SmallGameData>().opponentData.playFabID != opponentItemData.playFabID)
|
||||
{
|
||||
GContext.container.Resolve<SmallGameData>().opponentData = opponentItemData;
|
||||
ChangeSmallGameTargetEvent changeSmallGameTargetEvent = new ChangeSmallGameTargetEvent();
|
||||
changeSmallGameTargetEvent.opponentItemData = opponentItemData;
|
||||
changeSmallGameTargetEvent.random = random;
|
||||
changeSmallGameTargetEvent.ts = new System.Threading.Tasks.TaskCompletionSource<bool>();
|
||||
GContext.Publish(changeSmallGameTargetEvent);
|
||||
}
|
||||
Close();
|
||||
}
|
||||
void Close()
|
||||
{
|
||||
UIManager.Instance.HideUI(UITypes.EventBankHeistOpponentPopupPanel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb26815acf485e045a3514764ce8594c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
648
Assets/Scripts/UI/SmallGame/EventBankHeistPanel.cs
Normal file
648
Assets/Scripts/UI/SmallGame/EventBankHeistPanel.cs
Normal file
@@ -0,0 +1,648 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using GameCore;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniRx;
|
||||
using game;
|
||||
using Game;
|
||||
|
||||
public class EventBankHeistPanel : BasePanel
|
||||
{
|
||||
Tables _tables;
|
||||
FishingEventData _fishingEventData;
|
||||
SmallGameData smallGameData;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
static public int selectionType = 0;
|
||||
#endif
|
||||
GameObject bg;
|
||||
GameObject bg1;
|
||||
GameObject bg2;
|
||||
Head head;
|
||||
Button headButton;
|
||||
GameObject exchange;
|
||||
|
||||
public TMP_Text text_name;
|
||||
public Button btn_close;
|
||||
public Transform beilvpanel_max;
|
||||
public Transform bg_beilvlpanel;
|
||||
GameObject beilvpanel;
|
||||
public TMP_Text text_beilv;
|
||||
public TMP_Text text_beilv1;
|
||||
public TMP_Text text_num;
|
||||
public TMP_Text text_num1;
|
||||
public GameObject luckytime_1;
|
||||
public GameObject luckytime_2;
|
||||
CanvasGroup canvasGroup;
|
||||
HeistSequence heistSequence;
|
||||
Dictionary<int, HeistItem> heistItemDataMap;
|
||||
BankHeistItem[] bankHeistItems;
|
||||
List<BankHeistTargetItem> bankHeistTargetItems;
|
||||
List<BankHeistItem> bombBankHeistItems;
|
||||
List<int> ItemIDList;
|
||||
int curShowCount;
|
||||
bool isClick = false;
|
||||
int multiple;
|
||||
int getGlodCount = 0;
|
||||
bool is_double_cash = false;
|
||||
float allExtraPoint = 0;
|
||||
int gameType = 1;
|
||||
List<int> ids;
|
||||
Animation panel_card_ani;
|
||||
Animation target_ani;
|
||||
GameObject Root;
|
||||
//int curRankCount;
|
||||
int addRankCount;
|
||||
string playFabId;
|
||||
|
||||
float superCashBonus = 0;
|
||||
private void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
heistItemDataMap = _tables.TbHeistItem.DataMap;
|
||||
_fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
smallGameData = GContext.container.Resolve<SmallGameData>();
|
||||
|
||||
Root = transform.Find("root").gameObject;
|
||||
bg = transform.Find("bg").gameObject;
|
||||
bg1 = transform.Find("bg1").gameObject;
|
||||
bg2 = transform.Find("bg2").gameObject;
|
||||
canvasGroup = transform.GetComponent<CanvasGroup>();
|
||||
text_name = transform.Find("root/title/bg/text_name").GetComponent<TMP_Text>();
|
||||
btn_close = transform.Find("root/btn_close/bg_bottom").GetComponent<Button>();
|
||||
head = transform.Find("root/title/btn_head").GetComponent<Head>();
|
||||
headButton = transform.Find("root/title/btn_head").GetComponent<Button>();
|
||||
exchange = transform.Find("root/title/btn_head/exchange").gameObject;
|
||||
beilvpanel = transform.Find("root/panel_card/text_title/beilvpanel").gameObject;
|
||||
beilvpanel_max = transform.Find("root/panel_card/text_title/beilvpanel/bg_beilv_max");
|
||||
bg_beilvlpanel = transform.Find("root/panel_card/text_title/beilvpanel/bg_beilv");
|
||||
text_beilv = transform.Find("root/panel_card/text_title/beilvpanel/bg_beilv_max/text_beilv").GetComponent<TMP_Text>();
|
||||
text_beilv1 = transform.Find("root/panel_card/text_title/beilvpanel/bg_beilv/text_beilv").GetComponent<TMP_Text>();
|
||||
bankHeistItems = transform.Find("root/panel_card/ScrollView/Viewport/Content").GetComponentsInChildren<BankHeistItem>();
|
||||
luckytime_1 = transform.Find("root/luckytime_1").gameObject;
|
||||
luckytime_2 = transform.Find("root/luckytime_2").gameObject;
|
||||
//bankHeistTargetItems = transform.Find("root/panel_card/target").GetComponentsInChildren<BankHeistTargetItem>();
|
||||
bankHeistTargetItems = new List<BankHeistTargetItem>();
|
||||
bombBankHeistItems = new List<BankHeistItem>();
|
||||
Transform targets = transform.Find("root/panel_card/target");
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
bankHeistTargetItems.Add(targets.Find($"target{i}").GetComponent<BankHeistTargetItem>());
|
||||
}
|
||||
text_num = transform.Find("root/panel_card/target/target1/text_num").GetComponent<TMP_Text>();
|
||||
text_num1 = transform.Find("root/panel_card/target/target0/text_num").GetComponent<TMP_Text>();
|
||||
|
||||
panel_card_ani = transform.Find("root/panel_card").GetComponent<Animation>();
|
||||
target_ani = transform.Find("root/panel_card/target").GetComponent<Animation>();
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
luckytime_1.SetActive(false);
|
||||
luckytime_2.SetActive(false);
|
||||
for (int i = 1; i < bankHeistTargetItems.Count; i++)
|
||||
{
|
||||
bankHeistTargetItems[bankHeistTargetItems.Count - i].SetIcon(heistItemDataMap[i].Icon);
|
||||
}
|
||||
GContext.OnEvent<ChangeSmallGameTargetEvent>().Subscribe(ChangeSmallGameTarget).AddTo(disposables);
|
||||
playFabId = smallGameData.opponentData.playFabID;
|
||||
GContext.OnEvent<GetClubPlayInfoEvent>().Where(x => x.id == playFabId).Subscribe(SetAvatar).AddTo(disposables);
|
||||
IUserService userService = GContext.container.Resolve<IUserService>();
|
||||
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
|
||||
SetAvatar(clubPlayInfo);
|
||||
//text_name.text = LocalizationMgr.GetFormatTextValue("UI_EventIslandBombHeistPanel_1", smallGameData.opponentData.playName);
|
||||
//head.SetData(smallGameData.opponentData.url);
|
||||
btn_close.onClick.AddListener(() =>
|
||||
{
|
||||
GContext.Publish(new UnloadActToNextAct());
|
||||
});
|
||||
|
||||
//不支持切换、
|
||||
headButton.enabled = false;
|
||||
exchange.SetActive(false);
|
||||
headButton.onClick.AddListener(OnClickHead);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (selectionType != 0)
|
||||
{
|
||||
SetGamePlayGM();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetGamePlay();
|
||||
}
|
||||
#else
|
||||
SetGamePlay();
|
||||
#endif
|
||||
SetHeistItem();
|
||||
StartPlayNumAni();
|
||||
bg.SetActive(gameType == 1);
|
||||
bg1.SetActive(gameType == 2);
|
||||
bg2.SetActive(gameType == 3);
|
||||
}
|
||||
async void StartPlayNumAni()
|
||||
{
|
||||
canvasGroup.interactable = false;
|
||||
Root.SetActive(false);
|
||||
await Awaiters.Seconds(0.5f);
|
||||
Root.SetActive(true);
|
||||
_ = StartCoroutine(PlayNumAni());
|
||||
}
|
||||
|
||||
bool isShowing = false;
|
||||
async void OnClickHead()
|
||||
{
|
||||
if (isClick)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_20"));
|
||||
}
|
||||
else if (!isShowing)
|
||||
{
|
||||
isShowing = true;
|
||||
//选择对象
|
||||
await UIManager.Instance.ShowUI(UITypes.EventBankHeistOpponentPopupPanel);
|
||||
isShowing = false;
|
||||
}
|
||||
|
||||
}
|
||||
void ChangeSmallGameTarget(ChangeSmallGameTargetEvent data)
|
||||
{
|
||||
playFabId = data.opponentItemData.playFabID;
|
||||
//text_name.text = LocalizationMgr.GetFormatTextValue("UI_EventBankHeistPanel_1", data.opponentItemData.playName);
|
||||
//head.SetData(data.opponentItemData.url);
|
||||
StartCoroutine(PlayNumAni());
|
||||
IUserService userService = GContext.container.Resolve<IUserService>();
|
||||
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
|
||||
SetAvatar(clubPlayInfo);
|
||||
}
|
||||
|
||||
public void SetAvatar(PlayInfo clubPlayInfo)
|
||||
{
|
||||
if (clubPlayInfo != null)
|
||||
{
|
||||
text_name.text = LocalizationMgr.GetFormatTextValue("UI_EventBankHeistPanel_1", clubPlayInfo.name);
|
||||
head.SetData(clubPlayInfo.avatarUrl);
|
||||
}
|
||||
}
|
||||
void SetAvatar(GetClubPlayInfoEvent getClubPlayInfoEvent)
|
||||
{
|
||||
if (getClubPlayInfoEvent.id == playFabId)
|
||||
{
|
||||
text_name.text = LocalizationMgr.GetFormatTextValue("UI_EventBankHeistPanel_1", getClubPlayInfoEvent.name);
|
||||
head.SetData(getClubPlayInfoEvent.avatarUrl);
|
||||
}
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
void SetGamePlayGM()
|
||||
{
|
||||
List<HeistGamePlay> gamePlays = _tables.TbHeistGamePlay.DataList.FindAll((HeistGamePlay heistGamePlay) =>
|
||||
{
|
||||
return heistGamePlay.Type == selectionType;
|
||||
});
|
||||
int weight = 0;
|
||||
for (int i = 0; i < gamePlays.Count; i++)
|
||||
{
|
||||
weight += gamePlays[i].Weight;
|
||||
}
|
||||
int random = Random.Range(0, weight);
|
||||
int curWeight = 0;
|
||||
for (int i = 0; i < gamePlays.Count; i++)
|
||||
{
|
||||
curWeight += gamePlays[i].Weight;
|
||||
if (random < curWeight)
|
||||
{
|
||||
gameType = gamePlays[i].Type;
|
||||
ids = gamePlays[i].Sequence;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
void SetGamePlay()
|
||||
{
|
||||
List<HeistInit> heistInits = _tables.TbHeistInit.DataList;
|
||||
if (GContext.container.Resolve<IStageData>().IsRewardSettlement && GContext.container.Resolve<SmallGameData>().HeistGameCount < heistInits.Count)
|
||||
{
|
||||
gameType = heistInits[GContext.container.Resolve<SmallGameData>().HeistGameCount].Type;
|
||||
ids = heistInits[GContext.container.Resolve<SmallGameData>().HeistGameCount].Sequence;
|
||||
}
|
||||
else
|
||||
{
|
||||
List<HeistGamePlay> gamePlays = _tables.TbHeistGamePlay.DataList;
|
||||
int weight = 0;
|
||||
for (int i = 0; i < gamePlays.Count; i++)
|
||||
{
|
||||
weight += gamePlays[i].Weight;
|
||||
}
|
||||
int random = Random.Range(0, weight);
|
||||
int curWeight = 0;
|
||||
for (int i = 0; i < gamePlays.Count; i++)
|
||||
{
|
||||
curWeight += gamePlays[i].Weight;
|
||||
if (random < curWeight)
|
||||
{
|
||||
gameType = gamePlays[i].Type;
|
||||
ids = gamePlays[i].Sequence;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetHeistItem()
|
||||
{
|
||||
//按权重随机heistSequence
|
||||
List<HeistSequence> heistSequences = new List<HeistSequence>();
|
||||
for (int i = 0; i < ids.Count; i++)
|
||||
{
|
||||
int id = ids[i];
|
||||
HeistSequence heistSequence = _tables.TbHeistSequence.GetOrDefault(id);
|
||||
#if UNITY_EDITOR
|
||||
if (selectionType == 2 && heistSequence.FinalReward != 201)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
heistSequences.Add(heistSequence);
|
||||
}
|
||||
heistSequence = heistSequences[0];
|
||||
int weight = 0;
|
||||
for (int i = 0; i < heistSequences.Count; i++)
|
||||
{
|
||||
weight += heistSequences[i].Weight;
|
||||
}
|
||||
int random = Random.Range(0, weight);
|
||||
int curWeight = 0;
|
||||
for (int i = 0; i < heistSequences.Count; i++)
|
||||
{
|
||||
curWeight += heistSequences[i].Weight;
|
||||
if (random < curWeight)
|
||||
{
|
||||
heistSequence = heistSequences[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("specialevent_bankheist"))
|
||||
{
|
||||
e.AddContent("heist_sequence_id", heistSequence.ID);
|
||||
}
|
||||
#endif
|
||||
InitItenIDList();
|
||||
for (int i = 0; i < bankHeistItems.Length; i++)
|
||||
{
|
||||
if (i < ItemIDList.Count)
|
||||
{
|
||||
bankHeistItems[i].action = OnClickItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
bankHeistItems[i].gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
void InitItenIDList()
|
||||
{
|
||||
ItemIDList = new List<int>(heistSequence.ItemList);
|
||||
int id;
|
||||
Dictionary<int, int> idCountMap = new Dictionary<int, int>();
|
||||
for (int i = 0; i < ItemIDList.Count; i++)
|
||||
{
|
||||
idCountMap[ItemIDList[i]] = 0;
|
||||
}
|
||||
List<int> idList = new List<int>();
|
||||
//if (gameType == 1)
|
||||
//{
|
||||
//额外道具
|
||||
for (int i = 0; i < heistSequence.SpecialItemCount; i++)
|
||||
{
|
||||
id = ItemIDList[ItemIDList.Count - 1];
|
||||
idList.Add(id);
|
||||
ItemIDList.Remove(id);
|
||||
}
|
||||
//}
|
||||
|
||||
int random;
|
||||
//目标道具
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
random = Random.Range(0, idList.Count);
|
||||
idList.Insert(random, heistSequence.FinalReward);
|
||||
ItemIDList.Remove(heistSequence.FinalReward);
|
||||
}
|
||||
idCountMap[heistSequence.FinalReward] = 2;
|
||||
int insertCount = 0;
|
||||
for (int i = heistSequence.SpecialItemCount + 3; i < heistSequence.DrawCount; i++)
|
||||
{
|
||||
id = ItemIDList[insertCount];
|
||||
if (idCountMap[id] < 2)
|
||||
{
|
||||
idCountMap[id]++;
|
||||
random = Random.Range(0, idList.Count);
|
||||
idList.Insert(random, id);
|
||||
ItemIDList.Remove(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
insertCount++;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
idList.Add(heistSequence.FinalReward);
|
||||
ItemIDList.Remove(heistSequence.FinalReward);
|
||||
for (int i = heistSequence.DrawCount; i < heistSequence.ItemList.Count; i++)
|
||||
{
|
||||
if (ItemIDList.Count == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
id = ItemIDList[0];
|
||||
random = Random.Range(heistSequence.DrawCount, idList.Count);
|
||||
idList.Insert(random, id);
|
||||
ItemIDList.Remove(id);
|
||||
}
|
||||
ItemIDList = idList;
|
||||
}
|
||||
IEnumerator PlayNumAni()
|
||||
{
|
||||
canvasGroup.interactable = false;
|
||||
ItemData itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(heistItemDataMap[3].RewardID);
|
||||
int curNum = (int)(itemData.count * smallGameData.opponentData.power * (1 + superCashBonus));
|
||||
curNum = Mathf.RoundToInt(curNum * (1 + allExtraPoint));
|
||||
|
||||
curNum = is_double_cash ? curNum + curNum : curNum;
|
||||
|
||||
text_num.text = ConvertTools.GetNumberString2(curNum);
|
||||
|
||||
if (gameType == 3)
|
||||
{
|
||||
//金砖事件
|
||||
itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(heistItemDataMap[4].RewardID);
|
||||
int curNum1 = (int)(itemData.count * smallGameData.opponentData.power * (1 + superCashBonus));
|
||||
curNum1 = Mathf.RoundToInt(curNum1 * (1 + allExtraPoint));
|
||||
curNum1 = is_double_cash ? curNum1 + curNum1 : curNum1;
|
||||
luckytime_1.SetActive(true);
|
||||
//GContext.Publish(new VibrationData(HapticTypes.Warning));
|
||||
float timerAni = luckytime_1.GetComponent<Animation>().GetClip("EventBankHeistPanel_luckytime1").length;
|
||||
text_num1.text = ConvertTools.GetNumberString2(curNum1);
|
||||
yield return new WaitForSeconds(timerAni);
|
||||
luckytime_1.SetActive(false);
|
||||
target_ani.Play();// ("EventBankHeistPanel_luckytime1_target");
|
||||
timerAni = target_ani.GetClip("EventBankHeistPanel_luckytime1_target").length;
|
||||
yield return new WaitForSeconds(timerAni);
|
||||
panel_card_ani.Play("EventBankHeistPanel_luckytimeopen");
|
||||
timerAni = panel_card_ani.GetClip("EventBankHeistPanel_luckytimeopen").length;
|
||||
int curNum2 = curNum1 * multiple;
|
||||
yield return new WaitForSeconds(timerAni - 0.2f);
|
||||
if (multiple > 1)
|
||||
{
|
||||
DOTween.To(() => curNum1, x => curNum1 = x, curNum2, 1f).OnUpdate(() =>
|
||||
{
|
||||
text_num1.text = ConvertTools.GetNumberString2(curNum1);
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (gameType == 2)
|
||||
{
|
||||
//炸弹事件
|
||||
luckytime_2.SetActive(true);
|
||||
//GContext.Publish(new VibrationData(HapticTypes.Warning));
|
||||
float timerAni = luckytime_2.GetComponent<Animation>().GetClip("EventBankHeistPanel_luckytime2").length;
|
||||
yield return new WaitForSeconds(timerAni);
|
||||
luckytime_2.SetActive(false);
|
||||
panel_card_ani.Play("EventBankHeistPanel_commonopen");
|
||||
timerAni = panel_card_ani.GetClip("EventBankHeistPanel_commonopen").length;
|
||||
yield return new WaitForSeconds(timerAni - 0.2f);
|
||||
}
|
||||
else if (gameType == 1)
|
||||
{
|
||||
panel_card_ani.Play("EventBankHeistPanel_commonopen");
|
||||
float timerAni = panel_card_ani.GetClip("EventBankHeistPanel_commonopen").length;
|
||||
yield return new WaitForSeconds(timerAni - 0.2f);
|
||||
}
|
||||
if (multiple > 1)
|
||||
{
|
||||
int lastNum = curNum * multiple;
|
||||
DOTween.To(() => curNum, x => curNum = x, lastNum, 1f).OnUpdate(() =>
|
||||
{
|
||||
text_num.text = ConvertTools.GetNumberString2(curNum);
|
||||
});
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
canvasGroup.interactable = true;
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
SuperRob superRob = GContext.container.Resolve<BuffDataCenter>().GetWeelyBuffTimeData<SuperRob>();
|
||||
if (superRob != null)
|
||||
{
|
||||
superCashBonus = superRob.CashBonus;
|
||||
}
|
||||
//bool isRankInit = _fishingEventData.rankInit != null;
|
||||
//if (isRankInit)
|
||||
//{
|
||||
// curRankCount = (int)GContext.container.Resolve<PlayerItemData>().GetItemCount(_fishingEventData.rankInit.TokenID);
|
||||
//}
|
||||
multiple = GContext.container.Resolve<PlayerData>().GetMagnification();
|
||||
beilvpanel.SetActive(multiple > 1);
|
||||
if (multiple <= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool isMax = GContext.container.Resolve<PlayerData>().IsMaxMagnification();
|
||||
beilvpanel_max.gameObject.SetActive(isMax);
|
||||
bg_beilvlpanel.gameObject.SetActive(!isMax);
|
||||
text_beilv.text = $"x{multiple}";
|
||||
text_beilv1.text = $"x{multiple}";
|
||||
}
|
||||
void OnClickItem(BankHeistItem heistItemB)
|
||||
{
|
||||
GContext.Publish(new VibrationData(HapticTypes.Selection));
|
||||
int heistID = ItemIDList[curShowCount];
|
||||
curShowCount++;
|
||||
HeistItem heistItem = heistItemDataMap[heistID];
|
||||
heistItemB.SetData(heistItem, multiple);
|
||||
isClick = true;
|
||||
exchange.SetActive(false);
|
||||
switch (heistItem.Type)
|
||||
{
|
||||
case 0:
|
||||
OnClick00(heistItemB);
|
||||
break;
|
||||
case 1:
|
||||
GContext.Publish(new EventUISound("audio_ui_bankheist_open_high"));
|
||||
OnClick01(heistItemB);
|
||||
break;
|
||||
case 2:
|
||||
GContext.Publish(new EventUISound("audio_ui_bankheist_open_high"));
|
||||
OnClick02(heistItemB);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 翻开普通道具
|
||||
/// </summary>
|
||||
/// <param name="heistItem"></param>
|
||||
void OnClick00(BankHeistItem bankHeistItem)
|
||||
{
|
||||
HeistItem heistItem = bankHeistItem.heistItem;
|
||||
if (gameType == 3 && heistItem.ID == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (heistItem.ID == 1)
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_bankheist_open_low"));
|
||||
}
|
||||
else if (heistItem.ID == 2)
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_bankheist_open_mid"));
|
||||
}
|
||||
else
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_bankheist_open_high"));
|
||||
}
|
||||
|
||||
|
||||
BankHeistTargetItem bankHeistTargetItem = bankHeistTargetItems[^heistItem.ID];
|
||||
bankHeistTargetItem.OnAddItem(bankHeistItem);
|
||||
if (bankHeistTargetItem.itemCount >= 3)
|
||||
{
|
||||
canvasGroup.interactable = false;
|
||||
bankHeistTargetItem.Success();
|
||||
|
||||
if (_fishingEventData.rankInit != null)
|
||||
{
|
||||
int point = _fishingEventData.rankInit.PointRobbery[heistItem.ID - 1] * multiple;
|
||||
point = Mathf.RoundToInt(point);
|
||||
addRankCount += point;
|
||||
_fishingEventData.AddRankTarget(point);
|
||||
}
|
||||
ItemData itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(heistItem.RewardID);
|
||||
int curNum = (int)(itemData.count * smallGameData.opponentData.power * (1 + superCashBonus));
|
||||
curNum = Mathf.RoundToInt(curNum * (1 + allExtraPoint));
|
||||
curNum = is_double_cash ? curNum + curNum : curNum;
|
||||
|
||||
AddGload(curNum, itemData.count);
|
||||
Settlement();
|
||||
}
|
||||
//else
|
||||
//{
|
||||
bankHeistItem.PlayAni();
|
||||
//}
|
||||
}
|
||||
void AddGload(int curNum, float baseNum)
|
||||
{
|
||||
baseNum /= GContext.container.Resolve<PlayerItemData>().ExtraCoinMag();
|
||||
GContext.Publish(new ConditionTypeEvent(ConditionType.MaxCashFromHeist, curNum));
|
||||
getGlodCount = curNum * multiple;
|
||||
GContext.container.Resolve<PlayerItemData>().AddItemCount(1002, getGlodCount);
|
||||
long Heist = (int)baseNum * multiple * 100 + Random.Range(5, 16);
|
||||
smallGameData.SetEnemy(EnemyType.Heist, Heist);
|
||||
GContext.Publish(new ConditionTypeEvent(ConditionType.CashFromHeist, getGlodCount));
|
||||
|
||||
GContext.container.Resolve<SmallGameData>().SaveHeistGameCount();
|
||||
GContext.Publish(new ConditionTypeEvent(ConditionType.DoHeist, 1));
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("special_event"))
|
||||
{
|
||||
e.AddContent("item_id", 1002)
|
||||
.AddContent("special_event_multiple", multiple)
|
||||
.AddContent("finish_times", GContext.container.Resolve<SmallGameData>().HeistGameCount)
|
||||
.AddContent("reward_cash", getGlodCount)
|
||||
.AddContent("event_type", 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
async void Settlement()
|
||||
{
|
||||
GContext.Publish(new VibrationData(HapticTypes.MediumImpact));
|
||||
UIManager.Instance.DestroyUI(UITypes.EventBankHeistOpponentPopupPanel);
|
||||
await Awaiters.Seconds(1f);
|
||||
//yield return new WaitForSeconds(2f);
|
||||
//Todo
|
||||
var go = await UIManager.Instance.GetUIAsync(UITypes.EventBankHeistRewardPanel);
|
||||
EventBankHeistRewardPanel eventBankHeistRewardPanel = go.GetComponent<EventBankHeistRewardPanel>();
|
||||
eventBankHeistRewardPanel.SetData(getGlodCount, superCashBonus, addRankCount);
|
||||
}
|
||||
/// <summary>
|
||||
/// 翻开特殊奖励
|
||||
/// </summary>
|
||||
/// <param name="bankHeistItem"></param>
|
||||
void OnClick01(BankHeistItem bankHeistItem)
|
||||
{
|
||||
HeistItem heistItem = bankHeistItem.heistItem;
|
||||
bankHeistItem.OnGetAdditional();
|
||||
ItemData itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(heistItem.RewardID);
|
||||
//if (itemData.id == 1001)
|
||||
//{
|
||||
// itemData.count *= (1 + GContext.container.Resolve<PlayerData>().curVipData.ShopEnergy);
|
||||
//}
|
||||
GContext.container.Resolve<PlayerItemData>().AddItemCount(itemData.id, itemData.count * multiple);
|
||||
}
|
||||
//翻开炸弹
|
||||
void OnClick02(BankHeistItem bankHeistItem)
|
||||
{
|
||||
bombBankHeistItems.Add(bankHeistItem);
|
||||
bankHeistItem.PlayAni();
|
||||
if (bombBankHeistItems.Count >= 3)
|
||||
{
|
||||
canvasGroup.interactable = false;
|
||||
//Todo
|
||||
//一系列效果
|
||||
for (int i = 0; i < bankHeistItems.Length; i++)
|
||||
{
|
||||
if (bankHeistItems[i].isMaster)
|
||||
{
|
||||
int heistID = ItemIDList[curShowCount];
|
||||
curShowCount++;
|
||||
HeistItem heistItem = heistItemDataMap[heistID];
|
||||
bankHeistItems[i].SetData(heistItem, multiple);
|
||||
}
|
||||
}
|
||||
ItemData itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(heistItemDataMap[3].RewardID);
|
||||
bool isRankInit = _fishingEventData.rankInit != null;
|
||||
if (isRankInit)
|
||||
{
|
||||
int point = _fishingEventData.rankInit.PointRobbery[3] * multiple;
|
||||
point = Mathf.RoundToInt(point);
|
||||
addRankCount += point;
|
||||
_fishingEventData.AddRankTarget(point);
|
||||
}
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
ItemData subItemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(heistItemDataMap[i].RewardID);
|
||||
itemData.count += subItemData.count;
|
||||
}
|
||||
int curNum = (int)(itemData.count * smallGameData.opponentData.power * (1 + superCashBonus));
|
||||
curNum = Mathf.RoundToInt(curNum * (1 + allExtraPoint));
|
||||
curNum = is_double_cash ? curNum + curNum : curNum;
|
||||
AddGload(curNum, itemData.count);
|
||||
//结算
|
||||
ShowAll();
|
||||
}
|
||||
}
|
||||
|
||||
async void ShowAll()
|
||||
{
|
||||
int index;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
index = i * 4;
|
||||
bankHeistItems[index].OnSuccess();
|
||||
bankHeistItems[index + 1].OnSuccess();
|
||||
bankHeistItems[index + 2].OnSuccess();
|
||||
bankHeistItems[index + 3].OnSuccess();
|
||||
bankHeistTargetItems[i + 1].OnAllShow();
|
||||
await Awaiters.Seconds(1f);
|
||||
}
|
||||
Settlement();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SmallGame/EventBankHeistPanel.cs.meta
Normal file
11
Assets/Scripts/UI/SmallGame/EventBankHeistPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02e13b6921469ca488f4baf43d0bb94b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
99
Assets/Scripts/UI/SmallGame/EventBankHeistRewardPanel.cs
Normal file
99
Assets/Scripts/UI/SmallGame/EventBankHeistRewardPanel.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
using game;
|
||||
using GameCore;
|
||||
using Spine;
|
||||
using Spine.Unity;
|
||||
using System.Collections;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EventBankHeistRewardPanel : MonoBehaviour
|
||||
{
|
||||
public float PlaySpineDelay = 0.5f;
|
||||
TMP_Text text_num;
|
||||
TMP_Text text_num_buff;
|
||||
Button btn_close;
|
||||
GameObject fx_ui_blingbling_01;
|
||||
RewardItemNew reward_extra;
|
||||
GameObject bg_extra;
|
||||
SkeletonGraphic skeletonGraphic;
|
||||
int add = 0;
|
||||
private void Awake()
|
||||
{
|
||||
text_num = transform.Find("root/reward/text_num").GetComponent<TMP_Text>();
|
||||
text_num_buff = transform.Find("root/reward/text_num/text_num_buff").GetComponent<TMP_Text>();
|
||||
btn_close = transform.Find("root/reward/btn_play/btn_green").GetComponent<Button>();
|
||||
bg_extra = transform.Find("root/reward/bonus").gameObject;
|
||||
reward_extra = transform.Find("root/reward/bonus/reward").GetComponent<RewardItemNew>();
|
||||
skeletonGraphic = transform.Find("root/spine").GetComponent<SkeletonGraphic>();
|
||||
fx_ui_blingbling_01 = transform.Find("root/reward/fx_ui_blingbling_01").gameObject;
|
||||
fx_ui_blingbling_01.gameObject.SetActive(false);
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("EventBankHeistRewardPanel");
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
skeletonGraphic.AnimationState.Complete += HandleAnimationComplete;
|
||||
}
|
||||
void HandleAnimationComplete(TrackEntry trackEntry)
|
||||
{
|
||||
skeletonGraphic.AnimationState.SetAnimation(0, "Idle01", true);
|
||||
}
|
||||
public void SetData(int glod, float superCashBonus, int addRankCount)
|
||||
{
|
||||
//superCashBonus = 0.5f;
|
||||
FishingEventData _fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
bool isRankInit = _fishingEventData.rankInit != null;
|
||||
if (isRankInit && addRankCount > 0)
|
||||
{
|
||||
reward_extra.SetData(new ItemData() { id = _fishingEventData.rankInit.TokenID, count = addRankCount });
|
||||
//GContext.container.Resolve<SmallGameData>().image_extra_pos = bg_extra.transform.position;
|
||||
bg_extra.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
bg_extra.SetActive(false);
|
||||
}
|
||||
//this.multiple = multiple;
|
||||
add = glod;
|
||||
if (superCashBonus > 0.001f)
|
||||
{
|
||||
text_num.color = Color.black;
|
||||
text_num_buff.color = Color.white;
|
||||
}
|
||||
GContext.Publish(new TargetAddData(1002, 0, add));
|
||||
StartCoroutine(ShowMoney());
|
||||
StartCoroutine(PlaySpine(superCashBonus > 0.001f));
|
||||
}
|
||||
IEnumerator PlaySpine(bool isShow)
|
||||
{
|
||||
yield return new WaitForSeconds(PlaySpineDelay);
|
||||
skeletonGraphic.AnimationState.SetAnimation(0, "Celebrate01", false);
|
||||
fx_ui_blingbling_01.gameObject.SetActive(isShow);
|
||||
}
|
||||
IEnumerator ShowMoney()
|
||||
{
|
||||
//GameEventMgr.Instance.Raise(GameEvents.GoldAddAni, add);
|
||||
text_num.text = "";
|
||||
text_num_buff.text = "";
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
int gold = 0;
|
||||
DOTween.To(() => gold, x => gold = x, add, 1f).OnUpdate(() =>
|
||||
{
|
||||
text_num.text = ConvertTools.GetNumberString2(gold);
|
||||
text_num_buff.text = text_num.text;
|
||||
});
|
||||
//yield return new WaitForSeconds(1.2f);
|
||||
//text_num.text = ConvertTools.GetNumberString2(add * multiple);
|
||||
}
|
||||
private void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.EventBankHeistRewardPanel);
|
||||
GContext.Publish(new UnloadActToNextAct());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9079df3fef5cd1047b894e612dc646f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
86
Assets/Scripts/UI/SmallGame/EventGamePlayPanel.cs
Normal file
86
Assets/Scripts/UI/SmallGame/EventGamePlayPanel.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using asap.core;
|
||||
using game;
|
||||
using Game;
|
||||
using GameCore;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class EventGamePlayPanel : MonoBehaviour
|
||||
{
|
||||
GameObject bomb;
|
||||
GameObject bank;
|
||||
GameObject hunting;
|
||||
int id;
|
||||
bool isReward;
|
||||
private void Awake()
|
||||
{
|
||||
bomb = transform.Find("root/bomb").gameObject;
|
||||
bank = transform.Find("root/bank").gameObject;
|
||||
hunting = transform.Find("root/hunting").gameObject;
|
||||
GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("EventGamePlayPanel");
|
||||
}
|
||||
public void StartGame(int id, bool isReward = false)
|
||||
{
|
||||
//GContext.Publish(new VibrationData(HapticTypes.Warning));
|
||||
this.id = id;
|
||||
this.isReward = isReward;
|
||||
//bank.SetActive(id == 11);
|
||||
bomb.SetActive(id == 12);
|
||||
hunting.SetActive(id == 11);
|
||||
Transition();
|
||||
}
|
||||
|
||||
async void Transition()
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
IsShowGuidance isShowGuidance = new IsShowGuidance();
|
||||
GContext.Publish(isShowGuidance);
|
||||
if (!isShowGuidance.isShow)
|
||||
{
|
||||
EnterSmallGame();
|
||||
}
|
||||
else
|
||||
{
|
||||
await isShowGuidance.tcs.Task;
|
||||
EnterSmallGame();
|
||||
}
|
||||
}
|
||||
void EnterSmallGame()
|
||||
{
|
||||
IStageData stageData = GContext.container.Resolve<IStageData>();
|
||||
stageData.Id = id;
|
||||
stageData.Type = StageType.SmallGame;
|
||||
stageData.IsRewardSettlement = isReward;
|
||||
if (id == 11)
|
||||
{
|
||||
GContext.Publish(new UnloadActToNextAct("ShooterFishAct"));
|
||||
}
|
||||
else
|
||||
{
|
||||
GContext.Publish(new UnloadActToNextAct("SmallGameAct"));
|
||||
}
|
||||
cfg.Tables _tables = GContext.container.Resolve<cfg.Tables>();
|
||||
if (GContext.container.Resolve<PlayerFishData>().GetAnglingCount() >= GContext.container.Resolve<MMTService>().FixedFish.Count
|
||||
|| GContext.container.Resolve<PlayerData>().lastMapId != _tables.TbMapData.DataList[0].ID)
|
||||
{
|
||||
if (!GContext.container.Resolve<FishingData>().IsNewItemFish() && isReward)
|
||||
{
|
||||
GContext.container.Resolve<PlayerFishData>().SetBotCount(0);
|
||||
}
|
||||
}
|
||||
GContext.Publish(new OnSoundStateEvent(0));
|
||||
//ConvertTools.SetFSBlur(false);
|
||||
DisableFishingBlur();
|
||||
}
|
||||
|
||||
private void DisableFishingBlur()
|
||||
{
|
||||
var stage = RootCtx.container.Resolve<IStageService>().GetStage("FishingStage");
|
||||
if(stage != null && stage.Id == "FishingStage")
|
||||
{
|
||||
var act = stage.CurrentAct as FishingAct;
|
||||
if(act != null)
|
||||
act.EnableFishingVolume(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SmallGame/EventGamePlayPanel.cs.meta
Normal file
11
Assets/Scripts/UI/SmallGame/EventGamePlayPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c5cea9525b585b4aaf5feedb4e1dc6c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
330
Assets/Scripts/UI/SmallGame/EventIslandBombHeistPanel.cs
Normal file
330
Assets/Scripts/UI/SmallGame/EventIslandBombHeistPanel.cs
Normal file
@@ -0,0 +1,330 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class BombBuildingDataEvent
|
||||
{
|
||||
public BombBuildingDataEvent(int index = -1)
|
||||
{
|
||||
this.index = index;
|
||||
}
|
||||
public int index;
|
||||
|
||||
public BombBuilding bombBuilding;
|
||||
public Transform[] bombPos;
|
||||
}
|
||||
public class EventIslandBombHeistPanel : BasePanel
|
||||
{
|
||||
Tables _tables;
|
||||
Head head;
|
||||
Button switchbtn;
|
||||
GameObject exchange;
|
||||
TMP_Text text_name;
|
||||
TMP_Text text_beilv;
|
||||
Transform frame_bomb;
|
||||
List<BombHeistTargetItem> targetItems = new List<BombHeistTargetItem>();
|
||||
bool isClick = false;
|
||||
int multiple;
|
||||
bool is_double_cash = false;
|
||||
float allExtraPoint;
|
||||
//目标位置
|
||||
Vector3 targetPos;
|
||||
int selectIndex = 0;
|
||||
BombBuildingDataEvent bombBuilding;
|
||||
List<ItemData> itemDatas;
|
||||
//int curRankCount;
|
||||
int addRankCount;
|
||||
FishingEventData _fishingEventData;
|
||||
BombGamePlay bombGamePlay;
|
||||
SmallGameData smallGameData;
|
||||
string playFabId;
|
||||
bool isGuided = false;
|
||||
float superBombCashBonus = 0;
|
||||
private void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
smallGameData = GContext.container.Resolve<SmallGameData>();
|
||||
frame_bomb = transform.Find("root/frame_bomb");
|
||||
text_name = transform.Find("root/title/bg/text_name").GetComponent<TMP_Text>();
|
||||
head = transform.Find("root/title/btn_head").GetComponent<Head>();
|
||||
switchbtn = transform.Find("root/switch/btn_switch/btn_green").GetComponent<Button>();
|
||||
exchange = transform.Find("root/switch").gameObject;
|
||||
text_beilv = transform.Find("root/text_beilv").GetComponent<TMP_Text>();
|
||||
text_beilv.gameObject.SetActive(false);
|
||||
BombHeistTargetItem item;
|
||||
for (int i = 1; i < 6; i++)
|
||||
{
|
||||
item = transform.Find($"root/target{i}").GetComponent<BombHeistTargetItem>();
|
||||
targetItems.Add(item);
|
||||
}
|
||||
frame_bomb.gameObject.SetActive(false);
|
||||
isGuided = GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("EventIslandBombHeistPanel");
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
//bool isRankInit = _fishingEventData.rankInit != null;
|
||||
//if (isRankInit)
|
||||
//{
|
||||
// curRankCount = (int)GContext.container.Resolve<PlayerItemData>().GetItemCount(_fishingEventData.rankInit.TokenID);
|
||||
//}
|
||||
|
||||
multiple = GContext.container.Resolve<PlayerData>().GetMagnification();
|
||||
if (multiple > 1)
|
||||
{
|
||||
text_beilv.text = $"x{multiple}";
|
||||
}
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
SuperBomb superBomb = GContext.container.Resolve<BuffDataCenter>().GetWeelyBuffTimeData<SuperBomb>(true);
|
||||
if (superBomb != null)
|
||||
{
|
||||
superBombCashBonus = superBomb.CashBonus;
|
||||
}
|
||||
base.Start();
|
||||
for (int i = 0; i < targetItems.Count; i++)
|
||||
{
|
||||
targetItems[i].Init(i, OnClickItem);
|
||||
targetItems[i].gameObject.SetActive(false);
|
||||
}
|
||||
GContext.OnEvent<ChangeSmallGameTargetEvent>().Subscribe(ChangeSmallGameTarget).AddTo(disposables);
|
||||
playFabId = smallGameData.opponentData.playFabID;
|
||||
GContext.OnEvent<GetClubPlayInfoEvent>().Where(x => x.id == playFabId).Subscribe(SetAvatar).AddTo(disposables);
|
||||
IUserService userService = GContext.container.Resolve<IUserService>();
|
||||
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
|
||||
SetAvatar(clubPlayInfo);
|
||||
//text_name.text = LocalizationMgr.GetFormatTextValue("UI_EventIslandBombHeistPanel_1", smallGameData.opponentData.playName);
|
||||
//head.SetData(smallGameData.opponentData.url);
|
||||
switchbtn.onClick.AddListener(OnClickHead);
|
||||
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("specialevent_bomb"))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
StartCoroutine(Show());
|
||||
}
|
||||
|
||||
IEnumerator Show()
|
||||
{
|
||||
float time = 0.5f;
|
||||
if (isGuided)
|
||||
{
|
||||
time = 2f;
|
||||
}
|
||||
yield return new WaitForSeconds(time);
|
||||
SetBombBuilding();
|
||||
}
|
||||
void SetBombBuilding()
|
||||
{
|
||||
bombBuilding = new BombBuildingDataEvent();
|
||||
GContext.Publish(bombBuilding);
|
||||
for (int i = 0; i < bombBuilding.bombPos.Length; i++)
|
||||
{
|
||||
targetItems[i].gameObject.SetActive(true);
|
||||
targetItems[i].transform.localPosition = ConvertTools.WorldToScreenPoint(bombBuilding.bombPos[i].position);
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (bombBuilding != null)
|
||||
{
|
||||
for (int i = 0; i < bombBuilding.bombPos.Length; i++)
|
||||
{
|
||||
targetItems[i].gameObject.SetActive(true);
|
||||
targetItems[i].transform.localPosition = ConvertTools.WorldToScreenPoint(bombBuilding.bombPos[i].position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isShowing = false;
|
||||
async void OnClickHead()
|
||||
{
|
||||
if (isClick)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_20"));
|
||||
}
|
||||
else if (!isShowing)
|
||||
{
|
||||
isShowing = true;
|
||||
//选择对象
|
||||
await UIManager.Instance.ShowUI(UITypes.EventBankHeistOpponentPopupPanel);
|
||||
isShowing = false;
|
||||
}
|
||||
|
||||
}
|
||||
void OnClickItem(int index)
|
||||
{
|
||||
//GContext.Publish(new VibrationData(HapticTypes.Selection));
|
||||
|
||||
selectIndex = index;
|
||||
isClick = true;
|
||||
exchange.SetActive(false);
|
||||
GContext.Publish(new BombBuildingDataEvent(index));
|
||||
//炮弹路径
|
||||
for (int i = 0; i < targetItems.Count; i++)
|
||||
{
|
||||
targetItems[i].OnSelect(i == index);
|
||||
}
|
||||
SetData();
|
||||
PlayAni();
|
||||
}
|
||||
void SetData()
|
||||
{
|
||||
List<BombInit> bombInits = _tables.TbBombInit.DataList;
|
||||
List<BombGamePlay> bombGamePlays = _tables.TbBombGamePlay.DataList;
|
||||
bombGamePlay = bombGamePlays[0];
|
||||
if (GContext.container.Resolve<IStageData>().IsRewardSettlement && GContext.container.Resolve<SmallGameData>().BombGameCount < bombInits.Count)
|
||||
{
|
||||
int gameType = bombInits[GContext.container.Resolve<SmallGameData>().BombGameCount].Type;
|
||||
bombGamePlay = _tables.TbBombGamePlay.GetOrDefault(gameType);
|
||||
}
|
||||
else
|
||||
{
|
||||
int allWeight = 0;
|
||||
for (int i = 0; i < bombGamePlays.Count; i++)
|
||||
{
|
||||
allWeight += bombGamePlays[i].Weight;
|
||||
}
|
||||
int random = Random.Range(0, allWeight);
|
||||
int weight = 0;
|
||||
for (int i = 0; i < bombGamePlays.Count; i++)
|
||||
{
|
||||
weight += bombGamePlays[i].Weight;
|
||||
if (random <= weight)
|
||||
{
|
||||
bombGamePlay = bombGamePlays[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
itemDatas = new List<ItemData>();
|
||||
ItemData itemData;
|
||||
int dataIndex = 0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(bombGamePlays[i].Reward);
|
||||
itemData.count = (int)(itemData.count * smallGameData.opponentData.power);
|
||||
if (bombGamePlay.ID == bombGamePlays[i].ID)
|
||||
{
|
||||
dataIndex = i;
|
||||
}
|
||||
itemData.count = (int)(itemData.count * (1 + superBombCashBonus));
|
||||
itemDatas.Add(itemData);
|
||||
}
|
||||
itemData = itemDatas[selectIndex];
|
||||
itemDatas[selectIndex] = itemDatas[dataIndex];
|
||||
itemDatas[dataIndex] = itemData;
|
||||
}
|
||||
async void PlayAni()
|
||||
{
|
||||
await Awaiters.Seconds(5f);
|
||||
frame_bomb.gameObject.SetActive(false);
|
||||
|
||||
targetItems[selectIndex].MainShowData(itemDatas[selectIndex]);
|
||||
await Awaiters.Seconds(0.5f);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (i != selectIndex)
|
||||
{
|
||||
targetItems[i].ShowData(itemDatas[i]);
|
||||
await Awaiters.Seconds(0.2f);
|
||||
}
|
||||
}
|
||||
GContext.Publish(new VibrationData(HapticTypes.HeavyImpact));
|
||||
await Awaiters.Seconds(0.5f);
|
||||
if (multiple > 1)
|
||||
{
|
||||
bombBuilding.bombBuilding.cannonRoot.text_beilv.gameObject.SetActive(false);
|
||||
text_beilv.gameObject.SetActive(true);
|
||||
targetPos = targetItems[selectIndex].transform.position;
|
||||
text_beilv.transform.DOMove(targetPos, 0.5f);
|
||||
await Awaiters.Seconds(0.5f);
|
||||
text_beilv.gameObject.SetActive(false);
|
||||
//翻倍
|
||||
targetItems[selectIndex].Multiply(itemDatas[selectIndex], multiple);
|
||||
await Awaiters.Seconds(1.3f);
|
||||
}
|
||||
|
||||
//结算
|
||||
UIManager.Instance.DestroyUI(UITypes.EventBankHeistOpponentPopupPanel);
|
||||
|
||||
if (_fishingEventData.rankInit != null)
|
||||
{
|
||||
int point = _fishingEventData.rankInit.PointDestruction[^bombGamePlay.Type] * multiple;
|
||||
addRankCount += point;
|
||||
|
||||
_fishingEventData.AddRankTarget(point);
|
||||
}
|
||||
int getGlodCount = (int)itemDatas[selectIndex].count;// * multiple;
|
||||
GContext.Publish(new ConditionTypeEvent(ConditionType.MaxCashFromBomb, getGlodCount));
|
||||
int glodCount = getGlodCount * multiple;
|
||||
GContext.container.Resolve<PlayerItemData>().AddItemCount(1002, glodCount);
|
||||
smallGameData.SetEnemy(EnemyType.Bomb, glodCount);
|
||||
GContext.Publish(new ConditionTypeEvent(ConditionType.CashFromBomb, glodCount));
|
||||
GContext.Publish(new BombBuildingDataEvent(-2));
|
||||
GContext.container.Resolve<SmallGameData>().SaveBombGameCount();
|
||||
GContext.Publish(new ConditionTypeEvent(ConditionType.DoBomb, 1));
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("special_event"))
|
||||
{
|
||||
e.AddContent("special_event_multiple", multiple)
|
||||
.AddContent("finish_times", GContext.container.Resolve<SmallGameData>().BombGameCount)
|
||||
.AddContent("item_id", 1002)
|
||||
.AddContent("reward_cash", glodCount)
|
||||
.AddContent("event_type", 2);
|
||||
}
|
||||
using (var e = GEvent.GameEvent("bomb_camp"))
|
||||
{
|
||||
e.AddContent("fish_multiple", multiple)
|
||||
.AddContent("map_id", GContext.container.Resolve<PlayerData>().currentMapId)
|
||||
.AddContent("bomb_user_id", smallGameData.opponentData.playFabID)
|
||||
.AddContent("bomb_map_id", smallGameData.opponentData.BombID)
|
||||
.AddContent("reward_cash", glodCount);
|
||||
}
|
||||
#endif
|
||||
|
||||
var go = await UIManager.Instance.GetUIAsync(UITypes.EventBankHeistRewardPanel);
|
||||
EventBankHeistRewardPanel eventBankHeistRewardPanel = go.GetComponent<EventBankHeistRewardPanel>();
|
||||
eventBankHeistRewardPanel.SetData(glodCount, superBombCashBonus, addRankCount);
|
||||
}
|
||||
|
||||
async void ChangeSmallGameTarget(ChangeSmallGameTargetEvent data)
|
||||
{
|
||||
bombBuilding = null;
|
||||
playFabId = data.opponentItemData.playFabID;
|
||||
await data.ts.Task;
|
||||
//text_name.text = LocalizationMgr.GetFormatTextValue("UI_EventIslandBombHeistPanel_1", data.opponentItemData.playName);
|
||||
//head.SetData(data.opponentItemData.url);
|
||||
SetBombBuilding();
|
||||
IUserService userService = GContext.container.Resolve<IUserService>();
|
||||
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
|
||||
SetAvatar(clubPlayInfo);
|
||||
}
|
||||
|
||||
public void SetAvatar(PlayInfo clubPlayInfo)
|
||||
{
|
||||
if (clubPlayInfo != null)
|
||||
{
|
||||
text_name.text = LocalizationMgr.GetFormatTextValue("UI_EventIslandBombHeistPanel_1", clubPlayInfo.name);
|
||||
head.SetData(clubPlayInfo.avatarUrl);
|
||||
}
|
||||
}
|
||||
void SetAvatar(GetClubPlayInfoEvent getClubPlayInfoEvent)
|
||||
{
|
||||
if (getClubPlayInfoEvent.id == playFabId)
|
||||
{
|
||||
text_name.text = LocalizationMgr.GetFormatTextValue("UI_EventIslandBombHeistPanel_1", getClubPlayInfoEvent.name);
|
||||
head.SetData(getClubPlayInfoEvent.avatarUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddf37b6353e292f4983cf7fb28dc5c3c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
96
Assets/Scripts/UI/SmallGame/OpponentItem.cs
Normal file
96
Assets/Scripts/UI/SmallGame/OpponentItem.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using asap.core;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class OpponentItem : MonoBehaviour
|
||||
{
|
||||
Head head;
|
||||
TMP_Text text_name;
|
||||
TMP_Text text_info;
|
||||
Button btn_challenge;
|
||||
OpponentItemData opponentItemData;
|
||||
public Action<OpponentItemData, bool> action;
|
||||
string playFabId;
|
||||
IDisposable disposable;
|
||||
private void Awake()
|
||||
{
|
||||
disposable = GContext.OnEvent<GetClubPlayInfoEvent>().Where(x => x.id == playFabId).Subscribe(SetAvatar);
|
||||
head = transform.Find("btn_head").GetComponent<Head>();
|
||||
text_name = transform.Find("info/text_name").GetComponent<TMP_Text>();
|
||||
text_info = transform.Find("info/text_info").GetComponent<TMP_Text>();
|
||||
btn_challenge = transform.Find("btn_common_green_c/btn_green_c").GetComponent<Button>();
|
||||
}
|
||||
public void SetGray()
|
||||
{
|
||||
btn_challenge.gameObject.SetActive(false);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_challenge.onClick.AddListener(() =>
|
||||
{
|
||||
action?.Invoke(opponentItemData, false);
|
||||
});
|
||||
}
|
||||
public void SetData(OpponentItemData opponentItemData)
|
||||
{
|
||||
this.opponentItemData = opponentItemData;
|
||||
playFabId = opponentItemData.playFabID;
|
||||
text_info.text = opponentItemData.info;
|
||||
text_info.gameObject.SetActive(!string.IsNullOrEmpty(opponentItemData.info));
|
||||
//text_name.text = opponentItemData.playName;
|
||||
//head.SetData(opponentItemData.url);
|
||||
IUserService userService = GContext.container.Resolve<IUserService>();
|
||||
PlayInfo clubPlayInfo = userService.GetPlayInfo(playFabId);
|
||||
SetAvatar(clubPlayInfo);
|
||||
}
|
||||
|
||||
public void SetTextInfo(string text)
|
||||
{
|
||||
text_info.text = text;
|
||||
}
|
||||
|
||||
public void SetAvatar(PlayInfo clubPlayInfo)
|
||||
{
|
||||
if (clubPlayInfo != null)
|
||||
{
|
||||
text_name.text = clubPlayInfo.name;
|
||||
head.SetData(clubPlayInfo.avatarUrl);
|
||||
}
|
||||
}
|
||||
void SetAvatar(GetClubPlayInfoEvent getClubPlayInfoEvent)
|
||||
{
|
||||
if (getClubPlayInfoEvent.id == playFabId)
|
||||
{
|
||||
text_name.text = getClubPlayInfoEvent.name;
|
||||
head.SetData(getClubPlayInfoEvent.avatarUrl);
|
||||
}
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
}
|
||||
public class OpponentItemData
|
||||
{
|
||||
public string playFabID;
|
||||
//public string playName;
|
||||
//public string url;
|
||||
public string info;
|
||||
public int BombID;
|
||||
public float power;
|
||||
public bool isRobot;
|
||||
/// <summary>
|
||||
/// 1=好友组, 2=非好友玩家组, 3=机器人组
|
||||
/// </summary>
|
||||
public int target_group;
|
||||
/// <summary>
|
||||
/// -1=机器人, 1=好友, 2=一日内活跃玩家, 3=排行榜玩家, 4=复仇玩家
|
||||
/// </summary>
|
||||
public int target_source;
|
||||
}
|
||||
11
Assets/Scripts/UI/SmallGame/OpponentItem.cs.meta
Normal file
11
Assets/Scripts/UI/SmallGame/OpponentItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c9e249d8d6872a41ba687725e743dd1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user