using LitJson;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
//传功(双修)
|
public class FairyFeastModel : Model, IBeforePlayerDataInitialize
|
{
|
RoleParticularModel roleParticularModel { get { return ModelCenter.Instance.GetModel<RoleParticularModel>(); } }
|
DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
|
|
|
public float transmitCostSeconds { get; private set; }
|
public float transmitExpSeconds { get; private set; }
|
public int refuseCGSeconds;
|
public int expFlyStage { get; private set; }
|
public int expFlyCount { get; private set; }
|
public ulong totalExp { get; private set; }
|
public int activeOpenday;
|
public int[][] chuangongAwards;
|
|
Dictionary<int, HourMinute> normalQuestionTimes = new Dictionary<int, HourMinute>();
|
public Dictionary<int, float> inviteTimes = new Dictionary<int, float>(); //邀请时间
|
|
public override void Init()
|
{
|
ParseConfig();
|
}
|
|
public override void UnInit()
|
{
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
transmitPlayer = 0;
|
totalExp = 0;
|
inviteTimes.Clear();
|
}
|
|
void ParseConfig()
|
{
|
var config = FuncConfigConfig.Get("FamilyChuangong");
|
activeOpenday = int.Parse(config.Numerical1); //开服前几天的活动
|
expFlyStage = int.Parse(config.Numerical3);
|
expFlyCount = expFlyStage;
|
chuangongAwards = JsonMapper.ToObject<int[][]>(config.Numerical4);
|
config = FuncConfigConfig.Get("FairyFeastTransmit");
|
transmitCostSeconds = float.Parse(config.Numerical1) / 1000;
|
transmitExpSeconds = transmitCostSeconds;
|
refuseCGSeconds = int.Parse(config.Numerical2);
|
}
|
|
public void UpdateTransmitState(HA510_tagMCChuangongResult package)
|
{
|
totalExp = package.Exp + (ulong)package.ExpPoint*100000000;
|
FairyFeastTransmitShow.Instance.Open();
|
}
|
|
public struct InvitePlayer
|
{
|
public int playerID;
|
public string playerName;
|
public int job;
|
public int face;
|
public int facePic;
|
}
|
public InvitePlayer invitePlayer;
|
public event Action OnInvitePlayerEvent;
|
public void UpdateChuangongInviteInfo(HA411_tagGCChuangongInviteInfo netPack)
|
{
|
//顶掉其他的邀请
|
if (!invitePlayer.Equals(default(InvitePlayer)) && invitePlayer.playerID != 0 && invitePlayer.playerID != (int)netPack.PlayerID)
|
{
|
SendChuangongOP(2, invitePlayer.playerID, 0);
|
}
|
invitePlayer = new InvitePlayer()
|
{
|
playerID = (int)netPack.PlayerID,
|
playerName = UIHelper.ServerStringTrim(netPack.Name),
|
job = netPack.Job,
|
face = (int)netPack.Face,
|
facePic = (int)netPack.FacePic,
|
|
};
|
if(!WindowCenter.Instance.IsOpen<ChuangongInviteWin>())
|
{
|
WindowCenter.Instance.Open<ChuangongInviteWin>();
|
}
|
OnInvitePlayerEvent?.Invoke();
|
}
|
|
public void SendChuangongOP(int opType, int playerID, int opdata)
|
{
|
|
var pak = new CA615_tagCMChuangongOP();
|
pak.OPType = (byte)opType;
|
pak.PlayerID = (uint)playerID;
|
pak.OPData = (byte)opdata;
|
GameNetSystem.Instance.SendInfo(pak);
|
if (opType == 2)
|
{
|
invitePlayer = default(InvitePlayer);
|
}
|
}
|
public void TransmitComplete()
|
{
|
//CA508_tagCMDoFBAction pak = new CA508_tagCMDoFBAction();
|
//pak.ActionType = 1;
|
//pak.ActionInfo = 0;
|
//GameNetSystem.Instance.SendInfo(pak);
|
}
|
|
public List<PlayerFairyData.FairyMember> displayFairyMembers = new List<PlayerFairyData.FairyMember>();
|
public uint transmitPlayer = 0; //传功的画面表现
|
|
public void Transmit(PlayerFairyData.FairyMember fairyMember)
|
{
|
if (fairyMember.PlayerID == PlayerDatas.Instance.baseData.PlayerID)
|
{
|
return;
|
}
|
//if (fairyMember.Exattr2 != 0)
|
//{
|
// SysNotifyMgr.Instance.ShowTip("FairyFeastPlayerOffline");
|
// return;
|
//}
|
|
inviteTimes[(int)fairyMember.PlayerID] = Time.time;
|
SendChuangongOP(1, (int)fairyMember.PlayerID, 0);
|
}
|
|
//收到开始传功 - 请求对方角色信息(外观使用) - 请求传功结果(经验)- 展示传功过程
|
public void UpdateChuangongStart(HA412_tagGCChuangongStart netPack)
|
{
|
roleParticularModel.ViewPlayerCacheData((int)netPack.PlayerID);
|
transmitPlayer = netPack.PlayerID;
|
var completedTimes = dailyQuestModel.GetDailyQuestCompletedTimes((int)DailyQuestType.FairyChuanGong);
|
var totalTimes = dailyQuestModel.GetDailyQuestTotalTimes((int)DailyQuestType.FairyChuanGong);
|
if (completedTimes >= totalTimes)
|
{
|
//已获得奖励 直接展示
|
SysNotifyMgr.Instance.ShowTip("ChuangongFinish");
|
totalExp = 0;
|
FairyFeastTransmitShow.Instance.Open();
|
}
|
else
|
{
|
Clock.AlarmAfter(0.1, () =>
|
{
|
SendChuangongOP(3, 0, 0);
|
});
|
}
|
if (WindowCenter.Instance.IsOpen<FairyFeastTransmitListWin>())
|
{
|
WindowCenter.Instance.Close<FairyFeastTransmitListWin>();
|
}
|
}
|
}
|
}
|
|