2021-04-08 20:09:59 +08:00
|
|
|
|
using System;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
using System.Collections.Generic;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
using System.Net;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
[ActorMessageHandler]
|
|
|
|
|
public class C2M_GetMapCoinHandler : AMActorLocationRpcHandler<Unit, C2M_GetMapCoin, M2C_GetMapCoin>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
protected override async ETTask Run(Unit unit, C2M_GetMapCoin request, M2C_GetMapCoin response, Action reply)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (!unit.IsTeamLeader)
|
|
|
|
|
{
|
|
|
|
|
response.Message = "你不是队长!";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
|
|
|
if (!MapCoinComponent.instance.HasCoinMonster(unitScene.MapId))
|
|
|
|
|
{
|
|
|
|
|
response.Message = "金币怪消失";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Team team = TeamComponent.Instance.Get(unit.TeamLeaderId);
|
2021-04-11 19:50:39 +08:00
|
|
|
|
LinkedList<Unit> list = team.GetUnits();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
bool hasCount = false;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (Unit u in list)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
PlayerData data = u.GetComponent<PlayerData>();
|
|
|
|
|
hasCount = hasCount || data.mapCoinCount > 0;
|
|
|
|
|
}
|
|
|
|
|
if (!hasCount)
|
|
|
|
|
{
|
|
|
|
|
response.Message = "没有次数了";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
MapCoinComponent.instance.RemoveMonster(unit.Id, unitScene.MapId);
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (Unit u in list)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
PlayerData data = u.GetComponent<PlayerData>();
|
|
|
|
|
if (data.mapCoinCount <= 0) continue;
|
|
|
|
|
data.mapCoinCount--;
|
|
|
|
|
int count = RandomHelper.RandomArray_Len2(ConstDefine.MapCoinArr);
|
|
|
|
|
CharacterHelper.AddMoney(u, CharacterHelper.MoneyType.Coin, count);
|
|
|
|
|
MessageHelper.SendActor(u, new M2C_SendTip { Message = $"恭喜你获得{count}铜币" });
|
|
|
|
|
}
|
|
|
|
|
reply();
|
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|