备份CatanBuilding瘦身独立工程

This commit is contained in:
JSD\13999
2026-05-26 16:15:54 +08:00
commit 2d0e6a61b7
12001 changed files with 2431925 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
using asap.core;
using cfg;
public struct DuelChatEvent
{
public int RoleID;
public int MessageID;
public DuelChatEvent(int roleID, int messageID)
{
RoleID = roleID;
MessageID = messageID;
}
}
public class DuelChatModel : IDuelChatModel
{
public int RoleID { get; set; }
public void ReceiveMessage(int message)
{
GContext.Publish(new DuelChatEvent(RoleID, message));
}
/// <summary>
/// 敌人真人 不需要发送消息
/// </summary>
/// <param name="message"></param>
public void SendMessage(int message)
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d0bde08c7e4650c4dba2b76d4eb97099
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 需要从服务器收数据
/// </summary>
public class DuelEnemyModel : DuelModel//:服务器接口
{
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a5b609134ace35c41b49479a0ddd878a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,207 @@
using asap.core;
using System.Collections.Generic;
using UnityEngine;
public class DuelFishingEvent
{
public int RoleID;
public int index;
public FishInfoData data;
public bool isEnd;
public int ItemID;
public DuelFishingEvent(int RoleID, int itemID)
{
ItemID = itemID;
this.RoleID = RoleID;
}
public DuelFishingEvent(int RoleID, int index, FishInfoData data, bool isEnd)
{
this.RoleID = RoleID;
this.index = index;
this.data = data;
this.isEnd = isEnd;
}
}
public class DuelModel : IDuelPlayerModel
{
public int RoleID { get; set; }
public string PlayerID { get; set; }
public int SetRodTime { get; set; } //设置鱼竿时间
public string PlayerName { get; set; }
public List<int> CarLevels { get; set; } = new List<int>(6);
public string PlayerAvatar { get; set; }
public int RankScore { get; set; }
public int Mag { get; set; } = 1;
public int RodId { get; set; }
public int RodLevel { get; set; }
public int RodStar { get; set; }
public int CurrentPTS { set; get; } //当前分数
public List<DuelFishingData> DuelFishingDatas { get; set; } = new List<DuelFishingData>();
public int CurrentFailNum { get; set; } //失败次数
int MaxFailNum = 3;
protected DuelFishingData CurrentState;
public int index;
public void Init(string playerID, string playerName, string playerAvatar, int randScore, int mag, int maxFail)
{
PlayerID = playerID;
PlayerName = playerName;
PlayerAvatar = playerAvatar;
RankScore = randScore;
Mag = mag;
CurrentPTS = 0;
CurrentFailNum = 0;
MaxFailNum = maxFail;
}
public void Init(List<int> carLevels)
{
CarLevels = carLevels;
}
public void SetRodData(DuelRodData rodData)
{
RodId = rodData.rodId;
RodLevel = rodData.rodLevel;
RodStar = rodData.rodStar;
}
public virtual void Start()
{
CurrentState = NewDuelFishingData();
}
public virtual void StartLastRecordedTime()
{
}
//public virtual void StartFishing()
//{
//}
public virtual bool StopFishing(FishInfoData data)
{
if (CurrentState == null)
{
Debug.LogError("CurrentState is null, please call Start() first.");
return false;
}
CurrentState.fishItemId = data.fishItemId;
bool isWin = data.point > 0;
CurrentState.isWin = isWin;
CurrentState.point = data.point;
CurrentPTS += data.point;
int stateIndex = 0;
if (isWin)
{
CurrentFailNum = 0;
CurrentState.fishCardAdd = data.fishCardAdd;
CurrentState.fishRodAdd = data.fishRodAdd;
index++;
stateIndex = index;
}
else
{
CurrentFailNum++;
CurrentState.failNum = CurrentFailNum;
if (CurrentFailNum >= MaxFailNum)
{
index++;
stateIndex = index;
CurrentFailNum = 0;
}
}
bool isEnd = index >= CarLevels.Count;
GContext.Publish(new DuelFishingEvent(RoleID, stateIndex, data, isEnd));
CurrentState = NewDuelFishingData();
return isEnd;
}
public bool IsLastFish()
{
return index >= CarLevels.Count - 1;
}
public virtual void CastRod(int fishID)
{
CurrentState.fishItemId = fishID;
GContext.Publish(new DuelFishingEvent(RoleID, fishID));
}
public List<DuelFishingData> GetShowDatas()
{
List<DuelFishingData> duelFishingDatas = new List<DuelFishingData>();
foreach (var data in DuelFishingDatas)
{
if (data.isWin || data.failNum >= 3)
{
DuelFishingData showData = new DuelFishingData
{
slienceTime = data.slienceTime,
//castingTime = data.castingTime,
fishingTime = data.fishingTime,
isWin = data.isWin,
fishItemId = data.fishItemId,
point = data.point,
failNum = data.failNum,
fishCardAdd = data.fishCardAdd,
fishRodAdd = data.fishRodAdd
};
duelFishingDatas.Add(showData);
}
}
return duelFishingDatas;
}
public FishInfoData GetDuelFishingData(int index, int fishID, int point, float fishCardAdd, float fishingRodAdd)
{
FishInfoData infoData = new FishInfoData()
{
fishItemId = fishID,
point = point,
fishCardAdd = fishCardAdd,
fishRodAdd = fishingRodAdd,
higher = true,
higherCard = true,
higherRod = true
};
int count = DuelFishingDatas.Count;
if (index < 0 || index >= count)
{
return infoData;
}
count = 0;
for (int i = 0; i < DuelFishingDatas.Count; i++)
{
DuelFishingData data = DuelFishingDatas[i];
if (data.isWin || data.failNum >= 3)
{
if (count == index)
{
if (data.isWin)
//设置对手数据
{
infoData.higher = data.point < point;
infoData.higherCard = data.fishCardAdd < fishCardAdd;
infoData.higherRod = data.fishRodAdd < fishingRodAdd;
}
else
break;
}
count++;
}
}
return infoData; //如果没有找到对应的成功数据则返回null
}
public DuelFishingData NewDuelFishingData()
{
DuelFishingData duelFishingData = new DuelFishingData();
duelFishingData.isWin = false;
duelFishingData.slienceTime = 0;
duelFishingData.fishingTime = 0;
DuelFishingDatas.Add(duelFishingData);
return duelFishingData;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ac06e75d9bb311b46980ea86363bdab3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using asap.core;
using cfg;
public class DuelPlayerChatModel : IDuelChatModel
{
public int RoleID { get; set; }
public void ReceiveMessage(int message)
{
GContext.Publish(new DuelChatEvent(RoleID, message));
}
/// <summary>
/// 自己发送消息,远端和本地转发
/// </summary>
/// <param name="messageID"></param>
public void SendMessage(int messageID)
{
ReceiveMessage(messageID);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 55b26abaf03e046428efe9094b334a26
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 需要同步服务器
/// </summary>
public class DuelPlayerModel : DuelModel//:服务器接口
{
DateTime LastRecordedTime;
public override void Start()
{
base.Start();
LastRecordedTime = ZZTimeHelper.UtcNow();
}
public override void StartLastRecordedTime()
{
SetRodTime = (int)(ZZTimeHelper.UtcNow() - LastRecordedTime).TotalSeconds;
LastRecordedTime = ZZTimeHelper.UtcNow();
}
//public override void StartFishing()
//{
// SetCastingTime();
// base.StartFishing();
//}
public override bool StopFishing(FishInfoData data)
{
SetFishingTime();
return base.StopFishing(data);
}
public override void CastRod(int fishID)
{
SetSlienceTime();
base.CastRod(fishID);
}
void SetSlienceTime()
{
CurrentState.slienceTime = (int)(ZZTimeHelper.UtcNow() - LastRecordedTime).TotalSeconds;
LastRecordedTime = ZZTimeHelper.UtcNow();
}
//void SetCastingTime()
//{
// CurrentState.castingTime = (int)(ZZTimeHelper.UtcNow() - LastRecordedTime).TotalSeconds;
// LastRecordedTime = ZZTimeHelper.UtcNow();
//}
void SetFishingTime()
{
CurrentState.fishingTime = (int)(ZZTimeHelper.UtcNow() - LastRecordedTime).TotalSeconds;
LastRecordedTime = ZZTimeHelper.UtcNow();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a3ebabc836cefdb4a828e1d407dfa3b0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,123 @@
using asap.core;
using cfg;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public enum RobotDuelChatType
{
Start = 1,
FishingSuccess = 2,
OpponetFishingSuccess = 3,
OpponetFishingFail = 4,
FirstLastFishStart = 5,
FirstLastFishSuccess = 6,
EndVictory = 7,
EndDefeat = 8
}
public class DuelRobotChatModel : IDuelChatModel
{
public int RoleID { get; set; }
EventSoloRobotBehavior enemyRobotBehavior;
List<int> RobotBehaviorTimeDelay = new List<int>() { 0, 2 };
public DuelRobotChatModel()
{
GetEventSoloRobotBehavior();
}
public void ReceiveMessage(int message)
{
GContext.Publish(new DuelChatEvent(RoleID, message));
}
/// <summary>
/// 机器人 读表获取消息 转发本地
/// </summary>
/// <param name="messageType"></param>
public void SendMessage(int messageType)
{
RobotDuelChatType robotDuelChatType = (RobotDuelChatType)messageType;
Debug.Log($"RobotDuelChatType: {robotDuelChatType}");
int prob = 0;
List<int> ints = new List<int>();
switch (robotDuelChatType)
{
case RobotDuelChatType.Start:
prob = enemyRobotBehavior.Start[0][0];
ints = enemyRobotBehavior.Start[1];
break;
case RobotDuelChatType.FishingSuccess:
prob = enemyRobotBehavior.FishingSuccess[0][0];
ints = enemyRobotBehavior.FishingSuccess[1];
break;
case RobotDuelChatType.OpponetFishingSuccess:
prob = enemyRobotBehavior.OpponetFishingSuccess[0][0];
ints = enemyRobotBehavior.OpponetFishingSuccess[1];
break;
case RobotDuelChatType.OpponetFishingFail:
prob = enemyRobotBehavior.OpponetFishingFail[0][0];
ints = enemyRobotBehavior.OpponetFishingFail[1];
break;
case RobotDuelChatType.FirstLastFishStart:
prob = enemyRobotBehavior.FirstLastFishStart[0][0];
ints = enemyRobotBehavior.FirstLastFishStart[1];
break;
case RobotDuelChatType.FirstLastFishSuccess:
prob = enemyRobotBehavior.FirstLastFishSuccess[0][0];
ints = enemyRobotBehavior.FirstLastFishSuccess[1];
break;
case RobotDuelChatType.EndVictory:
prob = enemyRobotBehavior.EndVictory[0][0];
ints = enemyRobotBehavior.EndVictory[1];
break;
case RobotDuelChatType.EndDefeat:
prob = enemyRobotBehavior.EndDefeat[0][0];
ints = enemyRobotBehavior.EndDefeat[1];
break;
default:
break;
}
int randomValue = UnityEngine.Random.Range(0, 100);
//Debug.Log($"机器人消息: {robotDuelChatType} ID {enemyRobotBehavior.ID} prob:{prob} randomValue:{randomValue}");
if (prob == 0 || prob < randomValue)
{
return;
}
int index = UnityEngine.Random.Range(0, ints.Count);
int messageId = ints[index];
SendMessageDelay(messageId);
}
async void SendMessageDelay(int messageId)
{
try
{
float delay = UnityEngine.Random.Range(RobotBehaviorTimeDelay[0] * 1f, RobotBehaviorTimeDelay[1]);
await Awaiters.Seconds(delay);
ReceiveMessage(messageId);
}
catch (System.Exception e)
{
Debug.LogError($" [RobotChat] SendMessageDelay error: {e.Message}");
}
}
void GetEventSoloRobotBehavior()
{
RobotBehaviorTimeDelay = GContext.container.Resolve<Tables>().TbEventSoloConfig.RobotBehaviorTimeDelay;
List<EventSoloRobotBehavior> robotBehaviors = GContext.container.Resolve<Tables>().TbEventSoloRobotBehavior.DataList;
int allweight = robotBehaviors.Select(x => x.Weight).Sum();
int randomValue = UnityEngine.Random.Range(0, allweight);
int currentWeight = 0;
foreach (var behavior in robotBehaviors)
{
currentWeight += behavior.Weight;
if (randomValue < currentWeight)
{
enemyRobotBehavior = behavior;
break;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 73554857fbc8c7d4fb225f08a64aca53
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,102 @@
using System.Collections;
using System.Collections.Generic;
using UniRx;
using UnityEngine;
public struct RobotFishingQueue
{
public FishingChangeState changeState;
public int waitTimer;
public int fishItemId;
public int point;
public float fishCardAdd;
public float fishingRodAdd;
}
public class DuelRobotEntity : MonoBehaviour
{
List<DuelFishingData> robotInfos;
FishingDuelManager FDM;
Queue<RobotFishingQueue> robotQueue = new Queue<RobotFishingQueue>();
float chooseRodTime;
public void Init(List<DuelFishingData> robotInfos, FishingDuelManager FDM)
{
this.robotInfos = robotInfos;
this.FDM = FDM;
SetFishingQueue();
WaitStart();
}
float allUpdateTime = 0f;
float robotUpdateTime = 0f;
private void Update()
{
if (robotInfos == null || robotInfos.Count == 0 || robotQueue.Count == 0 || FDM.RodState < 2)
{
return;
}
allUpdateTime += Time.unscaledDeltaTime;
if (allUpdateTime > robotUpdateTime)
{
RobotFishingQueue robotFishingQueue = robotQueue.Dequeue();
FDM.ReceiveFishingQueue(robotFishingQueue);
if (robotQueue.Count > 0)
{
robotFishingQueue = robotQueue.Peek();
robotUpdateTime += robotFishingQueue.waitTimer;
#if UNITY_EDITOR
Debug.Log("机器人下一个状态:" + robotFishingQueue.changeState + " 等待时间:" + robotFishingQueue.waitTimer);
#endif
}
}
}
void SetFishingQueue()
{
DuelFishingData robotInfo;
robotUpdateTime = robotInfos[0].slienceTime / 2;
bool preFail = false;
for (int i = 0; i < robotInfos.Count; i++)
{
robotInfo = robotInfos[i];
RobotFishingQueue robotFishingQueue = new RobotFishingQueue
{
changeState = FishingChangeState.Cast,
waitTimer = robotInfo.slienceTime,
fishItemId = robotInfo.fishItemId
};
if (preFail)
{
robotFishingQueue.waitTimer /= 2; //如果上一个是失败,则静默时间减半
}
robotQueue.Enqueue(robotFishingQueue);
//robotFishingQueue = new RobotFishingQueue
//{
// changeState = FishingChangeState.StartFishing,
// waitTimer = robotInfo.castingTime,
// fishItemId = robotInfo.fishItemId
//};
//robotQueue.Enqueue(robotFishingQueue);
robotFishingQueue = new RobotFishingQueue
{
changeState = FishingChangeState.FishingSuccess,
waitTimer = robotInfo.fishingTime,
fishItemId = robotInfo.fishItemId,
point = robotInfo.point,
fishCardAdd = robotInfo.fishCardAdd,
fishingRodAdd = robotInfo.fishRodAdd
};
preFail = !robotInfo.isWin;
if (robotInfo.point == 0)
{
robotFishingQueue.changeState = FishingChangeState.FishingFail;
}
robotQueue.Enqueue(robotFishingQueue);
}
}
async void WaitStart()
{
var RobotChooseRodTime = FDM.eventSoloConfig.RobotChooseRodTime;
chooseRodTime = Random.Range(RobotChooseRodTime[0], RobotChooseRodTime[1]);
await Awaiters.Seconds(chooseRodTime);
FDM.ReceiveEnemyRodData(FDM.robotRod);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e1a05ebfe11c25f428e631ac57d91de0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,837 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using UniRx;
using UnityEngine;
public partial class FishingDuelManager
{
public const string SoloDataKey = "SoloDataKey";
public const string EventPkDuel = "FishingDuelAct";
private cfg.Tables _tables;
private ICustomServerMgr customServerMgr;
FishingEventData eventData;
public DuelData duelData { get { return eventData.duelData; } }
int magnificationIndex
{
get { return duelData.multiple; }
set
{
duelData.multiple = value;
eventData.SaveDuelData();
}
}
public int magnification { get; set; }
DuelModel selfModel = new DuelModel();
DuelModel enemyModel = new DuelModel();
IDuelChatModel selfChatModel = new DuelChatModel();
IDuelChatModel enemyChatModel = new DuelChatModel();
public IDuelPlayerModel SelfModel
{
get { return selfModel; }
}
public IDuelPlayerModel EnemyModel
{
get { return enemyModel; }
}
public IDuelChatModel SelfChatModel
{
get { return selfChatModel; }
}
public IDuelChatModel EnemyChatModel
{
get { return enemyChatModel; }
}
public bool CurrentFail => selfModel.CurrentFailNum == 0; //当前失败次数
public int CurrentRetryNum => eventSoloConfig.MaxFailCount - selfModel.CurrentFailNum;
public float FillAmount
{
get
{
int pts = selfModel.CurrentPTS + enemyModel.CurrentPTS;
if (pts <= 0)
{
return 0;
}
return (float)selfModel.CurrentPTS / pts;
}
}
//当前倍率
public EventSolomain eventSolomain { get; private set; }
public EventSolomain beforeSolomain { get; private set; }
public EventSolomain enemySolomain { get; set; }
public TbEventSoloConfig eventSoloConfig { get; private set; }
//======================机器人信息==========================
public EventSoloRobot eventSoloRobot { get; set; }
public List<DuelFishingData> robotInfos { get; private set; }
public DuelRodData robotRod { get; private set; }
//======================机器人信息==========================
public int MapId => duelData.mapId;
int index = 0;
public List<int> FishItemIDs;
public int curProgress;
public bool isSettle = false;
public UIType OnStopShowUIType = UITypes.EventFishingDuelPanel;
public ReactiveProperty<int> GameOver = new ReactiveProperty<int>();
public List<int> TraitID = new List<int>();
public bool selfIsLastFish = false;
public FishingDuelManager()
{
_tables = GContext.container.Resolve<Tables>();
eventSoloConfig = _tables.TbEventSoloConfig;
customServerMgr = GContext.container.Resolve<ICustomServerMgr>();
eventData = GContext.container.Resolve<FishingEventData>();
SetCurRankData();
}
#region
void SetCurRankData()
{
eventSolomain = GetEventSolomain(duelData.progress);
magnification = eventSolomain.MagList[magnificationIndex];
//获取机器人配置
List<int> RobotAccountList = eventSolomain.RobotAccountList;
var robotAccount = RobotAccountList[UnityEngine.Random.Range(0, RobotAccountList.Count)];
eventSoloRobot = _tables.TbEventSoloRobot.DataMap[robotAccount];
}
public bool SetProgress()
{
bool add = selfModel.CurrentPTS > enemyModel.CurrentPTS;
if (add)
{
duelData.progress += eventSolomain.WinTrophy * magnification;
}
else
{
duelData.progress -= eventSolomain.LoseTrophy * magnification;
}
if (duelData.progress < _tables.TbEventSoloConfig.MinTrophy)
{
duelData.progress = _tables.TbEventSoloConfig.MinTrophy;
}
eventData.duelData.preProgress = duelData.progress;
beforeSolomain = eventSolomain;
var data = _tables.TbEventSolomain.DataList;
for (int i = data.Count - 1; i >= 0; i--)
{
if (duelData.progress >= data[i].TrophyRange[0])
{
beforeSolomain = data[i];
break;
}
}
eventData.SaveDuelData();
//往服务器传数据
SendDuelFishingData();
return add;
}
public void SetMagnification()
{
magnificationIndex++;
if (magnificationIndex >= eventSolomain.MagList.Count)
{
magnificationIndex = 0;
GContext.Publish(new VibrationData(HapticTypes.LightImpact));
}
else
{
GContext.Publish(new VibrationData(HapticTypes.Selection));
}
magnification = eventSolomain.MagList[magnificationIndex];
}
public void SetMaxMagnification()
{
for (int i = magnificationIndex - 1; i >= 0; i--)
{
if (duelData.tickets >= eventSolomain.MagList[i])
{
magnificationIndex = i;
magnification = eventSolomain.MagList[magnificationIndex];
break;
}
}
}
public bool IsMaxMagnification()
{
return magnificationIndex == eventSolomain.MagList.Count - 1;
}
public void OnJoin()
{
//扣除体力
//GContext.container.Resolve<PlayerData>().ReduceEnergy(eventSolomain.MatchCost * magnification);
//增加参与过的次数
curProgress = duelData.progress;
duelData.progress -= eventSolomain.LoseTrophy * magnification;
if (duelData.progress < _tables.TbEventSoloConfig.MinTrophy)
{
duelData.progress = _tables.TbEventSoloConfig.MinTrophy;
}
eventData.AddDuelTickets(-magnification);
}
public void SetMapId(int id)
{
duelData.mapId = id;
eventData.SaveDuelData();
}
public List<ItemData> GetReward()
{
List<ItemData> itemDatas =
GContext.container.Resolve<PlayerItemData>().
GetItemDataByDropId(eventSolomain.WinReward);
return itemDatas;
}
public EventSolomain GetEventSolomain(int progress)
{
var data = _tables.TbEventSolomain.DataList;
for (int i = data.Count - 1; i >= 0; i--)
{
if (progress >= data[i].TrophyRange[0])
{
return data[i];
}
}
return data[0];
}
public Item GetFishItem()
{
int id;
Item item;
if (index >= FishItemIDs.Count)
{
id = FishItemIDs[index - 1];
item = _tables.TbItem.GetOrDefault(id);
return item;
}
id = FishItemIDs[index];
index++;
item = _tables.TbItem.GetOrDefault(id);
return item;
}
public bool IsFishItemFull()
{
return index >= FishItemIDs.Count;
}
public bool IsFishItemEmpty()
{
return index >= FishItemIDs.Count;
}
public void GetFishItemID(System.Random random)
{
//对比 eventSolomain 和 enemySolomain 取段位低的
FishItemIDs = new List<int>();
var mapData = _tables.TbMapData.DataMap[MapId];
var solomain = eventSolomain;
if (enemySolomain.RankTier < eventSolomain.RankTier)
{
solomain = enemySolomain;
}
//同一ID 不能超过总数的这个比例
float duplicateFishRat = eventSoloConfig.DuplicateFishRat / 100f;
int fishCount = solomain.FishSequenceCount;
int fishConfig = solomain.FishSequenceConfig;
List<FishItemList> dropFishList = mapData.DropFishList;
List<List<int>> fishList = new List<List<int>>();
for (int i = 0; i < dropFishList.Count; i++)
{
List<int> fishs = new List<int>(dropFishList[i].FishIDList);
fishList.Add(fishs);
}
// 辅助字典记录每个ID已出现的次数
Dictionary<int, int> idCountDict = new Dictionary<int, int>();
int itemID;
for (int i = 0; i < fishConfig; i++)
{
itemID = GetValidFishID(fishList, random, 2, 5, fishCount, duplicateFishRat, idCountDict);
FishItemIDs.Add(itemID);
UpdateIDCountDict(idCountDict, itemID);
}
for (int i = fishConfig; i < fishCount; i++)
{
itemID = GetValidFishID(fishList, random, 0, 5, fishCount, duplicateFishRat, idCountDict);
FishItemIDs.Add(itemID);
UpdateIDCountDict(idCountDict, itemID);
}
//随机打乱
for (int i = 0; i < FishItemIDs.Count; i++)
{
int j = random.Next(i, FishItemIDs.Count);
int temp = FishItemIDs[i];
FishItemIDs[i] = FishItemIDs[j];
FishItemIDs[j] = temp;
}
Debug.Log($"本局鱼ID{string.Join(',', FishItemIDs)}");
}
// 辅助方法获取符合比例限制的鱼ID
private int GetValidFishID(List<List<int>> dropFishList, System.Random random, int minQuality, int maxQuality,
int currentTotal, float maxRatio, Dictionary<int, int> idCountDict)
{
int isInvalid = 10;
int itemID = 0;
do
{
// 随机选择品质等级([minQuality, maxQuality)
int qualityIndex = random.Next(minQuality, maxQuality);
// 从该品质的鱼ID列表中随机选一个
var fishIDList = dropFishList[qualityIndex];
if (fishIDList.Count > 0)
{
itemID = fishIDList[random.Next(fishIDList.Count)];
if (qualityIndex >= 4)
{
hasRedFish = true;
}
// 计算当前ID如果添加后是否超过比例限制
int newCount = idCountDict.TryGetValue(itemID, out int count) ? count + 1 : 1;
// 检查是否超过最大比例允许有1e-6的浮点误差
if (newCount > 1 && currentTotal > 0 && (float)newCount / currentTotal > maxRatio - 1e-6)
{
fishIDList.Remove(itemID); // 从列表中移除该ID避免重复选择
isInvalid--;
Debug.Log($"剔除鱼ID{itemID} 当前数量:{newCount} 总数量:{currentTotal} 比例:{(float)newCount / currentTotal} 最大比例:{maxRatio}");
}
else
{
isInvalid = 0;
}
}
}
// 如果无效则重新选择直到找到符合条件的ID
while (isInvalid > 0);
if (itemID == 0)
{
// 理论上不会到这里
Debug.LogError("配表冲突");
itemID = dropFishList[0][0];
}
return itemID;
}
// 辅助方法更新ID计数字典
private void UpdateIDCountDict(Dictionary<int, int> dict, int id)
{
if (dict.ContainsKey(id))
{
dict[id]++;
}
else
{
dict[id] = 1;
}
}
#endregion
#region
void PlayerRobot(DuelFishingDataSave dataSave)
{
enemyModel = new DuelPlayerModel();
enemyModel.Init(dataSave.playerID, dataSave.playerName, dataSave.playerAvatar, dataSave.rankScore, dataSave.mag, eventSoloConfig.MaxFailCount);
ReceiveEnemyFishCardLevel(dataSave.carLevels);
enemyChatModel = new DuelRobotChatModel();
//设置机器人数据列表
robotInfos = dataSave.selfDuelFishingDatas;
robotRod = new DuelRodData
{
rodId = dataSave.rodId,
rodLevel = dataSave.rodLevel,
rodStar = dataSave.rodStar
};
}
void MachRobot()
{
var RobotList = eventSoloRobot.RobotList;
int robotId = RobotList[UnityEngine.Random.Range(0, RobotList.Count)];
var robotData = _tables.TbRobot.DataMap[robotId];
//获得鱼卡等级
List<int> carLv = new List<int>();
MapData _curMapData = _tables.TbMapData.DataMap[MapId];
var CardLevelList = eventSoloRobot.CardLevel;
int mapIndex = (_curMapData.ID - 1) % 100;
for (int i = 0; i < FishItemIDs.Count; i++)
{
Item item = _tables.TbItem.DataMap[FishItemIDs[i]];
var fishData = _tables.TbFishData.DataMap[item.RedirectID];
int cardIndex = _curMapData.FishList.IndexOf(fishData.ID);
cardIndex %= CardLevelList.Count;
var CardLevel = CardLevelList[cardIndex];
mapIndex = mapIndex % CardLevel.Count;
int cardLevel = CardLevel[mapIndex];
carLv.Add(cardLevel);
}
var MagList = enemySolomain.MagList;
int magIndex = UnityEngine.Random.Range(0, MagList.Count);
enemyModel = new DuelPlayerModel();
enemyModel.Init(robotData.ID.ToString("X"), LocalizationMgr.GetText(robotData.Name_l10n_key), robotData.Avatar, eventSoloRobot.Trophy, MagList[magIndex], eventSoloConfig.MaxFailCount);
ReceiveEnemyFishCardLevel(carLv);
enemyChatModel = new DuelRobotChatModel();
//设置机器人数据列表
robotInfos = new List<DuelFishingData>();
int rodIndex = UnityEngine.Random.Range(0, eventSoloRobot.RodId.Count);
var rodData = _tables.TbRodData.GetOrDefault(eventSoloRobot.RodId[rodIndex]);
int rodLevel = eventSoloRobot.RodLevel[rodIndex];
int star = eventSoloRobot.RodStar[rodIndex];
if (star < 0)
{
star = 0;
}
robotRod = new DuelRodData
{
rodId = rodData.ID,
rodLevel = rodLevel,
rodStar = star
};
for (int i = 0; i < FishItemIDs.Count; i++)
{
GetRobotInfo(FishItemIDs[i], _curMapData, rodData.ID, star);
}
//打印 机器人id、杯数、鱼竿id鱼竿等级、鱼竿星级、鱼卡等级
Debug.Log($"机器人ID:{robotId} 杯数:{eventSoloRobot.Trophy} 鱼杆id:{rodData.ID} 鱼杆等级:{rodLevel} 鱼杆星级:{star} 鱼卡等级:{string.Join(',', carLv)}");
}
List<int> SetSelfModel()
{
List<int> carLv = new List<int>();
PlayerFishData playerFishData = GContext.container.Resolve<PlayerFishData>();
for (int i = 0; i < FishItemIDs.Count; i++)
{
Item item = _tables.TbItem.DataMap[FishItemIDs[i]];
carLv.Add(playerFishData.GetDataLevel(item.RedirectID));
}
IUserService user = GContext.container.Resolve<IUserService>();
selfModel = new DuelPlayerModel();
selfModel.Init(user.UserId, user.DisplayName, user.AvatarUrl, duelData.progress, magnification, eventSoloConfig.MaxFailCount);
selfChatModel = new DuelPlayerChatModel();
return carLv;
}
async Task<List<int>> GetRandmMap()
{
//int curMapId = duelData.mapId;
var mapDatas = _tables.TbMapData.DataList;
var lastMapID = GContext.container.Resolve<PlayerData>().lastMapId;
int maxMapID = _tables.TbMapData.DataList[^1].ID + eventSolomain.MaxMapId;
if (lastMapID < maxMapID)
{
maxMapID = lastMapID;
}
if (maxMapID < mapDatas[0].ID)
{
maxMapID = mapDatas[0].ID;
}
//非当前地图
var mapIDs = new List<int>();
for (int i = 0; i < mapDatas.Count; i++)
{
if (mapDatas[i].ID <= maxMapID)
{
//if (mapDatas[i].ID != curMapId)
//{
mapIDs.Add(mapDatas[i].ID);
//}
}
else
{
break;
}
}
List<int> ints = new List<int>();
if (mapIDs.Count <= 1)
{
ints.Add(maxMapID);
}
else
{
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
for (int i = 0; i < mapIDs.Count; i++)
{
int id = mapIDs[i];
var mapData = _tables.TbMapData.DataMap[id];
bool isCanEnter = await loadResourceService.CheckResource(mapData.EnvName);
if (isCanEnter)
{
ints.Add(id);
}
}
}
return ints;
}
void GetRobotInfo(int itemId, MapData _curMapData, int rodId, int star)
{
//获得积分
DuelFishingData robotInfo;
Item item = _tables.TbItem.DataMap[itemId];
if (item.Quality == 4 || item.Quality == 5)
{
float prob = item.Quality == 4 ? enemySolomain.HugeFishLoseProb : enemySolomain.GiantFishLoseProb;
int probCount = eventSoloConfig.MaxFailCount;
for (int i = 0; i < probCount; i++)
{
float fishLoseProb = UnityEngine.Random.Range(0, 1f);
///失败区间内
if (fishLoseProb < prob)
{
robotInfo = RobotInfo(itemId);
robotInfos.Add(robotInfo);
}
else
{
break;
}
if (i == probCount - 1)
{
///如果是最后一次,彻底失败
return;
}
}
}
robotInfo = RobotInfo(itemId);
robotInfos.Add(robotInfo);
RobotInfoSucceed(robotInfo, _curMapData, rodId, star);
}
DuelFishingData RobotInfo(int itemId)
{
DuelFishingData robotInfo = new DuelFishingData();
robotInfo.fishItemId = itemId;
Item item = _tables.TbItem.DataMap[itemId];
var slienceTime = enemySolomain.SlienceTime;
robotInfo.slienceTime = UnityEngine.Random.Range(slienceTime[0], slienceTime[1]);
float fishingTime = enemySolomain.FishTime[0];
if (item.Quality < enemySolomain.FishTime.Count)
{
fishingTime = enemySolomain.FishTime[item.Quality - 1];
}
fishingTime = fishingTime * (1 + UnityEngine.Random.Range(-enemySolomain.FishTimeRandomRange, enemySolomain.FishTimeRandomRange));
robotInfo.fishingTime = (int)fishingTime;
return robotInfo;
}
void RobotInfoSucceed(DuelFishingData robotInfo, MapData _curMapData, int rodId, int star)
{
robotInfo.isWin = true;
Item item = _tables.TbItem.DataMap[robotInfo.fishItemId];
var fishData = _tables.TbFishData.DataMap[item.RedirectID];
DropPackageList dropPackageList = _tables.TbDrop[fishData.DropID].DropList;
float proficiency = dropPackageList.DropCountList[0];
proficiency *= fishData.PointExtraParam * UnityEngine.Random.Range(1 - fishData.WeightRandom, 1 + fishData.WeightRandom);
float cardBonus = 0;
int cardIndex = _curMapData.FishList.IndexOf(fishData.ID);
if (cardIndex >= 0)
{
var CardLevelList = eventSoloRobot.CardLevel;
cardIndex %= CardLevelList.Count;
var CardLevel = CardLevelList[cardIndex];
int mapIndex = (_curMapData.ID - 1) % 100;
mapIndex = mapIndex % CardLevel.Count;
int cardLevel = CardLevel[mapIndex];
if (cardLevel > 0)
{
cfg.FishCard fishCard = _tables.TbFishCard[fishData.FishCardID];
cardBonus = fishCard.WeightMagList[cardLevel - 1]; //重量加成参数 = 针对特定鱼的重量加成 + 基于基础重量的重量加成 + 总体重量加成初始为0
}
}
PlayerFishData playerFishData = GContext.container.Resolve<PlayerFishData>();
Dictionary<RodPerkType, string> RodPerkDic = playerFishData.GetRodPerk(rodId, star);
float rodBonus = GetCurRodBuff(RodPerkDic, fishData.Quality);
float bonus = (1 + cardBonus) * (1 + rodBonus);
robotInfo.fishCardAdd = cardBonus;
robotInfo.fishRodAdd = rodBonus;
robotInfo.point = (int)(proficiency * bonus);
}
#endregion
#region
public void Start()
{
selfModel.Start();
enemyModel.Start();
}
public void StartLastRecordedTime()
{
selfModel.StartLastRecordedTime();
enemyModel.StartLastRecordedTime();
}
public void SetRodData(int id)
{
PlayerFishData playerFishData = GContext.container.Resolve<PlayerFishData>();
DuelRodData duelRod = new DuelRodData
{
rodId = id,
rodLevel = playerFishData.GetRodLevel(id),
rodStar = playerFishData.GetRodPiece(id)
};
SendRodData(duelRod);
}
public void StopFishing(int fishID, int point, float fishCardAdd, float fishRodAdd)
{
isSettle = false;
FishInfoData data = enemyModel.GetDuelFishingData(selfModel.index, fishID, point, fishCardAdd, fishRodAdd);
bool gameOver = selfModel.StopFishing(data);
enemyChatModel.SendMessage((int)RobotDuelChatType.OpponetFishingSuccess);
if (gameOver)
{
SetFishingOver(1);
}
//刷新view
AwaitSettle();
}
public void OnFishingChangeStateEvent(FishingChangeState fishState, int id)
{
IDuelPlayerModel model = selfModel;
switch (fishState)
{
case FishingChangeState.Cast:
model.CastRod(id);
break;
//case FishingChangeState.StartFishing:
// model.StartFishing();
// break;
case FishingChangeState.FishingSuccess:
break;
case FishingChangeState.FishingFail:
bool gameOver = model.StopFishing(new FishInfoData());
enemyChatModel.SendMessage((int)RobotDuelChatType.OpponetFishingFail);
if (gameOver)
{
SetFishingOver(1);
}
break;
}
//view刷新
}
async void AwaitSettle()
{
await Awaiters.Seconds(3);
isSettle = true;
}
/// <summary>
///
/// </summary>
/// <param name="over">== 1 自己 == 2钓友</param>
void SetFishingOver(int over)
{
GameOverState++;
Debug.Log("SetFishingOver:" + over);
//倒计时五秒结束
GameOver.Value = over;
}
#endregion
/// <summary>
/// PVP 鱼竿词条加成
/// </summary>
/// <param name="RodPerkDic"></param>
/// <returns></returns>
public float GetCurRodBuff(Dictionary<RodPerkType, string> rodPerkDic, int quality)
{
MapData mapData = _tables.TbMapData.DataMap[MapId];
if (mapData == null)
{
return 0;
}
float add = 0;
PlayerFishData playerFishData = GContext.container.Resolve<PlayerFishData>();
//水域类型加成
switch (mapData.WaterType)
{
case SceneWaterType.ShallowSea:
case SceneWaterType.DeepSea:
add += playerFishData.GetRodPerkValue(RodPerkType.ExtraDuelPointsWaterType_2, rodPerkDic);
break;
case SceneWaterType.Lake:
case SceneWaterType.River:
add += playerFishData.GetRodPerkValue(RodPerkType.ExtraDuelPointsWaterType_1, rodPerkDic);
break;
default:
break;
}
//天气类型加成
if (WeatherType == 0)
{
add += playerFishData.GetRodPerkValue(RodPerkType.ExtraDuelPointsWeatherType_1, rodPerkDic);
}
else
{
add += playerFishData.GetRodPerkValue(RodPerkType.ExtraDuelPointsWeatherType_2, rodPerkDic);
}
//鱼品质加成
switch (quality)
{
case 1:
add += playerFishData.GetRodPerkValue(RodPerkType.ExtraDuelPointsFishQuality_1, rodPerkDic);
break;
case 2:
add += playerFishData.GetRodPerkValue(RodPerkType.ExtraDuelPointsFishQuality_2, rodPerkDic);
break;
case 3:
add += playerFishData.GetRodPerkValue(RodPerkType.ExtraDuelPointsFishQuality_3, rodPerkDic);
break;
case 4:
add += playerFishData.GetRodPerkValue(RodPerkType.ExtraDuelPointsFishQuality_4, rodPerkDic);
break;
case 5:
add += playerFishData.GetRodPerkValue(RodPerkType.ExtraDuelPointsFishQuality_5, rodPerkDic);
break;
default:
break;
}
return add;
}
/*
RodData.DuelPower对应每个鱼竿每一级的基础战斗力
RodAscendPerk.DuelPowerParam对应属性的属性的对决战斗力参数
总战力 = 鱼竿当前等级的基础战力 *1 + 生效特性1 * 该属性的对决战斗力参数 + 生效特性2 * 该属性的对决战斗力参数)
*/
public void GetDuelPerk(RodItemData rodItemData)
{
MapData mapData = _tables.TbMapData.DataMap[MapId];
var playerFishData = GContext.container.Resolve<PlayerFishData>();
Dictionary<int, string> RodPerkList = playerFishData.GetRodDuelPerk(rodItemData.config.ID, rodItemData.star);
rodItemData.SetRodPower();
float param = 1;
foreach (var perk in RodPerkList)
{
var rodEngancePerk = _tables.TbRodAscendPerk.GetOrDefault(perk.Key);
bool hasValue = false;
switch (rodEngancePerk.PerkType)
{
case RodPerkType.ExtraDuelPointsWaterType_1:
hasValue = mapData.WaterType == SceneWaterType.Lake || mapData.WaterType == SceneWaterType.River;
break;
case RodPerkType.ExtraDuelPointsWaterType_2:
hasValue = mapData.WaterType == SceneWaterType.ShallowSea || mapData.WaterType == SceneWaterType.DeepSea;
break;
case RodPerkType.ExtraDuelPointsWeatherType_1:
hasValue = WeatherType == 0;
break;
case RodPerkType.ExtraDuelPointsWeatherType_2:
hasValue = WeatherType == 1;
break;
case RodPerkType.ExtraDuelPointsFishQuality_5:
hasValue = hasRedFish;
break;
default:
hasValue = true;
break;
}
rodItemData.traitIDs.Add(perk.Key);
rodItemData.noactions.Add(hasValue);
if (hasValue)
{
string value = perk.Value;
if (!string.IsNullOrEmpty(value) && !value.Contains('|'))
{
param += float.Parse(value) * _tables.TbRodAscendPerk.GetOrDefault(perk.Key)?.DuelPowerParam ?? 0;
}
}
}
rodItemData.RodPower = (int)(rodItemData.RodPower * param);
}
void SetTraitID()
{
TraitID = new List<int>();
MapData mapData = _tables.TbMapData.DataMap[MapId];
switch (mapData.WaterType)
{
case SceneWaterType.ShallowSea:
case SceneWaterType.DeepSea:
//RodPerkType.ExtraDuelPointsWaterType_2
TraitID.Add(5002);
break;
case SceneWaterType.Lake:
case SceneWaterType.River:
//RodPerkType.ExtraDuelPointsWaterType_1
TraitID.Add(5001);
break;
default:
break;
}
//天气类型加成
if (WeatherType == 0)
{
//RodPerkType.ExtraDuelPointsWeatherType_1
TraitID.Add(5011);
}
else
{
//RodPerkType.ExtraDuelPointsWeatherType_2
TraitID.Add(5012);
}
//鱼王,可能也会有小卡拉米
if (hasRedFish)
{
TraitID.Add(5025);
}
}
}
public class DuelData
{
public int eventID;
public int rewardEventID;
public int preProgress;
public int progress;
public int tickets;
public int soloTimes;
public int mapId;
public int multiple;
public int rePVPToken;
public int pvpShopTimeDay = -1;
public Dictionary<int, int> buyItem = new Dictionary<int, int>();
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e038fa523119e1149861a2c4fc31404a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,361 @@
using asap.core;
using GameCore;
using LitJson;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
public struct RodStateEvent
{
public int RoleID;
}
public partial class FishingDuelManager
{
public int seed;
public int WeatherType { get; private set; } = 0;//0晴天 1雨天
bool hasRedFish;//0无红鱼 1有红鱼
public bool IsRobot { get; private set; }
public int MachingState = 0;// 1一方准备好 2双方准备好
public int SceneState = 0;// 1一方准备好 2双方准备好
public int RodState = 0;// 1一方准备好 2双方准备好
public int GameOverState = 0;//1一方钓完 2双方钓完
bool IsCancel = false;
public async void StartMaching()
{
selfIsLastFish = false;
//随机地图
//等待匹配成功,或者匹配失败(机器人),开始对战
//传入段位可匹配段位列表杯数选择倍率地图列表随机种子seed
int rank = eventSolomain.RankTier;
List<int> matchTierList = eventSolomain.MatchTierList;
int trophy = duelData.progress;
int mag = magnification;
List<int> mapIDs = await GetRandmMap();
seed = new System.Random().Next();
MachingState = 0;
SceneState = 0;
RodState = 0;
GameOverState = 0;
IsCancel = false;
bool isSuccess = await MachingSuccess();
if (IsCancel)
{
return;
}
//DuelFishingDataSave duelFishingDataSave = null;
if (!isSuccess)
{
//if (duelFishingDataSave != null)
//{
// duelData.mapId = duelFishingDataSave.mapId;
// seed = duelFishingDataSave.seed;
// enemySolomain = _tables.TbEventSolomain.DataMap[duelFishingDataSave.rankTier];
//}
//else
{
if (mapIDs.Count == 1)
{
duelData.mapId = mapIDs[0];
}
else
{
duelData.mapId = mapIDs[UnityEngine.Random.Range(0, mapIDs.Count)];
}
int robotTier = eventSolomain.MatchTierList[UnityEngine.Random.Range(0, eventSolomain.MatchTierList.Count)];
enemySolomain = _tables.TbEventSolomain.DataMap[robotTier];
}
//============匹配失败===============
//============匹配失败===============
}
WeatherType = new System.Random(seed).Next(0, 2);
GetFishItemID(new System.Random(seed));
SetTraitID();
List<int> carLevels = SetSelfModel();
if (isSuccess)
{
IsRobot = false;
}
else
{
IsRobot = true;
//if (duelFishingDataSave != null)
//{
// PlayerRobot(duelFishingDataSave);
//}
//else
{
MachRobot();//匹配机器人
}
}
SendFishCardLevel(carLevels);
Debug.Log($"本局鱼Seed{seed} WeatherType {WeatherType}");
}
public void CancelMaching()
{
//发送取消请求
IsCancel = true;
}
#region
//选鱼杆之后再传鱼杆ID、鱼杆等级、鱼杆星级等数据
//SetEnemyRodData(rodData.ID, rodLevel, star);
async Task<bool> MachingSuccess()
{
double maxMatchTime = eventSoloConfig.MaxMatchTime * 1000;
while (maxMatchTime > 0)
{
DateTime loopStartTime = DateTime.Now;
try
{
//if (NetworkManager.Instance.HasMachingSuccess())
//{
// duelData.mapId = NetworkManager.Instance.GetMachingMapID();
// enemySolomain = NetworkManager.Instance.GetMachingEnemySolomain();
// seed = NetworkManager.Instance.GetMachingSeed();
//enemyModel = new DuelPlayerModel();
//enemyModel.Init(ID, Name, Avatar,Mag,eventSoloConfig.MaxFailCount);
//enemyChatModel = new DuelChatModel();//真人
//enemyChatModel = new DuelRobotChatModel();//复刻真人
// return true;
//}
}
catch (Exception ex)
{
Debug.LogError($"匹配检查过程中发生异常:{ex.Message}");
// 可根据需求选择继续重试仅打日志或终止匹配return false
// return false;
}
TimeSpan loopElapsed = DateTime.Now - loopStartTime;
maxMatchTime -= loopElapsed.TotalMilliseconds;
if (IsCancel || maxMatchTime < 1000)
{
return false;
}
await Task.Delay(1000);
maxMatchTime -= 1000f;
if (IsCancel || maxMatchTime < 0)
{
return false;
}
}
return false;
}
//=========同步鱼卡信息==========
void SendFishCardLevel(List<int> carLevels)
{
selfModel.Init(carLevels);
//传输鱼卡等级
if (!IsRobot)
{
//NetworkManager.Instance.SendFishCardLevel(carLevels);
}
MachingState++;
}
//获得对手鱼卡等级
void ReceiveEnemyFishCardLevel(List<int> carLevels)
{
enemyModel.Init(carLevels);
ReceiveEnemyRodData(_tables.TbRodData.DataList[0].ID, 0, 0);//默认鱼杆信息
MachingState++;
}
//=========同步鱼卡信息==========
//=========同步鱼竿信息==========
public void SendRodData(DuelRodData duelRod)
{
selfModel.SetRodData(duelRod);
if (!IsRobot)
{
//NetworkManager.Instance.SendRodData(id, rodLevel, rodStar);
}
RodState++;
GContext.Publish(new RodStateEvent() { RoleID = 0 });
}
//获得对手鱼竿等级
public void ReceiveEnemyRodData(DuelRodData duelRod)
{
enemyModel.SetRodData(duelRod);
RodState++;
GContext.Publish(new RodStateEvent() { RoleID = 1 });
}
//=========同步鱼竿信息==========
//=========同步场景完成信息==========
public void SendChangeScene()
{
if (!IsRobot)
{
//NetworkManager.Instance.SendSceneData(mapId);
}
SceneState++;
}
public void ReceiveEnemyChangeScene()
{
SceneState++;
}
//=========同步场景完成信息==========
#endregion
public void ReceiveEnemyRodData(int id, int rodLevel, int rodStar)
{
DuelRodData duelRod = new DuelRodData
{
rodId = id,
rodLevel = rodLevel,
rodStar = rodStar
};
enemyModel.SetRodData(duelRod);
}
/// <summary>
/// 对手操作
/// </summary>
/// <param name="robotFishing"></param>
public void ReceiveFishingQueue(RobotFishingQueue robotFishing)
{
bool gameOver;
switch (robotFishing.changeState)
{
case FishingChangeState.Cast:
enemyModel.CastRod(robotFishing.fishItemId);
if (enemyModel.IsLastFish() && !selfModel.IsLastFish())
{
enemyChatModel.SendMessage((int)RobotDuelChatType.FirstLastFishStart);
ReceiveFishingEvent receiveFishingEvent = new ReceiveFishingEvent();
receiveFishingEvent.value = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_38", enemyModel.PlayerName);
GContext.Publish(receiveFishingEvent);
}
break;
//case FishingChangeState.StartFishing:
// enemyModel.StartFishing();
// break;
case FishingChangeState.FishingSuccess:
FishInfoData data = selfModel.GetDuelFishingData(enemyModel.index,
robotFishing.fishItemId,
robotFishing.point,
robotFishing.fishCardAdd,
robotFishing.fishingRodAdd);
gameOver = enemyModel.StopFishing(data);
if (gameOver)
{
SetFishingOver(2);
enemyChatModel.SendMessage((int)RobotDuelChatType.FirstLastFishSuccess);
}
else
{
enemyChatModel.SendMessage((int)RobotDuelChatType.FishingSuccess);
}
break;
case FishingChangeState.FishingFail:
gameOver = enemyModel.StopFishing(new FishInfoData());
if (gameOver)
{
SetFishingOver(2);
}
break;
default:
break;
}
}
#region
public void SendQuickMessage(int id)
{
//本地转发
selfChatModel.SendMessage(id);
//远端转发
if (!IsRobot)
{
//NetworkManager.Instance.SendQuickMessage(id);
}
}
//接收对手消息
public void ReceiveQuickMessage(int id)
{
enemyChatModel.ReceiveMessage(id);
}
#endregion
#region
#endregion
//往服务器传数据
public void SendDuelFishingData()
{
var solomain = eventSolomain;
if (enemySolomain.RankTier < eventSolomain.RankTier)
{
solomain = enemySolomain;
}
List<DuelFishingData> DuelFishingDatas = new List<DuelFishingData>();
foreach (var data in selfModel.DuelFishingDatas)
{
if (data.fishItemId > 0)
{
DuelFishingData showData = new DuelFishingData
{
slienceTime = data.slienceTime,
//castingTime = data.castingTime,
fishingTime = data.fishingTime,
isWin = data.isWin,
fishItemId = data.fishItemId,
point = data.point,
failNum = data.failNum,
fishCardAdd = data.fishCardAdd,
fishRodAdd = data.fishRodAdd
};
DuelFishingDatas.Add(showData);
}
}
DuelFishingDataSave duelFishingDataSave = new DuelFishingDataSave
{
rankTier = solomain.RankTier,
mapId = duelData.mapId,
seed = seed,
playerID = selfModel.PlayerID,
setRodTime = selfModel.SetRodTime,
playerName = selfModel.PlayerName,
carLevels = selfModel.CarLevels,
playerAvatar = selfModel.PlayerAvatar,
rankScore = selfModel.RankScore,
mag = selfModel.Mag,
rodId = selfModel.RodId,
rodLevel = selfModel.RodLevel,
rodStar = selfModel.RodStar,
selfDuelFishingDatas = DuelFishingDatas
};
string json = JsonMapper.ToJson(duelFishingDataSave);
Debug.Log("本局上传对战数据" + json);
//NetworkManager.Instance.SendDuelFishingData(json);
}
}
public class ReceiveFishingEvent
{
public string value;
}
//往服务器存褚操作数据
public class DuelFishingDataSave
{
public int rankTier { get; set; }
public int mapId { get; set; }
public int seed { get; set; }
public string playerID { get; set; }
public int setRodTime { get; set; } //设置鱼竿时间
public string playerName { get; set; }
public List<int> carLevels { get; set; } = new List<int>(6);
public string playerAvatar { get; set; }
public int rankScore { get; set; }
public int mag { get; set; } = 1;
public int rodId { get; set; }
public int rodLevel { get; set; }
public int rodStar { get; set; }
public List<DuelFishingData> selfDuelFishingDatas { get; set; }
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 75f83cfaa2572884b9a08adb88a32dab
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,416 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using asap.core;
using cfg;
using DG.Tweening;
using game;
using Game;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class FishingDuelRewardPanel : BasePanel
{
Tables _tables;
private CanvasGroup canvasGroup;
private CanvasGroup root_success;
private GameObject root_fail;
private Button playButton;
private TMP_Text text_title;
private TMP_Text text_weight_num;
private Image img_fishTag;
private GameObject station_powerful;
private GameObject station_weekly;
private GameObject station_nopush;
public TMP_Text text_info;
private Button btn_green;
TMP_Text text_tryagain_num;
int curRateIndex;
public UIDrag dragImage;
Animator anim_panel;
public float fishRotateSpeed = 8f; //鱼旋转速度
TMP_Text text_num_fishcard;
TMP_Text text_num_rod;
int fishID;
FishingData fishingData;
//AddCash等待时间
public float waitTime1 = 0.2f;
//AddCash持续时间
public float duration1 = 1f;
public float waitTime2 = 0.2f;
public float duration2 = 1f;
IUIService uiService;
PlayerFishData playerFishData;
PlayerData playerData;
FishingDuelManager fishingDuelManager;
private void Awake()
{
fishingDuelManager = GContext.container.Resolve<FishingDuelManager>();
uiService = GContext.container.Resolve<IUIService>();
dragImage = transform.Find("root_success/UIDrag").GetComponent<UIDrag>();
canvasGroup = GetComponent<CanvasGroup>();
text_num_fishcard = transform.Find("root_success/info/fishcard/text_num").GetComponent<TMP_Text>();
text_num_rod = transform.Find("root_success/info/rod/text_num").GetComponent<TMP_Text>();
root_success = transform.Find("root_success").GetComponent<CanvasGroup>();
img_fishTag = transform.Find("root_success/info/name/icon_tag").GetComponent<Image>();
anim_panel = GetComponent<Animator>();
text_title = transform.Find("root_success/info/name/text_name").GetComponent<TMP_Text>();
text_weight_num = transform.Find("root_success/info/score/text_point").GetComponent<TMP_Text>();
playButton = transform.Find("root_success/info/btn_play/btn_green").GetComponent<Button>();
root_fail = transform.Find("root_fail").gameObject;
text_info = transform.Find("root_fail/bg_info/text_info").GetComponent<TMP_Text>();
station_powerful = transform.Find("root_fail/station_powerful").gameObject;
station_weekly = transform.Find("root_fail/station_weekly").gameObject;
station_nopush = transform.Find("root_fail/station_nopush").gameObject;
btn_green = transform.Find("root_fail/btn_tryagain/btn_green").GetComponent<Button>();
text_tryagain_num = transform.Find("root_fail/btn_tryagain/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
_tables = GContext.container.Resolve<Tables>();
playerData = GContext.container.Resolve<PlayerData>();
fishingData = GContext.container.Resolve<FishingData>();
if (fishingData.fishingResult == FishingResult.Success)
{
anim_panel.Play("info_show_1");
}
}
protected override void Start()
{
base.Start();
SetFishingFocalVolume(50);
playButton.onClick.AddListener(OnClickInHome);
btn_green.onClick.AddListener(OnSucceed);
dragImage.OnPointerDownCall += () =>
{
GameEventMgr.Instance.Raise(GameEvents.EventFishingPlay);
};
StartDoRotate();
dragImage.OnBeginDragCall += OnBeginDragCall;
dragImage.OnDragCall += OnDragFish;
dragImage.OnEndDragCall += StartDoRotate;
OnShow();
}
void StartDoRotate()
{
GContext.Publish(new FishRotateEvent(0, 1, fishingData.rodType));
}
void OnDragFish(PointerEventData eventData)
{
float x = Input.GetAxis("Mouse X") * fishRotateSpeed;
GContext.Publish(new FishRotateEvent(x, 2, fishingData.rodType));
}
void OnBeginDragCall()
{
GContext.Publish(new FishRotateEvent(0, 0, fishingData.rodType));
}
void OnShow()
{
playerFishData = GContext.container.Resolve<PlayerFishData>();
fishingData.IsFree = true;
if (!string.IsNullOrEmpty(fishingData.curFishData.AudioDuelRewardPanel))
{
GContext.Publish(new EventFishingSound(fishingData.curFishData.AudioDuelRewardPanel));
}
fishID = fishingData.curFishData.ID;
if (fishingData.fixedFishList != null)
{
fishID = fishingData.fixedFishList.RealFishID;
}
if (fishingData.fishingResult == FishingResult.Success)
{
root_fail.SetActive(false);
root_success.gameObject.SetActive(fishingData.IsGeneralFish());
Success();
StartCoroutine(Blur());
#if AGG
using (var e = GEvent.GameEvent("pvp_fishing"))
{
int currentRodLevel = playerFishData.GetRodLevel(playerData.equipRodID);
int currentRodStar = playerFishData.GetRodPiece(playerData.equipRodID);
e.AddContent("map_id", fishingData.MapId)
.AddContent("fishing_state", 1)
.AddContent("fish_id", fishID)
.AddContent("fish_time", fishingData.GetFishingTimer())
.AddContent("charge_count", GContext.container.Resolve<PlayerShopData>().GetBuyPaymentAmount())
.AddContent("hook_count", playerData.GetEnergyRM())
.AddContent("available_hook_num", playerData.Energy)
.AddContent("available_cash_num", playerData.gold)
.AddContent("jerking_count", fishingData.jerking_count)
.AddContent("stickle_state", fishingData.stickle_state)
.AddContent("current_rod", playerData.equipRodID)
.AddContent("current_rod_level", currentRodLevel)
.AddContent("current_rod_star", currentRodStar)
.AddContent("fish_card_lv", fishingData.CardLevel)
.AddContent("reward_cash", 0)
.AddContent("retry_ways", fishingData.retry_ways)
.AddContent("retry", fishingData.IsRetry);
var _socialData = GContext.container.Resolve<ClubService>();
if (_socialData.myClubInfo != null)
{
e.AddContent("guild_id", _socialData.myClubInfo.id);
}
else
{
e.AddContent("guild_id", 0);
}
}
#endif
}
else
{
root_success.gameObject.SetActive(false);
root_fail.SetActive(true);
//#if AGG
using (var e = GEvent.GameEvent("pvp_fishing"))
{
int currentRodLevel = playerFishData.GetRodLevel(playerData.equipRodID);
int currentRodStar = playerFishData.GetRodPiece(playerData.equipRodID);
e.AddContent("map_id", fishingData.MapId)
.AddContent("fishing_state", 2)
.AddContent("fishing_failed_reason", (int)fishingData.fishingResult)
.AddContent("fish_id", fishID)
.AddContent("fish_time", fishingData.GetFishingTimer())
.AddContent("charge_count", GContext.container.Resolve<PlayerShopData>().GetBuyPaymentAmount())
.AddContent("hook_count", playerData.GetEnergyRM())
.AddContent("available_hook_num", playerData.Energy)
.AddContent("available_cash_num", playerData.gold)
.AddContent("jerking_count", fishingData.jerking_count)
.AddContent("stickle_state", fishingData.stickle_state)
.AddContent("current_rod", playerData.equipRodID)
.AddContent("current_rod_level", currentRodLevel)
.AddContent("current_rod_star", currentRodStar)
.AddContent("fish_card_lv", fishingData.CardLevel)
.AddContent("retry_ways", fishingData.retry_ways)
.AddContent("retry", fishingData.IsRetry);
var _socialData = GContext.container.Resolve<ClubService>();
if (_socialData.myClubInfo != null)
{
e.AddContent("guild_id", _socialData.myClubInfo.id);
}
else
{
e.AddContent("guild_id", 0);
}
}
//#endif
OnFail();
}
fishingData.IsRetry = false;
}
IEnumerator Blur()
{
//Pulling 结束后
float time = fishingData.fishingBehaviorConf.blurDelay;
yield return new WaitForSeconds(time);
//ConvertTools.SetFSBlur(true, fishingData.fishingBehaviorConf.blurDistanceZ);
EnableFishingBlur(true);
}
//钓鱼成功
void Success()
{
//GContext.container.Resolve<GuideDataCenter>().AddIndex(true);
var PointBonus = playerFishData.GetRodAscendStats();
DropPackageList dropPackageList = _tables.TbDrop[fishingData.curFishData.DropID].DropList;
float proficiency = dropPackageList.DropCountList[0] * fishingData.random;
SetProficiency(proficiency, PointBonus);
text_title.text = LocalizationMgr.GetText(fishingData.curFishData.Name_l10n_key);
curRateIndex = 0;
uiService.SetImageSprite(img_fishTag, "icon_fish_rate_tag_" + fishingData.curFishData.Quality);
_ = StartCoroutine(AddCash());
//Show Fish Info UI
VibrationData();
}
async void VibrationData()
{
await Awaiters.Seconds(2.5f);
if (curRateIndex >= _tables.TbGlobalConfig.RankVibration.Count)
curRateIndex = _tables.TbGlobalConfig.RankVibration.Count - 1;
int hapticType = _tables.TbGlobalConfig.RankVibration[curRateIndex];
if (hapticType == 1)
{
GContext.Publish(new VibrationData(HapticTypes.LightImpact));
}
else if (hapticType == 2)
{
GContext.Publish(new VibrationData(HapticTypes.MediumImpact));
}
else if (hapticType == 3)
{
GContext.Publish(new VibrationData(HapticTypes.HeavyImpact));
}
}
private float _fishScore;
void SetFishingFocalVolume(float value)
{
var stage = RootCtx.container.Resolve<IStageService>()?.GetStage("FishingStage");
if (stage != null && stage.Id == "FishingStage")
{
var act = stage.CurrentAct as FishingAct;
if (act != null)
act.SetFishingFocalVolume(value);
}
}
private void EnableFishingBlur(bool enable)
{
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(enabled);
}
}
IEnumerator AddCash()
{
text_weight_num.text = "";
var progress = 0f;
yield return Awaiters.Seconds(waitTime1);
DOTween.To(() => progress, x => progress = x, 1, duration1).OnUpdate(() =>
{
text_weight_num.text = ConvertTools.GetNumberString2((int)(_fishScore * progress));
}).SetId("AddCash");
}
//设置熟练度
void SetProficiency(float proficiency, float proficiencyExtra)
{
float extra1 = fishingData.WeightIncEvent;
float extra2 = 0;
if (!fishingData.IsNewItemFish())
{
proficiencyExtra = (1 + fishingData.WeightIncEvent) * (1 + proficiencyExtra);
}
else
{
proficiencyExtra = (1 + proficiencyExtra) * (1 + playerData.benefitsEventFishCashMag);
}
if (fishingDuelManager != null)
{
int star = playerFishData.GetRodPiece(fishingData.fishRodData.ID);
Dictionary<RodPerkType, string> RodPerkDic = playerFishData.GetRodPerk(fishingData.fishRodData.ID, star);
extra2 = fishingDuelManager.GetCurRodBuff(RodPerkDic, fishingData.curFishData.Quality);
proficiencyExtra *= (1 + extra2);
}
proficiency *= proficiencyExtra;
proficiency = Mathf.RoundToInt(proficiency);
if (fishingDuelManager != null)
{
fishingDuelManager.StopFishing(fishingData.fishItem.ID, (int)proficiency, extra1, extra2);
}
text_num_fishcard.text = extra1.ToString("P0");
text_num_rod.text = extra2.ToString("P0");
_fishScore = proficiency;
}
void OnFail()
{
text_tryagain_num.text = LocalizationMgr.GetText("UI_FishingRewardPanel_101022");
if (fishingDuelManager != null)
{
int RetryNum = fishingDuelManager.CurrentRetryNum;
if (RetryNum > 1)
{
text_tryagain_num.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_50", RetryNum - 1);
}
fishingDuelManager.OnFishingChangeStateEvent(FishingChangeState.FishingFail, fishingData.fishItem.ID);
}
text_info.text = LocalizationMgr.GetFormatTextValue("UI_FishingRewardPanel_101008", fishingData.curFishData.Quality);
station_powerful.SetActive(false);
station_weekly.SetActive(false);
station_nopush.SetActive(false);
OnClickAdvertClose();
}
//第一次失败返回
void OnClickAdvertClose()
{
switch (fishingData.fishingResult)
{
case FishingResult.Success:
break;
case FishingResult.Fail1:
station_powerful.SetActive(true);
break;
case FishingResult.Fail2:
station_weekly.SetActive(true);
break;
default:
station_nopush.SetActive(true);
break;
}
}
void OnClickInHome()
{
StopAllCoroutines();
canvasGroup.blocksRaycasts = false;
GContext.Publish(new ResetFishingStatusEvent());
GContext.Publish(new IsRecastEvent());
UIManager.Instance.DestroyUI(UITypes.FishingDuelRewardPanel);
RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
GContext.Publish(restartShowHomeUIEvent);
}
protected override void OnDestroy()
{
//ConvertTools.SetFSBlur(false);
EnableFishingBlur(false);
DOTween.Kill("AddCash");
base.OnDestroy();
}
async void OnSucceed()
{
canvasGroup.blocksRaycasts = false;
GContext.Publish(new ResetFishingStatusEvent() { restart = true });
GContext.Publish(new IsRecastEvent() { isRecast = true });
await UIManager.Instance.ShowUI(UITypes.FishingPanel);
UIManager.Instance.DestroyUI(UITypes.FishingDuelRewardPanel);
RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
restartShowHomeUIEvent.isPopupStore = true;
GContext.Publish(restartShowHomeUIEvent);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ec456fa9e093a07489df01dc995ffa69
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
public interface IDuelChatModel
{
public int RoleID { get; set; } //对战聊天视图
//接收消息
void ReceiveMessage(int message);
//发送消息
void SendMessage(int message);
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 98cce676053d670468987e6b671e3dea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
using System.Collections.Generic;
public interface IDuelPlayerModel
{
int RoleID { get; set; }
string PlayerID { get; set; }
string PlayerName { get; set; }
string PlayerAvatar { get; set; }
List<int> CarLevels { get; set; }
int RankScore { get; set; }
int Mag { get; set; } //倍率
int RodId { get; set; } //鱼竿ID
int RodLevel { get; set; } //鱼竿等级
int RodStar { get; set; } //鱼竿星级
int CurrentPTS { get; set; }
int CurrentFailNum { get; set; }
List<DuelFishingData> DuelFishingDatas { get; set; } //对战数据
void Init(string playerID, string playerName, string playerAvatar, int randScore, int mag, int maxFail);
void Start();
void SetRodData(DuelRodData rodData);
//抛竿
void CastRod(int fishID);
//起杆
//void StartFishing();
//结算
bool StopFishing(FishInfoData fishInfoData);
List<DuelFishingData> GetShowDatas();
}
public struct DuelRodData
{
public int rodId; //鱼竿ID
public int rodLevel; //鱼竿等级
public int rodStar; //鱼竿星级
}
public struct FishInfoData
{
public int fishItemId; //鱼ID
public int point; //分数
public float fishCardAdd; //鱼卡加成
public float fishRodAdd; //鱼竿加成
public bool higher; //是否高分
public bool higherCard; //是否高分
public bool higherRod; //是否高分
}
public class DuelFishingData
{
//静默时间,从结算到起杆时间
public int slienceTime { get; set; }
//抛竿到起杆时间
//public int castingTime { get; set; }
//抛竿时间到钓鱼时间
public int fishingTime { get; set; }
public bool isWin { get; set; }
public int fishItemId { get; set; }
public int point { get; set; }
public int failNum { get; set; } //失败次数
//鱼卡加成
public float fishCardAdd { get; set; } //鱼卡加成
public float fishRodAdd { get; set; } //鱼杆加成
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bb1b7f5fdc075af4995ee3e92d0e6854
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c70a73e63b92da04d9c417b56ab4b3b7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,60 @@
using asap.core;
using cfg;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UniRx;
public class DuelBtnRod : MonoBehaviour
{
Image bg_hud_god_image;
Image rawImage;
TMP_Text text_grade_rod;
TMP_Text text_star_rod;
PlayerFishData _playerFishData;
Tables _tables;
string[] bg_hud_gods = { "bg_hud_god_blue", "bg_hud_god_blue", "bg_hud_god_purple", "bg_hud_god_yellow" };
System.IDisposable disposable;
private void Awake()
{
_playerFishData = GContext.container.Resolve<PlayerFishData>();
_tables = GContext.container.Resolve<Tables>();
bg_hud_god_image = transform.Find("bg").GetComponent<Image>();
rawImage = transform.Find("mask/icon").GetComponent<Image>();
text_grade_rod = transform.Find("text_grade").GetComponent<TMP_Text>();
text_star_rod = transform.Find("bg_star/text_star").GetComponent<TMP_Text>();
disposable = GContext.OnEvent<ActChangeRodDataEvent>().Subscribe(e =>
{
InitData();
});
}
private void Start()
{
InitData();
}
public void InitData()
{
RodData rod = _tables.GetRodData(GContext.container.Resolve<PlayerData>().equipRodID);
text_grade_rod.text = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePanel_2", _playerFishData.GetRodLevel(rod.ID) + 1);
text_star_rod.text = _playerFishData.GetRodPiece(rod.ID).ToString();
GContext.container.Resolve<IUIService>().SetImageSprite(bg_hud_god_image, bg_hud_gods[rod.Quality - 1], "HomePanel");
int skindID = GContext.container.Resolve<PlayerFishData>().GetRodSkin(rod.ID);
if (skindID <= 0)
{
return;
}
var fishRodSkinData = _tables.TbRodSkinData.GetOrDefault(skindID);
if (fishRodSkinData == null)
{
return;
}
GContext.container.Resolve<IUIService>().SetImageSprite(rawImage, fishRodSkinData.Avatar, "HomePanel");
}
private void OnDestroy()
{
disposable?.Dispose();
disposable = null;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 51c69079d8444444190c34a5692695f2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,69 @@
using asap.core;
using cfg;
using GameCore;
using System.Collections;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class DuelChatView : MonoBehaviour, IDuelChatView
{
public Animation dialogue;
public TMP_Text text_chat;
public Animation emoji;
public Image image_emoji;
IUIService uiService;
protected virtual void Awake()
{
uiService = GContext.container.Resolve<IUIService>();
}
public void SetDuelFishingEvent(int roleID)
{
GContext.OnEvent<DuelChatEvent>().Where(x => x.RoleID == roleID).Subscribe(SetMessage).AddTo(this);
}
void SetMessage(DuelChatEvent duelChatEvent)
{
EventSoloQuickMessage eventSoloQuickMessage = GContext.container.Resolve<Tables>().TbEventSoloQuickMessage.GetOrDefault(duelChatEvent.MessageID);
if (eventSoloQuickMessage != null)
{
switch (eventSoloQuickMessage.Type)
{
case 1:
Emoji(eventSoloQuickMessage.Emoji);
break;
case 2:
Dialogue(eventSoloQuickMessage.Text_l10n_key);
break;
default:
break;
}
}
}
public void Dialogue(string chat)
{
if (this == null)
{
return;
}
emoji.gameObject.SetActive(false);
dialogue.gameObject.SetActive(true);
dialogue.Play();
text_chat.text = LocalizationMgr.GetText(chat);
}
public void Emoji(string chat)
{
if (this == null)
{
return;
}
emoji.gameObject.SetActive(true);
dialogue.gameObject.SetActive(false);
emoji.Play();
uiService.SetImageSprite(image_emoji, chat);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 10af52ad76e126e48a486f0f1f76be1c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
using UnityEngine;
using UnityEngine.UI;
public class DuelFishInfo : MonoBehaviour
{
public Image icon_fish;
public Image icon_fish_tag;
public GameObject myself;
public GameObject enemy;
public TextNumHigherAdd text_num_score;
public TextNumHigherAdd text_num_enermy_score;
public GameObject root;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 00ee5a3d3cdb11140856e861afe46d49
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
using asap.core;
using cfg;
using GameCore;
using System.Collections;
using UnityEngine;
public class DuelFishProgress : MonoBehaviour
{
public GameObject catching;
public GameObject nocatched;
public GameObject failed;
public DuelFishProgressInfo fishInfo;
public GameObject finished;
IUIService uiService;
private void Awake()
{
uiService = GContext.container.Resolve<IUIService>();
}
public void Catching()
{
catching.SetActive(true);
nocatched.SetActive(false);
}
public void NoCatched()
{
catching.SetActive(false);
nocatched.SetActive(true);
}
public void Failed()
{
catching.SetActive(false);
nocatched.SetActive(false);
failed.SetActive(true);
StartCoroutine(HideFishInfo(failed));
}
public void ShowFishInfo(FishInfoData data, bool isEnd)
{
catching.SetActive(false);
nocatched.SetActive(false);
failed.SetActive(false);
fishInfo.gameObject.SetActive(true);
Item item = GContext.container.Resolve<Tables>().GetItemData(data.fishItemId);
if (item != null)
{
PlayerFishData.SetFishIcon(fishInfo.icon_fish, item);//鱼头像
}
fishInfo.text_num_score.SetValue(data.point.ToString(), data.higher);
fishInfo.text_num_fishcard.SetValue(data.fishCardAdd.ToString("P0"), data.higherCard);
fishInfo.text_num_rod.SetValue(data.fishRodAdd.ToString("P0"), data.higherRod);
if (isEnd)
{
finished.SetActive(true);
}
StartCoroutine(HideFishInfo(fishInfo.gameObject));
}
IEnumerator HideFishInfo(GameObject hide)
{
yield return new WaitForSeconds(3f);
hide.SetActive(false);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8a8038c29a0f50f43b1cf1a773ff2cbe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
using UnityEngine;
using UnityEngine.UI;
public class DuelFishProgressInfo : MonoBehaviour
{
public Image icon_fish;
public TextNumHigher text_num_score;
public TextNumHigher text_num_fishcard;
public TextNumHigher text_num_rod;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cbb4e7ad36cc4834b8c7415c4f56e63e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using TMPro;
using UnityEngine;
public class DuelFishState : MonoBehaviour
{
public GameObject current;
public GameObject failed;
public GameObject done;
public TMP_Text[] text_num;
private void Reset()
{
current = transform.Find("current").gameObject;
failed = transform.Find("failed").gameObject;
done = transform.Find("done").gameObject;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 418f1cad18ea4a847b7a5b5c7f8d7f32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1b77606e514639646a93a02bc1010acb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,114 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class DuelInfoPopupPanel : MonoBehaviour
{
Image icon_rank;
Head head;
Head head1;
TMP_Text text_info;
List<Image> icon_ranks;
List<TMP_Text> txt_ranks;
List<TMP_Text> text_points;
DuelRankRewardItem duelRankRewardItem;
DuelRankRewardItem duelRankRewardItem1;
FishingEventData fishingEventData;
IUserService userService;
IUIService uiService;
private void Awake()
{
fishingEventData = GContext.container.Resolve<FishingEventData>();
userService = GContext.container.Resolve<IUserService>();
uiService = GContext.container.Resolve<IUIService>();
icon_rank = transform.Find("root/page1/info1/btn_rank/icon").GetComponent<Image>();
head = transform.Find("root/page1/info3/btn_head").GetComponent<Head>();
head1 = transform.Find("root/page2/info3/player_info/btn_head").GetComponent<Head>();
text_info = transform.Find("root/page1/info1/text_info").GetComponent<TMP_Text>();
icon_ranks = new List<Image>();
txt_ranks = new List<TMP_Text>();
text_points = new List<TMP_Text>();
for (int i = 1; i < 8; i++)
{
icon_ranks.Add(transform.Find($"root/page3/info1/rank/rank{i}/btn_green/icon_rank").GetComponent<Image>());
txt_ranks.Add(transform.Find($"root/page3/info1/rank/rank{i}/btn_green/text_rank").GetComponent<TMP_Text>());
text_points.Add(transform.Find($"root/page3/info1/rank/rank{i}/btn_green/text_point").GetComponent<TMP_Text>());
}
duelRankRewardItem = transform.Find("root/page3/info2/item1").GetComponent<DuelRankRewardItem>();
duelRankRewardItem1 = transform.Find("root/page3/info2/item2").GetComponent<DuelRankRewardItem>();
}
private void Start()
{
uiService.SetImageSprite(icon_rank, fishingEventData.rankInit.Icon);
string title = LocalizationMgr.GetText(fishingEventData.rankInit.Title_l10n_key);
text_info.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_51", title);
head.SetData(userService.AvatarUrl);
head1.SetData(userService.AvatarUrl);
var data = GContext.container.Resolve<Tables>().TbEventSolomain.DataList;
for (int i = 0; i < txt_ranks.Count; i++)
{
txt_ranks[i].text = LocalizationMgr.GetText(data[i].RankText_l10n_key);
text_points[i].text = data[i].TrophyRange[0].ToString();
uiService.SetImageSprite(icon_ranks[i], data[i].RankIcon);
}
ShowReward();
}
void ShowReward()
{
List<EventSolomain> eventSolomain = GContext.container.Resolve<Tables>().TbEventSolomain.DataList;
int count = eventSolomain.Count;
int index = count / 2;
EventSolomain solomain = eventSolomain[index];
uiService.SetImageSprite(duelRankRewardItem.icon_rank, solomain.RankIcon);
duelRankRewardItem.text_rank.text = LocalizationMgr.GetText(solomain.RankText_l10n_key);
duelRankRewardItem.text_point.text = solomain.TrophyRange[0].ToString();
List<ItemData> rewardItemData = GContext.container.Resolve<PlayerItemData>()
.GetItemDataByDropId(solomain.SeasonReward);
if (rewardItemData != null)
{
int dataCount = rewardItemData.Count;
int rewardCount = duelRankRewardItem.rewardItems.Count;
for (int j = 0; j < rewardCount; j++)
{
if (j < dataCount)
{
duelRankRewardItem.rewardItems[j].SetData(rewardItemData[j]);
}
else
{
duelRankRewardItem.rewardItems[j].gameObject.SetActive(false);
}
}
}
solomain = eventSolomain[index - 1];
uiService.SetImageSprite(duelRankRewardItem1.icon_rank, solomain.RankIcon);
duelRankRewardItem1.text_rank.text = LocalizationMgr.GetText(solomain.RankText_l10n_key);
duelRankRewardItem1.text_point.text = solomain.TrophyRange[0].ToString();
rewardItemData = GContext.container.Resolve<PlayerItemData>()
.GetItemDataByDropId(solomain.SeasonReward);
if (rewardItemData != null)
{
int dataCount = rewardItemData.Count;
int rewardCount = duelRankRewardItem1.rewardItems.Count;
for (int j = 0; j < rewardCount; j++)
{
if (j < dataCount)
{
duelRankRewardItem1.rewardItems[j].SetData(rewardItemData[j]);
}
else
{
duelRankRewardItem1.rewardItems[j].gameObject.SetActive(false);
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 41167a87fe9912c46a393231d1fee416
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class DuelMatchPlayer : MonoBehaviour
{
public Image icon_head;
public TMP_Text text_name;
public TMP_Text text_score;
public Image icon_rank;
public GameObject fx_ui_matchingPanel_rank;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b11238457db2bc2498173bc36d8713a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,228 @@
using asap.core;
using cfg;
using DG.Tweening;
using GameCore;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class DuelRandomMapPanel : MonoBehaviour
{
public Transform arrow1;
public Transform arrow2;
public float StartDelay = 0.5f;
public float StartDuration = 0.4f;
public int AccNum = 4;
public float LoopDuration = 0.2f;
/*
* 选定阶段
在[0, 1]之间选一个参数然后如下的3个参数都取相同的比例
间隔多少张图SelectedMapNumRand = [2,5]
回弹最后一张图的回弹比例必须大于0[0.2, 0.4]
二次回弹:弹回去之后[0, 0.1]
回弹速度在这段时间内整体速度逐渐变成0
*/
public int[] SelectedMapNumRand = new[] { 2, 5 };
public float[] BackRatioRand = new[] { 0.2f, 0.4f };
public float[] SecondBackRatioRand = new[] { 0f, 0.1f };
public int[] ArrowRotationRand = new[] { 10, 15 };
int MapNum = 2;
float BackRatio;
float SecondBackRatio;
FishingDuelManager FDM;
RectTransform Content;
GameObject img_map;
int allCount = 5;
float height;
IUIService uIService;
GameObject text_title;
TMP_Text text_map;
Tables _tables;
List<MapData> mapDatas;
List<int> newIDs;
bool isClose;
[HideInInspector]
public bool IsStop;
private void Awake()
{
_tables = GContext.container.Resolve<Tables>();
uIService = GContext.container.Resolve<IUIService>();
FDM = GContext.container.Resolve<FishingDuelManager>();
Content = transform.Find("Viewport/Content").GetComponent<RectTransform>();
img_map = transform.Find("Viewport/Content/Item").gameObject;
height = img_map.GetComponent<RectTransform>().rect.height;
img_map.SetActive(false);
text_title = transform.Find("title").gameObject;
text_map = transform.Find("title/text_map").GetComponent<TMP_Text>();
}
public void StartMap()
{
float t = Random.Range(0f, 1f);
MapNum = Mathf.RoundToInt(SelectedMapNumRand[0] + (SelectedMapNumRand[1] - SelectedMapNumRand[0]) * t);
BackRatio = BackRatioRand[0] + (BackRatioRand[1] - BackRatioRand[0]) * t;
SecondBackRatio = SecondBackRatioRand[0] + (SecondBackRatioRand[1] - SecondBackRatioRand[0]) * t;
IsStop = false;
text_title.SetActive(false);
isClose = false;
_tables = GContext.container.Resolve<Tables>();
var lastMapID = GContext.container.Resolve<PlayerData>().lastMapId;
mapDatas = _tables.TbMapData.DataList;
List<int> indexs = new List<int>
{
0,1
};
for (int i = 2; i < mapDatas.Count; i++)
{
if (mapDatas[i].ID <= lastMapID)
{
indexs.Insert(Random.Range(0, indexs.Count), i);
}
else
{
break;
}
}
while (indexs.Count < allCount + MapNum)
{
indexs.AddRange(indexs);
}
newIDs = indexs;
for (int i = 0; i < allCount; i++)
{
SetMapBg(mapDatas[newIDs[i]].Bg);
}
SetMapBg(mapDatas[newIDs[0]].Bg);
for (int i = 0; i < MapNum - 1; i++)
{
SetMapBg(mapDatas[newIDs[allCount + i]].Bg);
}
StartCoroutine(Play());
}
public void SetClose()
{
int mapId = FDM.MapId;
var mapData = _tables.TbMapData.DataMap[mapId];
SetMapBg(mapData.Bg);
SetMapBg(mapDatas[newIDs[0]].Bg);
text_map.text = LocalizationMgr.GetText(mapData.Name_l10n_key);
isClose = true;
//Content.DOKill();
//Content.anchoredPosition = new Vector2(0, allCount * height);
//StartCoroutine(Close());
//FDM.SetMapId(mapId);
}
void SetMapBg(string bg)
{
GameObject go = Instantiate(img_map, Content);
Image image = go.transform.GetChild(0).GetComponent<Image>();
go.SetActive(true);
uIService.SetImageSprite(image, bg);
}
public void Stop()
{
StopAllCoroutines();
Content.DOKill();
}
IEnumerator PlayArrow()
{
int cur = 1;
float acc = (StartDuration - LoopDuration) / AccNum;
float time = StartDuration;
float arrowTime = time / 4;
int ArrowRotation = Random.Range(ArrowRotationRand[0], ArrowRotationRand[1]);
arrow1.DOLocalRotate(new Vector3(0, 0, ArrowRotation), arrowTime);
arrow2.DOLocalRotate(new Vector3(0, 0, -ArrowRotation), arrowTime);
yield return new WaitForSeconds(arrowTime);
arrowTime = time / 4;
while (cur < AccNum)
{
cur++;
time -= acc;
arrowTime = arrowTime + time / 4;
ArrowRotation = Random.Range(ArrowRotationRand[0], ArrowRotationRand[1]);
arrow1.DOLocalRotate(new Vector3(0, 0, -ArrowRotation), arrowTime);
arrow2.DOLocalRotate(new Vector3(0, 0, ArrowRotation), arrowTime);
yield return new WaitForSeconds(arrowTime);
arrowTime = time / 2;
ArrowRotation = Random.Range(ArrowRotationRand[0], ArrowRotationRand[1]);
arrow1.DOLocalRotate(new Vector3(0, 0, ArrowRotation), arrowTime);
arrow2.DOLocalRotate(new Vector3(0, 0, -ArrowRotation), arrowTime);
yield return new WaitForSeconds(arrowTime);
arrowTime = time / 4;
}
while (!IsStop)
{
arrowTime = LoopDuration / 2;
ArrowRotation = Random.Range(ArrowRotationRand[0], ArrowRotationRand[1]);
arrow1.DOLocalRotate(new Vector3(0, 0, -ArrowRotation), arrowTime);
arrow2.DOLocalRotate(new Vector3(0, 0, ArrowRotation), arrowTime);
yield return new WaitForSeconds(arrowTime);
arrowTime = LoopDuration / 2;
ArrowRotation = Random.Range(ArrowRotationRand[0], ArrowRotationRand[1]);
arrow1.DOLocalRotate(new Vector3(0, 0, ArrowRotation), arrowTime);
arrow2.DOLocalRotate(new Vector3(0, 0, -ArrowRotation), arrowTime);
yield return new WaitForSeconds(arrowTime);
}
}
Coroutine playArrow;
IEnumerator Play()
{
Content.anchoredPosition = Vector2.zero;
yield return new WaitForSeconds(StartDelay);
int cur = 0;
float acc = (StartDuration - LoopDuration) / AccNum;
float time = StartDuration;
playArrow = StartCoroutine(PlayArrow());
while (cur < AccNum)
{
cur++;
Content.DOAnchorPosY(cur * height, time).SetEase(Ease.Linear);
yield return new WaitForSeconds(time);
time -= acc;
}
time = LoopDuration * (allCount - cur);
Content.DOAnchorPosY(allCount * height, time).SetEase(Ease.Linear);
yield return new WaitForSeconds(time);
time = LoopDuration * allCount;
while (!isClose)
{
Content.anchoredPosition = Vector2.zero;
Content.DOAnchorPosY(allCount * height, time).SetEase(Ease.Linear);
yield return new WaitForSeconds(time);
}
StartCoroutine(Close());
}
IEnumerator Close()
{
var sequence = DOTween.Sequence();
//跑马灯动画
float index2 = allCount + MapNum + BackRatio;
float time1 = (BackRatio + MapNum) * LoopDuration;
float time2 = SecondBackRatio;
sequence.Append(Content.DOAnchorPosY(index2 * height, time1).SetEase(Ease.Linear));
sequence.Append(Content.DOAnchorPosY((allCount + MapNum) * height, time2).SetEase(Ease.InSine));
sequence.Play();
yield return new WaitForSeconds(time1);
StopCoroutine(playArrow);
arrow1.DOKill();
arrow2.DOKill();
arrow1.DOLocalRotate(new Vector3(0, 0, 0), time2);
arrow2.DOLocalRotate(new Vector3(0, 0, 0), time2);
yield return new WaitForSeconds(time2);
IsStop = true;
GContext.Publish(new VibrationData(HapticTypes.HeavyImpact));
text_title.SetActive(true);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 76fcf748385e5ef488b51ea370f425a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class DuelRankRewardItem : MonoBehaviour
{
public GameObject bar_root;
public Image bar;
public GameObject bg_normal;
public GameObject bg_gray;
public GameObject bg_next;
public List<RewardItemNew> rewardItems;
public TMP_Text text_rank;
public Image icon_rank;
public TMP_Text text_point;
private void Reset()
{
bar_root = transform.Find("bg_bar").gameObject;
bar = transform.Find("bg_bar/bar").GetComponent<Image>();
bg_normal = transform.Find("bg_normal").gameObject;
bg_gray = transform.Find("bg_gray").gameObject;
bg_next = transform.Find("bg_next").gameObject;
text_rank = transform.Find("rank/text_rank").GetComponent<TMP_Text>();
icon_rank = transform.Find("rank/icon_rank").GetComponent<Image>();
text_point = transform.Find("rank/text_point").GetComponent<TMP_Text>();
rewardItems = new List<RewardItemNew>();
for (int i = 1; i < 5; i++)
{
rewardItems.Add(transform.Find($"reward/reward{i}").GetComponent<RewardItemNew>());
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 46df4a5d17420bb449214988814a8c30
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class DuelRodItem : MonoBehaviour
{
public RodItem rodItem;
public GameObject selected;
public Button btn_item;
public TMP_Text power_text;
public Action<DuelRodItem> onClick;
public RodItemData data => rodItem?.data;
private void Start()
{
if (btn_item != null)
{
btn_item.onClick.AddListener(OnBtnItem);
}
}
public void Init(RodItemData _data)
{
rodItem.Init(_data);
if (power_text != null)
{
power_text.transform.parent.gameObject.SetActive(_data.RodPower > 0);
power_text.text = _data.RodPower.ToString();
}
}
void OnBtnItem()
{
onClick?.Invoke(this);
}
public void SetSelected(bool value)
{
selected.SetActive(value);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 24df3b59efa18184aa7e6162807dce5d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,99 @@
using asap.core;
using DG.Tweening;
using System.Collections.Generic;
using TMPro;
using UniRx;
using UnityEngine;
public class DuelUIView : DuelChatView, IDuelUIView
{
public TMP_Text text_point;
public Animation anim;
public Head icon_head;
public TMP_Text text_name;
public TMP_Text text_add;
public DuelFishProgress fishProgress;
[HideInInspector]
public ReactiveProperty<int> curPTS = new ReactiveProperty<int>();
public List<DuelFishState> duelFishStates = new List<DuelFishState>();
protected override void Awake()
{
base.Awake();
duelFishStates[0].current.SetActive(true);
}
public void SetDuelFishingEvent(int roleID, int fishCount)
{
GContext.OnEvent<DuelFishingEvent>().Where(x => x.RoleID == roleID).Subscribe(e =>
{
if (e.ItemID > 0)
{
Fishing(e.ItemID);
}
else
{
EndFishing(e.index, e.data, e.isEnd);
}
}).AddTo(this);
for (int i = fishCount; i < duelFishStates.Count; i++)
{
duelFishStates[i].gameObject.SetActive(false);
}
SetDuelFishingEvent(roleID);
}
public void EndFishing(int index, FishInfoData data, bool isEnd)
{
if (index > duelFishStates.Count)
{
return;
}
if (index > 0)
{
duelFishStates[index - 1].current.SetActive(false);
if (data.point > 0)
{
PTSAdd(data.point);
duelFishStates[index - 1].done.SetActive(true);
duelFishStates[index - 1].failed.SetActive(false);
fishProgress.ShowFishInfo(data, isEnd);
}
else
{
duelFishStates[index - 1].done.SetActive(false);
duelFishStates[index - 1].failed.SetActive(true);
fishProgress.Failed();
}
if (index < duelFishStates.Count)
{
duelFishStates[index].current.SetActive(true);
}
}
else
{
fishProgress.NoCatched();
}
}
public void Fishing(int itemID)
{
fishProgress.Catching();
}
async void PTSAdd(int add)
{
text_add.text = $"+{add}";
text_add.gameObject.SetActive(true);
anim.Play();
await Awaiters.Seconds(1);
//eventFishingDuelTopArea.text_add.gameObject.SetActive(false);
int pts = curPTS.Value;
curPTS.Value += add;
int newPts = pts + add;
DOTween.To(() => pts, x => pts = x, newPts, 1).OnUpdate(() =>
{
text_point.text = ConvertTools.GetNumberString2(pts);
});
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e5a4b91bc67c568498851c59851c3868
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,278 @@
using asap.core;
using Game;
using GameCore;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UniRx;
using DG.Tweening;
using System.Collections;
using cfg;
public class EventFishingDuelArea : MonoBehaviour
{
private UIButton btn_play;
Button btn_yugan;
public Animation ani;
event_fishingduel_rod_change rodPanel;
Animator btn_play_anim;
[HideInInspector]
public GameObject DownPanel;
Animation text_time_ani;
TMP_Text text_time;
TMP_Text text_time_red;
public TMP_Text text_countdown;
GameObject TopArea;
Image bar;
string doTweenKey = "EventFishingDuelArea";
DuelUIView selfView;
DuelUIView enemyView;
FishingDuelManager FDM;
Button btn_chat;
GameObject chat;
GameObject redpoint;
Animator toast_start;
TMP_Text text_title;
public Animation toast_others;
public TMP_Text[] toasts;
protected CompositeDisposable disposables = new CompositeDisposable();
private void Awake()
{
FDM = GContext.container.Resolve<FishingDuelManager>();
TopArea = transform.Find("root/TopArea").gameObject;
bar = transform.Find("root/TopArea/bg_bar/bar_myself").GetComponent<Image>();
selfView = transform.Find("root/TopArea/SelfView").GetComponent<DuelUIView>();
enemyView = transform.Find("root/TopArea/EnemyView").GetComponent<DuelUIView>();
btn_play = transform.Find("root/DownPanel/btn_play").GetComponent<UIButton>();
btn_play_anim = btn_play.GetComponent<Animator>();
text_time_ani = transform.Find("root/TopArea/bg_bar/text_time").GetComponent<Animation>();
text_time = transform.Find("root/TopArea/bg_bar/text_time/text_time").GetComponent<TMP_Text>();
text_time_red = transform.Find("root/TopArea/bg_bar/text_time/text_time_red").GetComponent<TMP_Text>();
DownPanel = transform.Find("root/DownPanel").gameObject;
btn_chat = transform.Find("root/DownPanel/btn_layout/btn_chat").GetComponent<Button>();
chat = transform.Find("root/event_fishingduel_chat").gameObject;
rodPanel = transform.Find("root/event_fishingduel_rod_change").GetComponent<event_fishingduel_rod_change>();
redpoint = transform.Find("root/DownPanel/btn_yugan/redpoint").gameObject;
btn_yugan = transform.Find("root/DownPanel/btn_yugan").GetComponent<Button>();
toast_start = transform.Find("root/toast_start").GetComponent<Animator>();
text_title = transform.Find("root/toast_start/text/text_waiting").GetComponent<TMP_Text>();
GContext.OnEvent<RequestSvrTimeEvent>().Subscribe(RequestSvrTimeEvent).AddTo(disposables);
redpoint.SetActive(false);
rodPanel.gameObject.SetActive(true);
SetTopArea(false);
}
protected void Start()
{
btn_play.onDown.AddListener(StartAutoTimer);
btn_play.onUp.AddListener(StopCoroutineTimer);
btn_play.onClick.AddListener(OnClickPlay);
//btn_yugan.onClick.AddListener(OnClickRod);
btn_chat.onClick.AddListener(() =>
{
chat.SetActive(!chat.activeSelf);
});
InitView();
SetTopArea(false);
//redpoint.SetActive(FDM.InitRodRed());
//OnClickRod();
MapData mapData = GContext.container.Resolve<Tables>().TbMapData.DataMap[FDM.MapId];
rodPanel.text_title.text = LocalizationMgr.GetText(mapData.Name_l10n_key);
rodPanel.allTime = FDM.eventSoloConfig.ChooseRodTime;
rodPanel.SetTimer();
}
void InitView()
{
selfView.icon_head.SetData(FDM.SelfModel.PlayerAvatar);
selfView.text_name.text = FDM.SelfModel.PlayerName;
selfView.text_point.text = "0";
selfView.text_add.gameObject.SetActive(false);
selfView.curPTS.Subscribe(curPTS =>
{
SetBar();
}).AddTo(disposables);
selfView.SetDuelFishingEvent(0, FDM.FishItemIDs.Count);
bar.fillAmount = 0.5f;
enemyView.icon_head.SetData(FDM.EnemyModel.PlayerAvatar);
enemyView.text_name.text = FDM.EnemyModel.PlayerName;
enemyView.text_point.text = "0";
enemyView.text_add.gameObject.SetActive(false);
enemyView.curPTS.Subscribe(curPTS =>
{
SetBar();
}).AddTo(disposables);
enemyView.SetDuelFishingEvent(1, FDM.FishItemIDs.Count);
FDM.SelfModel.RoleID = 0;
FDM.EnemyModel.RoleID = 1;
FDM.SelfChatModel.RoleID = 0;
FDM.EnemyChatModel.RoleID = 1;
}
public void SetBar()
{
float fillAmount = FDM.FillAmount;
if (fillAmount > 0)
{
DOTween.Kill(doTweenKey);
fillAmount = 0.05f + fillAmount * 0.9f;
bar.DOFillAmount(fillAmount, 1).SetId(doTweenKey);
}
}
bool Status = true;
void RequestSvrTimeEvent(RequestSvrTimeEvent requestSvrTimeEvent)
{
Status = requestSvrTimeEvent.Status;
TopArea.SetActive(Status);
}
/// <summary>
/// 显示Toast
/// </summary>
/// <param name="index">0== 对手先进 最后一轮, 1==对手完成2==我完成</param>
/// <param name="value"></param>
public void ShowToastOthers(int index, string value)
{
Debug.Log($"ShowToastOthers {index} {value}");
if (index < 0 || index >= toasts.Length) return;
var toast = toasts[index];
toast_others.gameObject.SetActive(true);
toast_others.Play($"toast_others_show_{index + 1}");
toast.text = value;
if (index == 1)
{
text_time_ani.Play("text_time_top_disappear_lose");
StartCoroutine(PlayAppear());
}
else if (index == 2)
{
text_time_ani.Play("text_time_top_disappear_win");
}
}
public async void ShowToastOthers(string value)
{
var toast = toasts[1];
toast_others.gameObject.SetActive(true);
toast_others.Play("toast_others_close");
await Awaiters.Seconds(0.5f);
toast_others.Play("toast_others_show_2");
toast.text = value;
}
public void PlayLoop()
{
text_time_ani.Play("text_time_red_loop");
}
IEnumerator PlayAppear()
{
yield return new WaitForSeconds(3f);
text_time_ani.Play("text_time_toast_appear");
yield return new WaitForSeconds(1f);
PlayLoop();
}
//void OnClickRod()
//{
// redpoint.SetActive(false);
// rodPanel.gameObject.SetActive(true);
// SetTopArea(false);
//}
void StartAutoTimer()
{
btn_play_anim.Play("Pressed", -1, 0);
}
void StopCoroutineTimer()
{
btn_play_anim.Play("Normal", -1, 0);
}
async void OnClickPlay()
{
GContext.Publish(new EventFishingSound(SoundType.audio_ui_btn_cast));
GContext.Publish(new VibrationData(HapticTypes.Selection));
GContext.Publish(new VibrationData(HapticTypes.MediumImpact));
var go = await UIManager.Instance.ShowUI(UITypes.FishingPanel);
if (go != null)
{
transform.SetAsLastSibling();
DownPanel.SetActive(false);
}
}
public void SetTopArea(bool value)
{
DownPanel.SetActive(value);
TopArea.SetActive(value && Status);
}
public void SetHideBtnPlay()
{
btn_play.gameObject.SetActive(false);
}
public void SetTime(TimeSpan timeSpan, bool selfIsLastFish)
{
if (/*selfIsLastFish || */timeSpan.TotalSeconds > FDM.eventSoloConfig.EndTime)
{
text_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_second", timeSpan.TotalSeconds.ToString("F0"));
text_time_red.text = "";
}
else
{
text_countdown.text = text_time_red.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_second", timeSpan.TotalSeconds.ToString("F0"));
text_time.text = "";
}
//UI_COMMON_second
}
public void SetState(int value, int role)
{
toast_start.gameObject.SetActive(true);
if (value == 1)
{
SetTimer();
}
else if (value == 2)
{
if (role == 1)
{
toast_start.SetBool("end", true);
}
else
{
toast_start.Play("duel_toast_late", -1, 0);
}
}
}
void SetTimer()
{
StartCoroutine(WaitTime());
}
IEnumerator WaitTime()
{
int allTime = rodPanel.allTime;
while (allTime > 0)
{
text_title.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_62", allTime);
yield return new WaitForSeconds(1);
if (FDM.RodState >= 2)
{
yield break;
}
allTime--;
}
text_title.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_62", 0);
if (FDM.RodState < 2)
{
//理论上这个时候双方都选好,防止意外强制开始
FDM.RodState++;
GContext.Publish(new RodStateEvent() { RoleID = 1 });
}
}
private void OnDestroy()
{
disposables?.Dispose();
disposables = null;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e02d3c73ef70b97429e453fc55c107b6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,485 @@
using asap.core;
using cfg;
using DG.Tweening;
using game;
using GameCore;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.AddressableAssets;
using System;
using UniRx;
public class EventFishingDuelPanel : BasePanel
{
Tables tables;
Button btn_close;
GameObject btn_close_image;
Animation anim;
GameObject MiddlePanel;
TMP_Text text_time;
Image icon_rank;
TMP_Text text_rank;
Button btn_questionmark1;
Button btn_questionmark;
GameObject bg_bar;
Image bar;
TMP_Text text_progress;
Button btn_reward;
List<RewardItemNew> rewardItemNews;
TMP_Text win_text_num;
TMP_Text loss_text_num;
TMP_Text middle_text_time;
Button icon_ticket;
Button btn_confirm;
TMP_Text text_num;
//GameObject effect_beilv_loop;
Button btn_beilv;
//Image btn_beilv_image;
Button btn_beilv_max;
//private Image btn_beilv_max_image;
TMP_Text text_beilv;
TMP_Text text_beilv_max;
TMP_Text text_beilv_show;
GameObject matchingPanel;
DuelMatchPlayer myself;
DuelMatchPlayer enemy;
GameObject fx_ui_matchingPanel_match_glow_01;
TMP_Text match_text_time;
Button but_stop;
Coroutine matchIng;
FishingDuelManager FDM;
Sound audio_matchingloop;
AudioClip audio_ui_fishingduel_matchingloop;
IUIService uiService;
Timer timer;
FishingEventData fishingEventData;
Button btn_advert;
DuelRandomMapPanel randomMapPanel;
GameObject fishConfrimPanel;
TicketTips ticket_tips;
IDisposable disRequestSvrTime;
private void Awake()
{
fishingEventData = GContext.container.Resolve<FishingEventData>();
uiService = GContext.container.Resolve<IUIService>();
tables = GContext.container.Resolve<Tables>();
btn_close = transform.Find("bottom/btn_close").GetComponent<Button>();
btn_close_image = transform.Find("bottom/btn_close/Image").gameObject;
GContext.container.Unregister<FishingDuelManager>();
FDM = new FishingDuelManager();
GContext.container.RegisterInstance(FDM);
btn_advert = transform.Find("root/MiddlePanel/bottom/btn_advert").GetComponent<Button>();
//====================倍率调整
btn_beilv = transform.Find("root/MiddlePanel/bottom/beilv").GetComponent<Button>();
btn_beilv_max = transform.Find("root/MiddlePanel/bottom/beilv_max").GetComponent<Button>();
text_beilv = transform.Find("root/MiddlePanel/bottom/beilv/text_beilv").GetComponent<TMP_Text>();
text_beilv_max = transform.Find("root/MiddlePanel/bottom/beilv_max/text_beilv").GetComponent<TMP_Text>();
//====================
ticket_tips = transform.Find("root/MiddlePanel/bottom/ticket_tips").GetComponent<TicketTips>();
//UI_EventPartnerFishbowlPanel_27
anim = transform.Find("root/matchingPanel").GetComponent<Animation>();
btn_questionmark1 = transform.Find("root/MiddlePanel/top/title/btn_questionmark").GetComponent<Button>();
//===================匹配界面
MiddlePanel = transform.Find("root/MiddlePanel").gameObject;
text_time = transform.Find("root/MiddlePanel/top/text_time").GetComponent<TMP_Text>();
icon_rank = transform.Find("root/MiddlePanel/rank/icon_rank").GetComponent<Image>();
text_rank = transform.Find("root/MiddlePanel/rank/text_rank").GetComponent<TMP_Text>();
btn_questionmark = transform.Find("root/MiddlePanel/rank/text_rank/btn_questionmark").GetComponent<Button>();
bg_bar = transform.Find("root/MiddlePanel/rank/bg_bar").gameObject;
bar = transform.Find("root/MiddlePanel/rank/bg_bar/bar").GetComponent<Image>();
text_progress = transform.Find("root/MiddlePanel/rank/bg_bar/text_progress").GetComponent<TMP_Text>();
btn_reward = transform.Find("root/MiddlePanel/rank/btn_reward").GetComponent<Button>();
rewardItemNews = new List<RewardItemNew>();
Transform layout_reward = transform.Find("root/MiddlePanel/reward/layout_reward");
int layout_reward_count = layout_reward.childCount;
for (int i = 0; i < layout_reward_count; i++)
{
rewardItemNews.Add(layout_reward.GetChild(i).GetComponent<RewardItemNew>());
}
icon_ticket = transform.Find("root/MiddlePanel/bottom/icon_ticket").GetComponent<Button>();
win_text_num = transform.Find("root/MiddlePanel/reward/info/win/text_num").GetComponent<TMP_Text>();
loss_text_num = transform.Find("root/MiddlePanel/reward/info/loss/text_num").GetComponent<TMP_Text>();
btn_confirm = transform.Find("root/MiddlePanel/bottom/btn_confirm/btn_green").GetComponent<Button>();
middle_text_time = transform.Find("root/MiddlePanel/top/text_time").GetComponent<TMP_Text>();
text_num = transform.Find("root/MiddlePanel/bottom/icon_ticket/text_num").GetComponent<TMP_Text>();
//================================
//=====================匹配中
matchingPanel = transform.Find("root/matchingPanel").gameObject;
myself = transform.Find("root/matchingPanel/myself").GetComponent<DuelMatchPlayer>();
enemy = transform.Find("root/matchingPanel/enermy").GetComponent<DuelMatchPlayer>();
match_text_time = transform.Find("root/matchingPanel/text_time").GetComponent<TMP_Text>();
but_stop = transform.Find("root/matchingPanel/btn_stop/btn_green").GetComponent<Button>();
fx_ui_matchingPanel_match_glow_01 = transform.Find("root/matchingPanel/enermy/fx_ui_matchingPanel_match_glow_01").gameObject;
//=================================
randomMapPanel = transform.Find("root/matchingPanel/RandomMap").GetComponent<DuelRandomMapPanel>();
fishConfrimPanel = transform.Find("root/FishConfirmPanel").gameObject;
fishConfrimPanel.SetActive(false);
LoadAudio();
}
async void LoadAudio()
{
audio_ui_fishingduel_matchingloop = await Addressables.LoadAssetAsync<AudioClip>("audio_ui_fishingduel_matchingloop").Task;
}
protected override void Start()
{
base.Start();
GContext.Publish(new HideHomePanelEvent());
//disposable = GContext.OnEvent<RewardPanelClose>().Subscribe(OnRewardPanelClose);
ShowPanel(false);
btn_close.onClick.AddListener(OnClickClose);
InitMiddlePanel();
but_stop.onClick.AddListener(OnClickStop);
IUserService userService = GContext.container.Resolve<IUserService>();
var url = userService.AvatarUrl;
uiService.SetHeadImage(myself.icon_head, url);
myself.text_name.text = userService.DisplayName;
myself.icon_rank.sprite = icon_rank.sprite;
myself.text_score.text = ConvertTools.GetNumberString2(FDM.duelData.progress);
btn_beilv.onClick.AddListener(OnclickMagnification);
btn_beilv_max.onClick.AddListener(OnclickMagnification);
SetShowMagnification();
btn_reward.onClick.AddListener(() => _ = UIManager.Instance.ShowUI(UITypes.EventFishingDuelRewardPopupPanel));
btn_advert.onClick.AddListener(() => _ = UIManager.Instance.ShowUI(UITypes.EventFishingduelShopPopupPanel));
Item itemdata = tables.TbItem.GetOrDefault(2051);
string nameL = LocalizationMgr.GetText(itemdata.Name_l10n_key);
ticket_tips.SetText(LocalizationMgr.GetFormatTextValue("UI_EventPartnerFishbowlPanel_27", nameL));
}
void OnclickMagnification()
{
FDM.SetMagnification();
SetShowMagnification();
}
void SetShowMagnification()
{
bool IsMax = FDM.IsMaxMagnification();
btn_beilv.gameObject.SetActive(!IsMax);
btn_beilv_max.gameObject.SetActive(IsMax);
text_beilv.text = text_beilv_max.text = $"x{FDM.magnification}";
SetReward();
}
//void OnRewardPanelClose(RewardPanelClose rewardPanelClose)
//{
// SetEnergy();
//}
void SetEnergy()
{
//获取配置表
int MatchCost = FDM.magnification;
int Energy = FDM.duelData.tickets;
if (MatchCost > Energy)
{
//ConvertTools.GetNumberString
text_num.text = $"<color=red>{Energy}/{MatchCost}</color>";
}
else
{
text_num.text = $"{Energy}/{MatchCost}";
}
}
void SetReward()
{
var rewardItemData = FDM.GetReward();
if (rewardItemData != null)
{
int dataCount = rewardItemData.Count;
int rewardCount = rewardItemNews.Count;
for (int i = 0; i < rewardCount; i++)
{
if (i < dataCount)
{
rewardItemData[i].count *= FDM.magnification;
rewardItemNews[i].SetData(rewardItemData[i]);
}
else
{
rewardItemNews[i].gameObject.SetActive(false);
}
}
}
win_text_num.text = $"+{FDM.eventSolomain.WinTrophy * FDM.magnification}";
loss_text_num.text = $"-{FDM.eventSolomain.LoseTrophy * FDM.magnification}";
SetEnergy();
}
void InitMiddlePanel()
{
DoConsumeBait();
icon_ticket.onClick.AddListener(OnClickIcon);
btn_confirm.onClick.AddListener(OnClickMaching);
btn_questionmark.onClick.AddListener(() => _ = UIManager.Instance.ShowUI(UITypes.EventFishingDuelRankPopupPanel));
btn_questionmark1.onClick.AddListener(() => _ = UIManager.Instance.ShowUI(UITypes.EventFishingDuelInfoPopupPanel));
uiService.SetImageSprite(icon_rank, FDM.eventSolomain.RankIcon);
text_rank.text = LocalizationMgr.GetText(FDM.eventSolomain.RankText_l10n_key);
text_progress.text = $"{FDM.duelData.progress}";
win_text_num.text = $"+{FDM.eventSolomain.WinTrophy * FDM.magnification}";
loss_text_num.text = $"-{FDM.eventSolomain.LoseTrophy * FDM.magnification}";
}
private void DoConsumeBait()
{
Debug.Log("NetworkReachability");
if (Application.internetReachability == NetworkReachability.NotReachable)
{
Debug.Log("NetworkReachability.NotReachable");
NoInternet();
}
}
private async void NoInternet()
{
GameObject go = await UIManager.Instance.ShowUI(UITypes.NoticeConfirmPopupPanel);
var NoticeConfirmPopupPanel = go.GetComponent<NoticeConfirmPopupPanel>();
string info = LocalizationMgr.GetText("UI_FishingReconnectPanel_101003");
string label = LocalizationMgr.GetText("UI_FishingRewardPanel_101022");
string title = LocalizationMgr.GetText("UI_FishingReconnectPanel_101002");
NoticeConfirmPopupPanel.Init(1, title, info,
onClickLeft: DoConsumeBait,
onClose: DoConsumeBait,
btn_left_text: label);
}
void OnClickMaching()
{
if (FDM.duelData.tickets < FDM.magnification)
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_86"));
//var pos = btn_confirm.transform.position;
//pos.y += 50;
//ticket_tips.SetPos(pos);
//ticket_tips.gameObject.SetActive(!ticket_tips.gameObject.activeSelf);
//门票不足
FDM.SetMaxMagnification();
SetShowMagnification();
return;
}
disRequestSvrTime?.Dispose();
disRequestSvrTime = GContext.OnEvent<RequestSvrTimeEvent>().Subscribe(RequestSvrTimeEvent);
ShowPanel(true);
matchIng = StartCoroutine(StartMaching());
}
void RequestSvrTimeEvent(RequestSvrTimeEvent requestSvrTimeEvent)
{
if (!requestSvrTimeEvent.Status)
{
OnClickStop();
}
}
void OnClickIcon()
{
var pos = icon_ticket.transform.position;
pos.y += 40;
ticket_tips.SetPos(pos);
ticket_tips.gameObject.SetActive(!ticket_tips.gameObject.activeSelf);
}
void OnClickStop()
{
FDM.CancelMaching();
disRequestSvrTime?.Dispose();
disRequestSvrTime = null;
if (matchIng != null)
{
StopCoroutine(matchIng);
matchIng = null;
}
randomMapPanel.Stop();
ShowPanel(false);
}
void ShowPanel(bool isMatch)
{
if (isMatch)
{
StopTimer();
}
else
{
SetTimer();
}
btn_close.enabled = !isMatch;
btn_close_image.SetActive(!isMatch);
MiddlePanel.SetActive(!isMatch);
matchingPanel.SetActive(isMatch);
StopLoopAudio();
}
void PlayLoopAudio()
{
StopLoopAudio();
audio_matchingloop = GContext.container.Resolve<ISoundService>().GetNewUISound(audio_ui_fishingduel_matchingloop);
audio_matchingloop.audioSource.Play();
audio_matchingloop.audioSource.loop = true;
}
void StopLoopAudio()
{
if (audio_matchingloop)
{
audio_matchingloop.audioSource.Stop();
audio_matchingloop.ReturnPool();
audio_matchingloop = null;
}
}
IEnumerator StartMaching()
{
//anim.Play("eventfishingduelpanel_maprandom");
Dictionary<int, Robot> robots = tables.TbRobot.DataMap;
List<int> RobotAccountList = FDM.eventSolomain.RobotAccountList;
int robotId = RobotAccountList[UnityEngine.Random.Range(0, RobotAccountList.Count)];
EventSoloRobot eventSoloRobot = tables.TbEventSoloRobot.GetOrDefault(robotId);
List<int> robotList = eventSoloRobot.RobotList;
robotId = robotList[UnityEngine.Random.Range(0, robotList.Count)];
Robot robot = robots[robotId];
SetRobot(robot, eventSoloRobot.Trophy);
//等待匹配
randomMapPanel.StartMap();
PlayLoopAudio();
yield return new WaitForSeconds(1);
FDM.StartMaching();
//anim.Play("eventfishingduelpanel_loop");
float time = 0.1f;
while (FDM.MachingState < 2)
{
robotId = RobotAccountList[UnityEngine.Random.Range(0, RobotAccountList.Count)];
eventSoloRobot = tables.TbEventSoloRobot.GetOrDefault(robotId);
robotList = eventSoloRobot.RobotList;
robotId = robotList[UnityEngine.Random.Range(0, robotList.Count)];
robot = robots[robotId];
SetRobot(robot, eventSoloRobot.Trophy);
yield return new WaitForSeconds(time);
}
but_stop.gameObject.SetActive(false);
disRequestSvrTime?.Dispose();
disRequestSvrTime = null;
var matchDelayTime = FDM.eventSoloConfig.MatchDelayTime;
float machTimeM = UnityEngine.Random.Range(matchDelayTime[0], matchDelayTime[1]);
//最后两秒等的越来越长
while (machTimeM > 0f)
{
robotId = RobotAccountList[UnityEngine.Random.Range(0, RobotAccountList.Count)];
eventSoloRobot = tables.TbEventSoloRobot.GetOrDefault(robotId);
robotList = eventSoloRobot.RobotList;
robotId = robotList[UnityEngine.Random.Range(0, robotList.Count)];
robot = robots[robotId];
SetRobot(robot, eventSoloRobot.Trophy);
machTimeM -= time;
yield return new WaitForSeconds(time);
}
randomMapPanel.SetClose();
while (!randomMapPanel.IsStop)
{
robotId = RobotAccountList[UnityEngine.Random.Range(0, RobotAccountList.Count)];
eventSoloRobot = tables.TbEventSoloRobot.GetOrDefault(robotId);
robotList = eventSoloRobot.RobotList;
robotId = robotList[UnityEngine.Random.Range(0, robotList.Count)];
robot = robots[robotId];
SetRobot(robot, eventSoloRobot.Trophy);
yield return new WaitForSeconds(time);
}
fx_ui_matchingPanel_match_glow_01.SetActive(true);
uiService.SetHeadImage(enemy.icon_head, FDM.EnemyModel.PlayerAvatar);
enemy.text_name.text = FDM.EnemyModel.PlayerName;
var eventSolomain = FDM.GetEventSolomain(FDM.EnemyModel.RankScore);
uiService.SetImageSprite(enemy.icon_rank, eventSolomain.RankIcon);
enemy.text_score.text = ConvertTools.GetNumberString2(FDM.EnemyModel.RankScore);
StopLoopAudio();
yield return new WaitForSeconds(2);
anim.Play("eventfishingduelpanel_matchingpanel_end");
yield return new WaitForSeconds(0.5f);
//PlayLoopAudio();
//yield return new WaitForSeconds(2);
//StopLoopAudio();
ShowFishConfrimPanel();
}
void SetRobot(Robot robot, int trophy)
{
int robotTier = FDM.eventSolomain.MatchTierList[UnityEngine.Random.Range(0, FDM.eventSolomain.MatchTierList.Count)];
var eventSolomain = tables.TbEventSolomain.DataMap[robotTier];
uiService.SetHeadImage(enemy.icon_head, robot.Avatar);
enemy.text_name.text = LocalizationMgr.GetText(robot.Name_l10n_key);
uiService.SetImageSprite(enemy.icon_rank, eventSolomain.RankIcon);
enemy.text_score.text = ConvertTools.GetNumberString2(trophy);
}
public void OnClickClose()
{
GContext.container.Unregister<FishingDuelManager>();
GContext.Publish(new RestartShowHomeUIEvent());
UIManager.Instance.DestroyUI(UITypes.EventFishingDuelPanel);
disRequestSvrTime?.Dispose();
disRequestSvrTime = null;
}
void SetTimer()
{
StopTimer();
DateTime endDateTime = fishingEventData.GetEventEndTime(fishingEventData.duelData.eventID)
.AddSeconds(-tables.TbEventSoloConfig.SettlementTime);
TimeSpan now = endDateTime - ZZTimeHelper.UtcNow().UtcNowOffset();
text_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_end",
ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds));
double seconds = now.TotalSeconds;
if (seconds < 1)
{
Refresh();
}
else
{
timer = this.AttachTimer((float)seconds, Refresh,
(elapsed) =>
{
now = endDateTime - ZZTimeHelper.UtcNow().UtcNowOffset();
text_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_end",
ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds));
}, useRealTime: true);
}
}
void StopTimer()
{
timer?.Cancel();
timer = null;
}
void Refresh()
{
timer?.Cancel();
timer = null;
OnClickClose();
UIManager.Instance.DestroyUI(UITypes.EventFishingDuelRankPopupPanel);
UIManager.Instance.DestroyUI(UITypes.EventFishingDuelRewardPopupPanel);
UIManager.Instance.DestroyUI(UITypes.EventFishingduelShopPopupPanel);
UIManager.Instance.DestroyUI(UITypes.EventFishingDuelInfoPopupPanel);
}
public void ShowFishConfrimPanel()
{
matchingPanel.gameObject.SetActive(false);
fishConfrimPanel.SetActive(true);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 923a6137d74c1664bb4ef7b99f242be0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
using asap.core;
using cfg;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class EventFishingDuelRankChangePopupPanel : BasePanel
{
Button closeButton;
Button mask;
GameObject rankUpPanel;
GameObject rankDownPanel;
Image icon_rank;
TMP_Text text_rank;
private void Awake()
{
mask = transform.Find("mask").GetComponent<Button>();
closeButton = transform.Find("btn_close").GetComponent<Button>();
rankUpPanel = transform.Find("root_promote").gameObject;
rankDownPanel = transform.Find("root_demote").gameObject;
closeButton.onClick.AddListener(ClosePanel);
mask.onClick.AddListener(ClosePanel);
}
public void SetRank(bool isUp, EventSolomain eventSolomain)
{
if (isUp)
{
rankUpPanel.SetActive(true);
rankDownPanel.SetActive(false);
icon_rank = rankUpPanel.transform.Find("icon_rank").GetComponent<Image>();
text_rank = rankUpPanel.transform.Find("text_rank").GetComponent<TMP_Text>();
}
else
{
rankUpPanel.SetActive(false);
rankDownPanel.SetActive(true);
icon_rank = rankDownPanel.transform.Find("icon_rank").GetComponent<Image>();
text_rank = rankDownPanel.transform.Find("text_rank").GetComponent<TMP_Text>();
}
GContext.container.Resolve<IUIService>().SetImageSprite(icon_rank, eventSolomain.RankIcon);
text_rank.text = LocalizationMgr.GetText(eventSolomain.RankText_l10n_key);
}
void ClosePanel()
{
UIManager.Instance.DestroyUI(UITypes.EventFishingDuelRankChangePopupPanel);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b18b42da9e597c94c9c8b4c8b8416edb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,86 @@
using asap.core;
using cfg;
using GameCore;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class EventFishingDuelRankPopupPanel : MonoBehaviour
{
List<Button> buttons;
List<Image> icon_ranks;
List<TMP_Text> txt_ranks;
List<TMP_Text> text_points;
List<GameObject> selecteds;
List<RewardItemNew> rewardItemNews;
List<EventSolomain> data;
Button btn_close;
FishingDuelManager fishingDuelManager;
private void Awake()
{
fishingDuelManager = GContext.container.Resolve<FishingDuelManager>();
buttons = new List<Button>();
icon_ranks = new List<Image>();
txt_ranks = new List<TMP_Text>();
text_points = new List<TMP_Text>();
selecteds = new List<GameObject>();
for (int i = 1; i < 8; i++)
{
buttons.Add(transform.Find($"root/rank{i}/btn_green").GetComponent<Button>());
icon_ranks.Add(transform.Find($"root/rank{i}/btn_green/icon_rank").GetComponent<Image>());
txt_ranks.Add(transform.Find($"root/rank{i}/btn_green/text_rank").GetComponent<TMP_Text>());
text_points.Add(transform.Find($"root/rank{i}/btn_green/text_point").GetComponent<TMP_Text>());
selecteds.Add(transform.Find($"root/rank{i}/btn_green/selected").gameObject);
}
rewardItemNews = new List<RewardItemNew>();
Transform layout_reward = transform.Find("root/layout_reward");
for (int i = 0; i < layout_reward.childCount; i++)
{
rewardItemNews.Add(layout_reward.GetChild(i).GetComponent<RewardItemNew>());
}
btn_close = transform.Find("btn_close").GetComponent<Button>();
}
void Start()
{
data = GContext.container.Resolve<Tables>().TbEventSolomain.DataList;
IUIService uiService = GContext.container.Resolve<IUIService>();
for (int i = 0; i < buttons.Count; i++)
{
int index = i;
txt_ranks[i].text = LocalizationMgr.GetText(data[i].RankText_l10n_key);
text_points[i].text = data[i].TrophyRange[0].ToString();
uiService.SetImageSprite(icon_ranks[i], data[i].RankIcon);
buttons[i].onClick.AddListener(() => SetRewardPanel(index));
if (data[i].RankTier == fishingDuelManager.eventSolomain.RankTier)
{
SetRewardPanel(index);
}
}
btn_close.onClick.AddListener(() => UIManager.Instance.DestroyUI(UITypes.EventFishingDuelRankPopupPanel));
}
void SetRewardPanel(int index)
{
var rank = data[index];
List<ItemData> itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(rank.WinReward);
for (int i = 0; i < rewardItemNews.Count; i++)
{
if (i < itemDatas.Count)
{
rewardItemNews[i].SetData(itemDatas[i]);
}
else
{
rewardItemNews[i].gameObject.SetActive(false);
}
}
for (int i = 0; i < selecteds.Count; i++)
{
selecteds[i].SetActive(i == index);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 81744cc08ed4c3b469901d074cb8fc1f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,193 @@
using asap.core;
using cfg;
using DG.Tweening;
using GameCore;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class EventFishingDuelReportRewardPanel : MonoBehaviour
{
protected FishingDuelManager FDM;
public FishStatisticsPlayerInfo playerInfo;
public GameObject fishInfoPrefab;
public Transform fishInfoParent;
protected List<DuelFishInfo> duelFishInfos = new List<DuelFishInfo>();
Tables tables;
IUIService uiService;
public GameObject text_winner;
public GameObject text_loser;
public Animation myself;
public Animation enemy;
public TMP_Text text_info;
public GameObject tap_to_skip;
public Button btn_confrim;
/*
* 第一个对局栏目组件延迟播放时间CardInfoShowDelay = 0.25s
后续对局栏目组件的出现间隔时间CardInfoShowInterval = 0.2s
*/
public float CardInfoShowDelay = 0.25f;
public float CardInfoShowInterval = 0.2f;
private void Awake()
{
tables = GContext.container.Resolve<Tables>();
uiService = GContext.container.Resolve<IUIService>();
FDM = GContext.container.Resolve<FishingDuelManager>();
fishInfoPrefab.SetActive(false);
SetFish();
playerInfo.SetData(FDM);
}
private void Start()
{
bool isWin = FDM.SelfModel.CurrentPTS > FDM.EnemyModel.CurrentPTS;
tap_to_skip.SetActive(false);
text_winner.SetActive(isWin);
text_loser.SetActive(!isWin);
PlayShow();
}
void SetFish()
{
List<int> fishItemIDs = FDM.FishItemIDs;
if (fishItemIDs == null || fishItemIDs.Count == 0)
{
return;
}
Item item = null;
for (int i = 0; i < fishItemIDs.Count; i++)
{
GameObject gameObject = Instantiate(fishInfoPrefab, fishInfoParent);
DuelFishInfo duelFishInfo = gameObject.GetComponent<DuelFishInfo>();
item = tables.TbItem[fishItemIDs[i]];
PlayerFishData.SetFishIcon(duelFishInfo.icon_fish,item);//鱼头像
uiService.SetImageSprite(duelFishInfo.icon_fish_tag, $"icon_fish_rate_tag_{item.Quality}");
duelFishInfos.Add(duelFishInfo);
duelFishInfo.gameObject.SetActive(true);
}
}
void PlayShow()
{
var fishInfos = FDM.SelfModel.GetShowDatas();
int myDataCount = fishInfos.Count;
var enemyInfos = FDM.EnemyModel.GetShowDatas();
int enemyDataCount = enemyInfos.Count;
DuelFishingData myData;
DuelFishingData enemyData;
for (int i = 0; i < duelFishInfos.Count; i++)
{
enemyData = null;
myData = null;
if (i < myDataCount && fishInfos[i].isWin)
{
myData = fishInfos[i];
}
if (i < enemyDataCount && enemyInfos[i].isWin)
{
enemyData = enemyInfos[i];
}
if (myData != null)
{
bool isHigh = enemyData == null || myData.point >= enemyData.point;
duelFishInfos[i].text_num_score.SetValue(myData.point.ToString(), isHigh);
float addMy = (1 + myData.fishCardAdd) * (1 + myData.fishRodAdd) - 1;
duelFishInfos[i].text_num_score.SetAddValue(addMy, isHigh);
}
else
{
duelFishInfos[i].text_num_score.SetValue("0", false);
duelFishInfos[i].text_num_score.SetAddValue(-1, false);
}
if (enemyData != null)
{
bool isHigh = myData == null || enemyData.point >= myData.point;
duelFishInfos[i].text_num_enermy_score.SetValue(enemyData.point.ToString(), isHigh);
float addEnemy = (1 + enemyData.fishCardAdd) * (1 + enemyData.fishRodAdd) - 1;
duelFishInfos[i].text_num_enermy_score.SetAddValue(addEnemy, isHigh);
}
else
{
duelFishInfos[i].text_num_enermy_score.SetValue("0", false);
duelFishInfos[i].text_num_enermy_score.SetAddValue(-1, false);
}
duelFishInfos[i].root.SetActive(false);
duelFishInfos[i].gameObject.SetActive(true);
}
StartCoroutine(ShowFish());
}
IEnumerator ShowFish()
{
playerInfo.SetNumShow(FDM.SelfModel.CurrentPTS >= FDM.EnemyModel.CurrentPTS);
var fishInfos = FDM.SelfModel.GetShowDatas();
int myDataCount = fishInfos.Count;
var enemyInfos = FDM.EnemyModel.GetShowDatas();
int enemyDataCount = enemyInfos.Count;
DuelFishingData myData;
DuelFishingData enemyData;
yield return new WaitForSeconds(CardInfoShowDelay);
int selfCurrentPTS = 0;
int enemyCurrentPTS = 0;
for (int i = 0; i < duelFishInfos.Count; i++)
{
enemyData = null;
myData = null;
if (i < myDataCount && fishInfos[i].isWin)
{
myData = fishInfos[i];
}
if (i < enemyDataCount && enemyInfos[i].isWin)
{
enemyData = enemyInfos[i];
}
if (myData != null)
{
selfCurrentPTS += myData.point;
myself.Play();
}
if (enemyData != null)
{
enemyCurrentPTS += enemyData.point;
enemy.Play();
}
playerInfo.SetNum(selfCurrentPTS, enemyCurrentPTS, CardInfoShowInterval);
duelFishInfos[i].root.SetActive(true);
yield return new WaitForSeconds(CardInfoShowInterval);
}
tap_to_skip.SetActive(true);
StartCoroutine(Close());
btn_confrim.onClick.AddListener(Join);
}
IEnumerator Close()
{
int allTime = 5;
while (allTime > 0)
{
text_info.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_61", allTime);
yield return new WaitForSeconds(1);
UIManager.Instance.DestroyUI(UITypes.FishingDuelRewardPanel);
allTime--;
}
text_info.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_61", 0);
Join();
}
async void Join()
{
StopAllCoroutines();
await UIManager.Instance.ShowUI(UITypes.EventFishingDuelRewardPanel);
UIManager.Instance.DestroyUI(UITypes.EventFishingDuelReportRewardPanel);
UIManager.Instance.DestroyUI(UITypes.FishingDuelRewardPanel);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 32bd004058c0911478afc39bcc4524d1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,381 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UniRx;
using System.Linq;
using DG.Tweening;
using System.Collections;
public class EventFishingDuelRewardPanel : BasePanel
{
Tables tables;
FishingDuelManager FDM;
Image img_map;
TMP_Text text_map;
Button btn_claim;
Button btn_confirm;
GameObject winner_tag_my;
GameObject winner_tag;
Transform root;
DuelMatchPlayer myself;
DuelMatchPlayer enemy;
TMP_Text text_change_my;
TMP_Text text_change;
Button btn_chat;
GameObject chat;
GameObject title_reward;
Transform layout_reward;
List<RewardItemNew> rewardItemNews;
bool isWin;
IUIService uiService;
int trophy_before;
DuelChatView selfView;
DuelChatView enemyView;
/*
* RewardFly起始时间 RewardFlyStartTime = 2s
数字滚动起始时间 NumberStartTime= 2.1s
RewardFly和数字滚动的持续时间 RewardPlayDuration= 0.7s
*/
public float NumberStartTime = 2.1f;
public float RewardPlayDuration = 0.7f;
private void Awake()
{
FDM = GContext.container.Resolve<FishingDuelManager>();
FDM.duelData.progress = FDM.curProgress;
trophy_before = FDM.duelData.progress;
uiService = GContext.container.Resolve<IUIService>();
tables = GContext.container.Resolve<Tables>();
isWin = FDM.SetProgress();
root = transform.Find("root");
img_map = root.Find("map/Item/img_map").GetComponent<Image>();
text_map = root.Find("map/text_map").GetComponent<TMP_Text>();
selfView = root.Find("bubble_chat_myself").GetComponent<DuelChatView>();
enemyView = root.Find("bubble_chat_enermy").GetComponent<DuelChatView>();
btn_claim = root.Find("btn_claim/btn_green").GetComponent<Button>();
btn_confirm = root.Find("btn_confirm/btn_green").GetComponent<Button>();
myself = root.Find("myself").GetComponent<DuelMatchPlayer>();
enemy = root.Find("enermy").GetComponent<DuelMatchPlayer>();
winner_tag_my = root.Find("myself/winner_tag").gameObject;
winner_tag = root.Find("enermy/winner_tag").gameObject;
text_change_my = root.Find("myself/point_change/text_num").GetComponent<TMP_Text>();
text_change = root.Find("enermy/point_change/text_num").GetComponent<TMP_Text>();
title_reward = root.Find("title_reward").gameObject;
layout_reward = root.Find("layout_reward");
rewardItemNews = new List<RewardItemNew>();
int layout_reward_count = layout_reward.childCount;
for (int i = 0; i < layout_reward_count; i++)
{
rewardItemNews.Add(layout_reward.GetChild(i).GetComponent<RewardItemNew>());
}
btn_chat = root.Find("btn_chat").GetComponent<Button>();
chat = transform.Find("event_fishingduel_chat").gameObject;
selfView.SetDuelFishingEvent(0);
enemyView.SetDuelFishingEvent(1);
FDM.SelfChatModel.RoleID = 0;
FDM.EnemyChatModel.RoleID = 1;
}
protected override void Start()
{
base.Start();
GContext.OnEvent<RewardPanelClose>().Subscribe(OnRewardPanelClose).AddTo(this);
GContext.Publish(new ConditionTypeEvent(ConditionType.Complete1v1Count, 1));
btn_chat.onClick.AddListener(() =>
{
chat.SetActive(!chat.activeSelf);
});
winner_tag_my.SetActive(isWin);
winner_tag.SetActive(!isWin);
title_reward.SetActive(isWin);
layout_reward.gameObject.SetActive(isWin);
btn_claim.gameObject.SetActive(isWin);
btn_confirm.gameObject.SetActive(!isWin);
btn_claim.onClick.AddListener(Claim);
btn_confirm.onClick.AddListener(Claim);
Init();
FDM.EnemyChatModel.SendMessage(isWin ? (int)RobotDuelChatType.EndDefeat : (int)RobotDuelChatType.EndVictory);
MapData mapData = tables.TbMapData.GetOrDefault(FDM.duelData.mapId);
if (mapData != null)
{
uiService.SetImageSprite(img_map, mapData.Bg);
text_map.text = LocalizationMgr.GetText(mapData.Name_l10n_key);
}
}
void PlayNumWin()
{
myself.fx_ui_matchingPanel_rank.SetActive(true);
int add = FDM.eventSolomain.WinTrophy * FDM.magnification;
int add1 = FDM.enemySolomain.LoseTrophy * FDM.EnemyModel.Mag;
text_change_my.text = $"+{add}";
text_change.text = $"-{add1}";
StartCoroutine(Play(add, add1, true));
}
void PlayNumLose()
{
int add = FDM.eventSolomain.LoseTrophy * FDM.magnification;
int add1 = FDM.enemySolomain.WinTrophy * FDM.EnemyModel.Mag;
text_change_my.text = $"-{add}";
text_change.text = $"+{add1}";
StartCoroutine(Play(add, add1, false));
}
IEnumerator Play(int add, int add1, bool isWin)
{
int trophy_before = this.trophy_before;
int enemy_before = FDM.EnemyModel.RankScore;
yield return new WaitForSeconds(NumberStartTime);
float pre = 0;
if (isWin)
{
DOTween.To(() => pre, x => pre = x, 1, RewardPlayDuration).OnUpdate(
() =>
{
text_change_my.text = $"+{(int)(add * (1 - pre))}";
text_change.text = $"-{(int)(add1 * (1 - pre))}";
myself.text_score.text = ConvertTools.GetNumberString2(trophy_before + (int)(add * pre));
enemy.text_score.text = ConvertTools.GetNumberString2(enemy_before - (int)(add1 * pre));
});
}
else
{
DOTween.To(() => pre, x => pre = x, 1, RewardPlayDuration).OnUpdate(
() =>
{
text_change_my.text = $"-{(int)(add * (1 - pre))}";
text_change.text = $"+{(int)(add1 * (1 - pre))}";
myself.text_score.text = ConvertTools.GetNumberString2(trophy_before - (int)(add * pre));
enemy.text_score.text = ConvertTools.GetNumberString2(enemy_before + (int)(add1 * pre));
});
}
}
void Init()
{
//双方基础信息
IUserService userService = GContext.container.Resolve<IUserService>();
var url = userService.AvatarUrl;
uiService.SetHeadImage(myself.icon_head, url);
myself.text_name.text = userService.DisplayName;
//uiService.SetImageSprite(myself.icon_rank, FDM.eventSolomain.RankIcon);
uiService.SetHeadImage(enemy.icon_head, FDM.EnemyModel.PlayerAvatar);
enemy.text_name.text = FDM.EnemyModel.PlayerName;
//uiService.SetImageSprite(enemy.icon_rank, FDM.robotSolomain.RankIcon);
myself.text_score.text = ConvertTools.GetNumberString2(trophy_before);
enemy.text_score.text = ConvertTools.GetNumberString2(FDM.EnemyModel.RankScore);
PlayerFishData playerFishData = GContext.container.Resolve<PlayerFishData>();
PlayerData playerData = GContext.container.Resolve<PlayerData>();
//胜负显示
int trophy_change = FDM.eventSolomain.WinTrophy * FDM.magnification;
if (isWin)
{
PlayNumWin();
GetReward();
}
else
{
PlayNumLose();
trophy_change = -FDM.eventSolomain.LoseTrophy * FDM.magnification;
}
#if AGG
using (var e = GEvent.GameEvent("single_battle"))
{
int currentRodLevel = playerFishData.GetRodLevel(playerData.equipRodID);
int fishCardLevel = playerFishData.GetFishLevelByMap(FDM.MapId);
int myStar = GContext.container.Resolve<PlayerFishData>().GetRodPiece(playerData.equipRodID);
Dictionary<RodPerkType, string> RodPerkDic = playerFishData.GetRodPerk(playerData.equipRodID, myStar);
float rod_points_bonus = FDM.GetCurRodBuff(RodPerkDic, 5);
e.AddContent("map_id", FDM.duelData.mapId)
.AddContent("tire", FDM.eventSolomain.RankTier)
.AddContent("charge_count", GContext.container.Resolve<PlayerShopData>().GetBuyPaymentAmount())
.AddContent("multiple", FDM.magnification)
.AddContent("result", isWin)
.AddContent("rod_id", playerData.equipRodID)
.AddContent("rod_level", currentRodLevel)
.AddContent("rod_star", myStar)
.AddContent("rod_points_bonus", rod_points_bonus)
.AddContent("card_level", fishCardLevel)
.AddContent("points", FDM.SelfModel.CurrentPTS)
.AddContent("trophy_before", trophy_before)
.AddContent("trophy_change", trophy_change)
.AddContent("trophy_after", FDM.duelData.progress)
.AddContent("reward_list", FDM.eventSolomain.WinReward)
.AddContent("first_complete", FDM.selfIsLastFish ? 1 : 2)
;
int allCount = FDM.FishItemIDs.Count;
var fishInfos = FDM.SelfModel.DuelFishingDatas;
int myDataCount = fishInfos.Count - 1;
Dictionary<int, List<int>> items = new Dictionary<int, List<int>>();
int fish_count = 0;
int slienceTime = 0;
List<int> fish_points_list = new List<int>();
for (int i = 0; i < allCount; i++)
{
fish_points_list.Add(0);
}
for (int i = 0; i < myDataCount && i < allCount; i++)
{
if (fishInfos[i].fishItemId > 0)
{
slienceTime += fishInfos[i].slienceTime;
if (fishInfos[i].isWin)
{
Item item = tables.TbItem.GetOrDefault(fishInfos[i].fishItemId);
if (!items.TryGetValue(item.Quality, out List<int> fish_time))
{
fish_time = new List<int>();
items[item.Quality] = fish_time;
}
fish_time.Add(fishInfos[i].fishingTime /*+ fishInfos[i].castingTime*/);
fish_count++;
fish_points_list[i] = fishInfos[i].point;
}
}
}
string fish_id = string.Join(",", FDM.FishItemIDs);
e.AddContent("cast_time", (float)slienceTime / myDataCount);
e.AddContent("fish_count", fish_count)
.AddContent("fish_id_sequence", fish_id)
.AddContent("fish_points_list", string.Join(",", fish_points_list));
foreach (var item in items)
{
if (item.Value.Count > 0)
{
e.AddContent("fish_time_" + item.Key, (float)item.Value.Sum() / item.Value.Count);
}
}
if (FDM.IsRobot)
{
int star = FDM.EnemyModel.RodStar;
RodPerkDic = playerFishData.GetRodPerk(playerData.equipRodID, star);
rod_points_bonus = FDM.GetCurRodBuff(RodPerkDic, 5);
fishCardLevel = 0;
int mapIndex = (FDM.MapId - 1) % 100;
var CardLevelList = FDM.eventSoloRobot.CardLevel;
for (int i = 0; i < CardLevelList.Count; i++)
{
var CardLevel = CardLevelList[i];
mapIndex = mapIndex % CardLevel.Count;
int cardLevel = CardLevel[mapIndex];
fishCardLevel += cardLevel;
}
List<int> fish_points_list_robot = new List<int>();
for (int i = 0; i < allCount; i++)
{
fish_points_list_robot.Add(0);
}
var robotInfos = FDM.EnemyModel.DuelFishingDatas;
int dataCount = robotInfos.Count - 1;
items = new Dictionary<int, List<int>>();
for (int i = 0; i < dataCount && i < allCount; i++)
{
if (robotInfos[i].fishItemId > 0)
{
if (robotInfos[i].isWin)
{
Item item = tables.TbItem.GetOrDefault(robotInfos[i].fishItemId);
if (!items.TryGetValue(item.Quality, out List<int> fish_time))
{
fish_time = new List<int>();
items[item.Quality] = fish_time;
}
fish_time.Add(robotInfos[i].fishingTime /*+ robotInfos[i].castingTime*/);
fish_points_list_robot[i] = robotInfos[i].point;
}
}
}
e.AddContent("points_robot", FDM.EnemyModel.CurrentPTS)
.AddContent("rod_id_robot", FDM.EnemyModel.RodId)
.AddContent("rod_level_robot", FDM.EnemyModel.RodLevel)
.AddContent("rod_star_robot", star)
.AddContent("rod_points_bonus_robot", rod_points_bonus)
.AddContent("fish_points_list_robot", string.Join(",", fish_points_list_robot))
.AddContent("card_level_robot", fishCardLevel);
foreach (var item in items)
{
if (item.Value.Count > 0)
{
e.AddContent("robot_fish_time_" + item.Key, (float)item.Value.Sum() / item.Value.Count);
}
}
}
}
#endif
}
void GetReward()
{
var rewardItemData = FDM.GetReward();
if (rewardItemData != null)
{
int dataCount = rewardItemData.Count;
int rewardCount = rewardItemNews.Count;
for (int i = 0; i < rewardCount; i++)
{
if (i < dataCount)
{
rewardItemData[i].count *= FDM.magnification;
rewardItemNews[i].SetData(rewardItemData[i]);
}
else
{
rewardItemNews[i].gameObject.SetActive(false);
}
}
GContext.container.Resolve<PlayerItemData>().AddItem(rewardItemData);
}
}
void Claim()
{
CurRewardQCount curRewardQCount = new CurRewardQCount();
GContext.Publish(curRewardQCount);
if (curRewardQCount.count <= 0)
{
QuitDuel();
}
else
{
GContext.Publish(new ShowData());
}
}
void OnRewardPanelClose(RewardPanelClose e)
{
QuitDuel();
}
void QuitDuelToRod()
{
FDM.OnStopShowUIType = UITypes.FishingRodBagPanel;
QuitDuel();
}
void QuitDuelToFishCard()
{
FDM.OnStopShowUIType = UITypes.FishingMapPanel;
QuitDuel();
}
void QuitDuel()
{
UIManager.Instance.DestroyUI(UITypes.EventFishingDuelRewardPanel);
GContext.Publish(new UnloadActToNextAct());
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8a71a7ed92b407b459122816e4ce7a1a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,137 @@
using asap.core;
using cfg;
using GameCore;
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class EventFishingDuelRewardPopupPanel : MonoBehaviour
{
Button btn_close;
Button btn_mask;
TMP_Text text_time;
TMP_Text text_points;
GameObject item;
Image bar;
Tables tables;
FishingEventData fishingEventData;
Timer timer;
private void Awake()
{
tables = GContext.container.Resolve<Tables>();
fishingEventData = GContext.container.Resolve<FishingEventData>();
btn_mask = transform.Find("mask").GetComponent<Button>();
btn_close = transform.Find("btn_close").GetComponent<Button>();
text_time = transform.Find("root/text_time").GetComponent<TMP_Text>();
text_points = transform.Find("root/info/icon_ticket/text_num").GetComponent<TMP_Text>();
bar = transform.Find("root/root_reward/ScrollView/Viewport/Content/bg_bar/bar").GetComponent<Image>();
item = transform.Find("root/root_reward/ScrollView/Viewport/Content/item").gameObject;
item.SetActive(false);
SetData();
}
async void SetData()
{
Transform content = transform.Find("root/root_reward/ScrollView/Viewport/Content");
List<EventSolomain> eventSolomain = tables.TbEventSolomain.DataList;
EventSolomain solomain = eventSolomain[0];
float progress = fishingEventData.duelData.progress;
text_points.text = ConvertTools.GetNumberString2(fishingEventData.duelData.progress);
bar.fillAmount = progress / (float)solomain.TrophyRange[0];
IUIService uiService = GContext.container.Resolve<IUIService>();
int nextIndex = -1;
DuelRankRewardItem duelRewardItem = null;
for (int i = 0; i < eventSolomain.Count; i++)
{
GameObject go = Instantiate(item, content);
go.SetActive(true);
duelRewardItem = go.GetComponent<DuelRankRewardItem>();
uiService.SetImageSprite(duelRewardItem.icon_rank, solomain.RankIcon);
duelRewardItem.text_rank.text = LocalizationMgr.GetText(solomain.RankText_l10n_key);
duelRewardItem.text_point.text = solomain.TrophyRange[0].ToString();
List<ItemData> rewardItemData = GContext.container.Resolve<PlayerItemData>()
.GetItemDataByDropId(solomain.SeasonReward);
if (rewardItemData != null)
{
int dataCount = rewardItemData.Count;
int rewardCount = duelRewardItem.rewardItems.Count;
for (int j = 0; j < rewardCount; j++)
{
if (j < dataCount)
{
duelRewardItem.rewardItems[j].SetData(rewardItemData[j]);
}
else
{
duelRewardItem.rewardItems[j].gameObject.SetActive(false);
}
}
}
duelRewardItem.bg_gray.SetActive(progress > solomain.TrophyRange[1]);
duelRewardItem.bg_normal.SetActive(false);
duelRewardItem.bg_next.SetActive(progress < solomain.TrophyRange[0]);
if (progress >= solomain.TrophyRange[0] && progress <= solomain.TrophyRange[1])
{
duelRewardItem.bg_normal.SetActive(true);
nextIndex = i;
}
if (i < eventSolomain.Count - 1)
{
duelRewardItem.bar.fillAmount = (progress - solomain.TrophyRange[0]) / (solomain.TrophyRange[1] - solomain.TrophyRange[0]);
solomain = eventSolomain[i + 1];
}
}
if (duelRewardItem != null)
{
duelRewardItem.bar.fillAmount = (progress - solomain.TrophyRange[0]) / (eventSolomain[eventSolomain.Count - 2].TrophyRange[1] - eventSolomain[eventSolomain.Count - 2].TrophyRange[0]);
duelRewardItem.bar_root.transform.localScale = new Vector3(1, 0.5f, 1);
}
if (nextIndex == -1)
{
nextIndex = eventSolomain.Count - 2;
}
await Awaiters.NextFrame;
content.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, -nextIndex * 280);
}
private void Start()
{
btn_mask.onClick.AddListener(OnClickClose);
btn_close.onClick.AddListener(OnClickClose);
SetTimer();
}
void OnClickClose()
{
UIManager.Instance.DestroyUI(UITypes.EventFishingDuelRewardPopupPanel);
}
void SetTimer()
{
DateTime endDateTime = fishingEventData.GetEventEndTime(fishingEventData.duelData.eventID)
.AddSeconds(-tables.TbEventSoloConfig.SettlementTime);
TimeSpan now = endDateTime - ZZTimeHelper.UtcNow().UtcNowOffset();
text_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_end",
ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds));
double seconds = now.TotalSeconds;
timer = this.AttachTimer((float)seconds, Refresh,
(elapsed) =>
{
now = endDateTime - ZZTimeHelper.UtcNow().UtcNowOffset();
text_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_end",
ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds));
}, useRealTime: true);
}
void Refresh()
{
timer?.Cancel();
timer = null;
//OnClickClose();
}
private void OnDestroy()
{
timer?.Cancel();
timer = null;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 03f81776852e4574294342e7d5f3b52e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,144 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class EventFishingDuelSettlementPanel : MonoBehaviour
{
FishingEventData fishingEventData;
Tables table;
Button btn_receive;
private EventSolomain solomain;
List<RewardItemNew> rewardItems;
TMP_Text text_rank;
Image icon_rank;
List<ItemData> rewardItemData;
private void Awake()
{
fishingEventData = GContext.container.Resolve<FishingEventData>();
table = GContext.container.Resolve<Tables>();
btn_receive = transform.Find("root/reward/btn_receive/btn_green").GetComponent<Button>();
text_rank = transform.Find("root/text_rank").GetComponent<TMP_Text>();
icon_rank = transform.Find("root/icon_rank").GetComponent<Image>();
Transform layout_reward = transform.Find($"root/layout_reward");
int count = layout_reward.childCount;
rewardItems = new List<RewardItemNew>();
for (int i = 1; i <= count; i++)
{
rewardItems.Add(transform.Find($"root/layout_reward/reward{i}").GetComponent<RewardItemNew>());
}
}
private void Start()
{
SetReward();
btn_receive.onClick.AddListener(OnReveive);
}
void SetReward()
{
var data = table.TbEventSolomain.DataList;
if (fishingEventData.duelData.preProgress > 0)
{
for (int i = data.Count - 1; i >= 0; i--)
{
if (fishingEventData.duelData.preProgress >= data[i].TrophyRange[0])
{
solomain = data[i];
break;
}
}
}
if (solomain == null)
{
solomain = data[0];
}
GContext.container.Resolve<IUIService>().SetImageSprite(icon_rank, solomain.RankIcon);
text_rank.text = LocalizationMgr.GetText(solomain.RankText_l10n_key);
rewardItemData = GContext.container.Resolve<PlayerItemData>()
.GetItemDataByDropId(solomain.SeasonReward);
if (rewardItemData != null)
{
int dataCount = rewardItemData.Count;
int rewardCount = rewardItems.Count;
for (int j = 0; j < rewardCount; j++)
{
if (j < dataCount)
{
rewardItems[j].SetData(rewardItemData[j]);
}
else
{
rewardItems[j].gameObject.SetActive(false);
}
}
}
}
void OnReveive()
{
int preProgress = fishingEventData.duelData.preProgress;
int reset = preProgress - table.TbEventSoloConfig.MinTrophy;
var data = table.TbEventSolomain.DataList;
if (reset > 0)
{
//preProgress = table.TbEventSoloConfig.SettlementTrophy +
// (int)(reset * table.TbEventSoloConfig.SettlementTrophyMultiplier);
var solomain = data[0];
if (preProgress > 0)
{
for (int i = data.Count - 1; i >= 0; i--)
{
if (preProgress >= data[i].TrophyRange[0])
{
solomain = data[i];
break;
}
}
}
preProgress -= solomain.SettleDeducTrophy;
}
//preProgress /= table.TbEventSoloConfig.TrophyMutiple;
//preProgress *= table.TbEventSoloConfig.TrophyMutiple;
if (preProgress < table.TbEventSoloConfig.MinTrophy)
{
preProgress = table.TbEventSoloConfig.MinTrophy;
}
EventSolomain preSolomain = solomain;
for (int i = data.Count - 1; i >= 0; i--)
{
if (preProgress >= data[i].TrophyRange[0])
{
preSolomain = data[i];
break;
}
}
#if AGG
using (var e = GEvent.GameEvent("single_battle_settlement"))
{
e.AddContent("trophy", fishingEventData.duelData.preProgress)
.AddContent("charge_count", GContext.container.Resolve<PlayerShopData>().GetBuyPaymentAmount())
.AddContent("trophy_after", preProgress);
if (solomain != null)
{
e.AddContent("tire", solomain.RankTier)
.AddContent("reward_list", solomain.SeasonReward);
}
if (preSolomain != null)
{
e.AddContent("tier_after", preSolomain.RankTier);
}
}
#endif
GContext.container.Resolve<PlayerItemData>().AddItem(rewardItemData);
fishingEventData.ClaimReward();
UIManager.Instance.DestroyUI(UITypes.EventFishingDuelSettlementPanel);
GContext.Publish(new ShowData());
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e505f07685de4984ab0ac1999d513ed9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,122 @@
using asap.core;
using cfg;
using GameCore;
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class EventFishingduelShopPopupPanel : MonoBehaviour
{
Button btn_close;
Button btn_mask;
TMP_Text text_time;
GameObject item;
GameObject item_special_bait1;
GameObject item_special_bait2;
GameObject item_special_money1;
GameObject item_special_money2;
GameObject item_special_skin;
Tables tables;
FishingEventData fishingEventData;
Timer timer;
List<GameObject> pvpStoreItems = new List<GameObject>();
DateTime endTime;
private void Awake()
{
tables = GContext.container.Resolve<Tables>();
fishingEventData = GContext.container.Resolve<FishingEventData>();
btn_mask = transform.Find("mask").GetComponent<Button>();
btn_close = transform.Find("btn_close").GetComponent<Button>();
text_time = transform.Find("root/text_time").GetComponent<TMP_Text>();
item = transform.Find("root/ScrollView/Viewport/Content/Item").gameObject;
item_special_bait1 = transform.Find("root/ScrollView/Viewport/Content/item_special_bait1").gameObject;
item_special_bait2 = transform.Find("root/ScrollView/Viewport/Content/item_special_bait2").gameObject;
item_special_money1 = transform.Find("root/ScrollView/Viewport/Content/item_special_money1").gameObject;
item_special_money2 = transform.Find("root/ScrollView/Viewport/Content/item_special_money2").gameObject;
item_special_skin = transform.Find("root/ScrollView/Viewport/Content/item_special_skin").gameObject;
item.SetActive(false);
SetData();
}
void SetData()
{
for (int i = 0; i < pvpStoreItems.Count; i++)
{
Destroy(pvpStoreItems[i]);
}
pvpStoreItems.Clear();
endTime = fishingEventData.SetPVPShopTime();
Transform content = transform.Find("root/ScrollView/Viewport/Content");
List<PvpStore> pvpStores = tables.TbPvpStore.DataList;
pvpStores.Sort((a, b) => a.CellId.CompareTo(b.CellId));
for (int i = 0; i < pvpStores.Count; i++)
{
GameObject go;
PvpStore pvpStore = pvpStores[i];
switch (pvpStore.SpecialRoot)
{
case "item_special_bait1":
go = Instantiate(item_special_bait1, content);
break;
case "item_special_bait2":
go = Instantiate(item_special_bait2, content);
break;
case "item_special_money1":
go = Instantiate(item_special_money1, content);
break;
case "item_special_money2":
go = Instantiate(item_special_money2, content);
break;
case "item_special_skin":
go = Instantiate(item_special_skin, content);
break;
default:
go = Instantiate(item, content);
break;
}
go.SetActive(true);
pvpStoreItems.Add(go);
PvpStoreItem pvpStoreItem = go.GetComponent<PvpStoreItem>();
pvpStoreItem.Init(pvpStore, fishingEventData.IsBuyPVPItem(pvpStore.Id));
}
SetTimer();
}
private void Start()
{
btn_mask.onClick.AddListener(OnClickClose);
btn_close.onClick.AddListener(OnClickClose);
}
void OnClickClose()
{
UIManager.Instance.DestroyUI(UITypes.EventFishingduelShopPopupPanel);
}
void SetTimer()
{
TimeSpan now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
text_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_refresh",
ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds));
double seconds = now.TotalSeconds;
timer = this.AttachTimer((float)seconds, Refresh,
(elapsed) =>
{
now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
text_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_refresh",
ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds));
}, useRealTime: true);
}
void Refresh()
{
timer?.Cancel();
timer = null;
SetData();
}
private void OnDestroy()
{
timer?.Cancel();
timer = null;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7e9e165b378ff8144bc380ed67418589
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using asap.core;
using cfg;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class FishConfrimCardInfo : MonoBehaviour
{
public Image icon_fish;
public Image icon_tag;
public TMP_Text text_name;
public TextNumHigher text_num;
public TextNumHigher text_num_enemy;
public GameObject root;
public void SetData(Item item, int selflv, int enemylv)
{
IUIService uiService = GContext.container.Resolve<IUIService>();
uiService.SetImageSprite(icon_tag, $"icon_fish_rate_tag_{item.Quality}");
PlayerFishData.SetFishIcon(icon_fish, item);//鱼头像
string lvStr = LocalizationMgr.GetText("UI_PlayerGradePanel_2");
text_num.SetValue(string.Format(lvStr, selflv), selflv > enemylv);
text_num_enemy.SetValue(string.Format(lvStr, enemylv), selflv < enemylv);
text_name.text = LocalizationMgr.GetText(item.Name_l10n_key);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7028bbc7a6216284e973ca10e61bf691
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,93 @@
using asap.core;
using cfg;
using game;
using GameCore;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class FishConfrimPanel : MonoBehaviour
{
FishingDuelManager FDM;
IUIService uIService;
FishConfrimPlayerInfo playerInfo;
public TMP_Text text_name;
public TMP_Text text_name_enemy;
GameObject card_info;
Transform card_info_content;
Button btn_confrim;
TMP_Text p_text;
public float CardInfoShowDelay = 0.25f;
public float CardInfoShowInterval = 0.2f;
bool joined = false;
List<FishConfrimCardInfo> fishConfrimCardInfos = new List<FishConfrimCardInfo>();
private void Awake()
{
uIService = GContext.container.Resolve<IUIService>();
FDM = GContext.container.Resolve<FishingDuelManager>();
card_info = transform.Find("card_info_content/card_info").gameObject;
card_info.SetActive(false);
card_info_content = transform.Find("card_info_content");
playerInfo = transform.Find("card_info_content/player_info").GetComponent<FishConfrimPlayerInfo>();
playerInfo.SetData(FDM);
text_name.text = FDM.SelfModel.PlayerName;
text_name_enemy.text = FDM.EnemyModel.PlayerName;
btn_confrim = transform.Find("btn_confrim/btn_green").GetComponent<Button>();
p_text = transform.Find("btn_confrim/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
}
private void Start()
{
btn_confrim.transform.parent.gameObject.SetActive(false);
List<int> itemIds = FDM.FishItemIDs;
Tables tables = GContext.container.Resolve<Tables>();
for (int i = 0; i < itemIds.Count; i++)
{
Item item = tables.GetItemData(itemIds[i]);
if (item == null) continue;
GameObject go = Instantiate(card_info, card_info_content);
go.SetActive(true);
FishConfrimCardInfo cardInfo = go.GetComponent<FishConfrimCardInfo>();
if (cardInfo != null)
{
cardInfo.SetData(item, FDM.SelfModel.CarLevels[i], FDM.EnemyModel.CarLevels[i]);
}
cardInfo.root.SetActive(false);
fishConfrimCardInfos.Add(cardInfo);
}
StartCoroutine(Close());
}
IEnumerator Close()
{
yield return new WaitForSeconds(CardInfoShowDelay);
for (int i = 0; i < fishConfrimCardInfos.Count; i++)
{
fishConfrimCardInfos[i].root.SetActive(true);
yield return new WaitForSeconds(CardInfoShowInterval);
}
btn_confrim.onClick.AddListener(Join);
btn_confrim.transform.parent.gameObject.SetActive(true);
int allTime = FDM.eventSoloConfig.StartTime;
while (allTime > 0)
{
p_text.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_41", allTime);
yield return new WaitForSeconds(1);
allTime--;
}
p_text.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_41", 0);
Join();
}
async void Join()
{
joined = true;
StopAllCoroutines();
GContext.Publish(new UnloadActToNextAct("FishingDuelAct"));
FDM.OnJoin();
await Awaiters.Seconds(1f);
UIManager.Instance.DestroyUI(UITypes.EventFishingDuelPanel);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6cb03cad7d49aaf46bba124d92c73405
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using GameCore;
using System.Linq;
public class FishConfrimPlayerInfo : FishPlayerInfo
{
public override void SetData(FishingDuelManager FDM)
{
base.SetData(FDM);
string lvStr = LocalizationMgr.GetText("UI_PlayerGradePanel_2");
int selflv = FDM.SelfModel.CarLevels.Sum();
int enemylv = FDM.EnemyModel.CarLevels.Sum();
text_num.SetValue(string.Format(lvStr, selflv), selflv > enemylv);
text_num_enemy.SetValue(string.Format(lvStr, enemylv), selflv < enemylv);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 34b54225ce18e2a4e848efc6f93472ef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using GameCore;
using UnityEngine;
public class FishPlayerInfo : MonoBehaviour
{
public Head selfHead;
public Head enemyHead;
public TextNumHigher text_num;
public TextNumHigher text_num_enemy;
public virtual void SetData(FishingDuelManager FDM)
{
if (FDM == null) return;
selfHead.SetData(FDM.SelfModel.PlayerAvatar);
enemyHead.SetData(FDM.EnemyModel.PlayerAvatar);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ff8837c24b055694982963b4955b4f7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,46 @@
using DG.Tweening;
using TMPro;
public class FishStatisticsPlayerInfo : FishPlayerInfo
{
TMP_Text num_my;
TMP_Text num_enemy;
int oldSelfValue;
int oldEnermyValue;
public void SetNumShow(bool higher)
{
text_num.SetValue("0", higher);
text_num_enemy.SetValue("0", !higher);
if (higher)
{
num_my = text_num.text_num_higher;
num_enemy = text_num_enemy.text_num;
}
else
{
num_my = text_num.text_num;
num_enemy = text_num_enemy.text_num_higher;
}
}
public void SetNum(int selfValue, int enermyValue, float time)
{
DOTween.Kill("SetNumInfo");
if (selfValue > 0 && num_my != null)
{
DOTween.To(() => oldSelfValue, x => oldSelfValue = x, selfValue, time).OnUpdate(() =>
{
num_my.text = oldSelfValue.ToString();
}).SetId("SetNumInfo");
//num_my.text = selfValue.ToString();
}
if (enermyValue > 0 && num_enemy != null)
{
DOTween.To(() => oldEnermyValue, x => oldEnermyValue = x, enermyValue, time).OnUpdate(() =>
{
num_enemy.text = oldEnermyValue.ToString();
}).SetId("SetNumInfo");
//num_enemy.text = enermyValue.ToString();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c1c159d1f7fef534c9bdd9e5b3897d78
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,6 @@
public interface IDuelChatView
{
void Dialogue(string chat);
void Emoji(string chat);
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bb6b46832bffbe74699f40fb261ea89a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,6 @@
public interface IDuelUIView
{
void Fishing(int itemID);
void EndFishing(int index, FishInfoData data, bool isEnd);
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 356fe4d02ea9bae4ca3adc09a23cd808
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,92 @@
using asap.core;
using cfg;
using game;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class PvpStoreItem : MonoBehaviour
{
[SerializeField]
protected Button btn_buy;
[SerializeField]
protected RewardItemNew rewardItem;
[SerializeField]
protected GameObject go_soldOut;
[SerializeField]
protected TMP_Text btn_buy_text;
protected PvpStore pvpStore;
protected ItemData itemData;
private void Reset()
{
btn_buy = transform.Find("position/btn_purchase/btn_green").GetComponent<Button>();
rewardItem = transform.Find("position/reward").GetComponent<RewardItemNew>();
go_soldOut = transform.Find("position/soldout").gameObject;
btn_buy_text = transform.Find("position/btn_purchase/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
}
private void Start()
{
btn_buy.onClick.AddListener(OnBuy);
}
public void Init(PvpStore pvpStore, bool soldOut)
{
this.pvpStore = pvpStore;
itemData = new ItemData(pvpStore.ItemId, pvpStore.ItemNumber);
if (itemData.id == 1002)
{
itemData.count = GContext.container.Resolve<PlayerItemData>().GetExtraCoinMag(itemData.count);
}
rewardItem.SetData(itemData);
btn_buy_text.text = pvpStore.TokenNumber.ToString();
go_soldOut.SetActive(soldOut);
btn_buy.gameObject.SetActive(!soldOut);
Init();
}
protected virtual void Init()
{
}
void OnBuy()
{
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
if (pvpStore.TokenNumber > fishingEventData.PVPToken)
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_87"));
//代币不足
return;
}
if (fishingEventData.BuyPVPItem(pvpStore.Id))
{
fishingEventData.AddPVPToken(-pvpStore.TokenNumber);
GContext.Publish(new ResAddEvent(pvpStore.TokenId));
itemData.curCount = (ulong)GContext.container.Resolve<PlayerItemData>().GetItemCount(itemData.id);
GContext.Publish(new ShowData(itemData));
GContext.container.Resolve<PlayerItemData>().AddItem(itemData);
GContext.Publish(new ShowData());
BuyEnd();
var duelData = fishingEventData.duelData;
#if AGG
using (var e = GEvent.GameEvent("pvp_store"))
{
e.AddContent("cost_token_id", 2052)
.AddContent("cost_token_count", pvpStore.TokenNumber)
.AddContent("change_type", pvpStore.Type)
.AddContent("item_id", itemData.id)
.AddContent("cost_token_count_sum", duelData == null ? 0 : duelData.rePVPToken)
.AddContent("available_token", fishingEventData.PVPToken)
.AddContent("change_count", itemData.count);
}
#endif
}
}
protected virtual void BuyEnd()
{
go_soldOut.SetActive(true);
btn_buy.gameObject.SetActive(false);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9801feee5b46b8244b6795b058d4ebe7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
using asap.core;
using cfg;
using GameCore;
using UnityEngine;
public class PvpStoreItemBait : PvpStoreItem
{
protected override void Init()
{
rewardItem.icon.gameObject.SetActive(false);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 42491999d4ffcb8409b874358b8da274
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
public class PvpStoreItemMoney : PvpStoreItem
{
protected override void Init()
{
rewardItem.icon.gameObject.SetActive(false);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f93818682726cf94ab307a6071e3d532
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using asap.core;
using cfg;
using GameCore;
using UnityEngine;
public class PvpStoreItemSkin : PvpStoreItem
{
[SerializeField]
protected GameObject owned;
protected override void Init()
{
PlayerFishData playerFishData = GContext.container.Resolve<PlayerFishData>();
Item item = GContext.container.Resolve<Tables>().GetItemData(pvpStore.ItemId);
bool alreadyOwned = false;
if (item != null && item.Type == 3)
{
switch (item.SubType)
{
case 3:
alreadyOwned = playerFishData.IsSkinUnlocked(item.RedirectID);
break;
case 11:
alreadyOwned = playerFishData.IsGloveUnlocked(item.RedirectID);
break;
}
}
owned.SetActive(alreadyOwned);
btn_buy.gameObject.SetActive(!alreadyOwned);
}
protected override void BuyEnd()
{
owned.SetActive(true);
btn_buy.gameObject.SetActive(false);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ff74bc4231cf3e0499c0977d6d955169
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
using TMPro;
using UnityEngine;
public class TextNumHigher : MonoBehaviour
{
public TMP_Text text_num;
public TMP_Text text_num_higher;
private void Reset()
{
text_num = transform.Find("text_num").GetComponent<TMP_Text>();
text_num_higher = transform.Find("text_num_higher").GetComponent<TMP_Text>();
}
public void SetValue(string num, bool higher)
{
text_num.text = text_num_higher.text = num;
text_num_higher.gameObject.SetActive(higher);
text_num.gameObject.SetActive(!higher);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8202397839d93ae409eeef02e3d94773
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
using TMPro;
public class TextNumHigherAdd : TextNumHigher
{
public TMP_Text text_num_add;
public TMP_Text text_num_higher_add;
public void SetAddValue(float num, bool higher)
{
if (higher)
{
if (num < 0)
{
text_num_higher_add.gameObject.SetActive(false);
}
else
{
text_num_higher_add.text = num.ToString("P0");
}
}
else
{
if (num < 0)
{
text_num_add.gameObject.SetActive(false);
}
else
{
text_num_add.text = num.ToString("P0");
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2ce6eac1afa540e4a95c158f068c2838
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class TicketTips : MonoBehaviour
{
public Button hide;
public TMP_Text text_info;
public Transform ticket_tips;
private void Start()
{
hide.onClick.AddListener(() =>
{
gameObject.SetActive(false);
});
}
public void SetText(string text)
{
text_info.text = text;
}
public void SetPos(Vector3 pos)
{
ticket_tips.position = pos;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3aa30b865a7f88149bb917e97533ede1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class duel_rod_trait_tips : MonoBehaviour
{
public Button close;
public GameObject[] tips;
public Image[] trait_icons;
public TMP_Text[] trait_names;
private void Start()
{
close.onClick.AddListener(() =>
{
gameObject.SetActive(false);
});
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eef82a7a40cd8aa4dad826399bb30e2a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,73 @@
using asap.core;
using cfg;
using GameCore;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class event_fishingduel_chat : MonoBehaviour
{
Transform layout_chat;
GameObject layout_chat_item;
Transform emoji_tips;
GameObject emoji_tips_item;
Button btnClose;
FishingDuelManager FDM;
private void Awake()
{
btnClose = transform.Find("btn_close").GetComponent<Button>();
FDM = GContext.container.Resolve<FishingDuelManager>();
layout_chat = transform.Find("root/layout_chat");
if (layout_chat != null)
{
layout_chat_item = layout_chat.Find("bubble_chat").gameObject;
layout_chat_item.SetActive(false);
}
emoji_tips = transform.Find("root/emoji_tips");
if (emoji_tips != null)
{
emoji_tips_item = emoji_tips.Find("emoji").gameObject;
emoji_tips_item.SetActive(false);
}
btnClose.onClick.AddListener(() => { gameObject.SetActive(false); });
}
private void Start()
{
IUIService uiService = GContext.container.Resolve<IUIService>();
List<EventSoloQuickMessage> messages = GContext.container.Resolve<Tables>().TbEventSoloQuickMessage.DataList;
for (int i = 0; i < messages.Count; i++)
{
EventSoloQuickMessage message = messages[i];
GameObject item = null;
if (message.Type == 1)
{
item = Instantiate(emoji_tips_item, emoji_tips);
item.SetActive(true);
Image image = item.transform.Find("icon").GetComponent<Image>();
uiService.SetImageSprite(image, message.Emoji);
}
else if (message.Type == 2)
{
item = Instantiate(layout_chat_item, layout_chat);
item.SetActive(true);
TMP_Text text = item.transform.Find("text_chat").GetComponent<TMP_Text>();
text.text = LocalizationMgr.GetText(message.Text_l10n_key);
}
if (item != null)
{
Button button = item.GetComponent<Button>();
if (button != null)
{
button.onClick.AddListener(() =>
{
FDM.SendQuickMessage(message.ID);
gameObject.SetActive(false);
});
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 913c1007b5c5da94e9fac5c3eb425386
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More