Browse Source

增加天气系统,修改小屋播种的BUG

master
wserver/wangdisen 3 years ago
parent
commit
f9d7df3326
  1. BIN
      Config/WeatherConfigCategory.bytes
  2. 12
      Excel/Json/c/WeatherConfig.txt
  3. 12
      Excel/Json/s/WeatherConfig.txt
  4. BIN
      Excel/WeatherConfig.xlsx
  5. 21
      Proto/OuterMessage.proto
  6. 6
      Server/Hotfix/Demo/Cabin/Handler/C2M_CabinSeedHandler.cs
  7. 8
      Server/Hotfix/Demo/Unit/UnitFactory.cs
  8. 12
      Server/Hotfix/Demo/Unit/UnitHelper.cs
  9. 3
      Server/Hotfix/Server.Hotfix.csproj
  10. 2
      Server/Model/Base/MongoRegister.cs
  11. 36
      Server/Model/Generate/Message/OuterMessage.cs
  12. 3
      Server/Model/Generate/Message/OuterOpcode.cs
  13. BIN
      Unity/Assets/Bundles/Config/WeatherConfigCategory.bytes
  14. 1
      Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs
  15. 33
      Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs
  16. 13
      Unity/Codes/Hotfix/Demo/Weather/Handler/M2C_NtfWeatherEndHandler.cs
  17. 10
      Unity/Codes/Hotfix/Demo/Weather/Handler/M2C_NtfWeatherStartHandler.cs
  18. 125
      Unity/Codes/Hotfix/Demo/Weather/WeatherSystem.cs
  19. 1
      Unity/Codes/Model/Demo/People/People.cs
  20. 10
      Unity/Codes/Model/Demo/Unit/Unit.cs
  21. 14
      Unity/Codes/Model/Demo/Weather/Weather.cs
  22. 36
      Unity/Codes/Model/Generate/Message/OuterMessage.cs
  23. 3
      Unity/Codes/Model/Generate/Message/OuterOpcode.cs

BIN
Config/WeatherConfigCategory.bytes

Binary file not shown.

12
Excel/Json/c/WeatherConfig.txt

@ -1,13 +1,13 @@
{"list":[
{"_t":"WeatherConfig","_id":1,"Name":"大风","Disease":200,"Injury":0,"DurableDestroy":2,"LaborVariety":0,"Duration":[5,10],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[10,15],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":1,"Name":"大风","Disease":200,"Injury":0,"DurableDestroy":2,"LaborVariety":0,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[10,15],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":2,"Name":"小雨","Disease":250,"Injury":0,"DurableDestroy":1,"LaborVariety":1,"Duration":[20,30],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":3,"Name":"暴雨","Disease":300,"Injury":0,"DurableDestroy":3,"LaborVariety":2,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":4,"Name":"雷雨","Disease":350,"Injury":0,"DurableDestroy":5,"LaborVariety":3,"Duration":[5,10],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":5,"Name":"冰雹","Disease":300,"Injury":200,"DurableDestroy":15,"LaborVariety":3,"Duration":[3,5],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":4,"Name":"雷雨","Disease":350,"Injury":0,"DurableDestroy":5,"LaborVariety":3,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":5,"Name":"冰雹","Disease":300,"Injury":200,"DurableDestroy":15,"LaborVariety":3,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":6,"Name":"高温","Disease":400,"Injury":0,"DurableDestroy":0,"LaborVariety":3,"Duration":[50,100],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[10,15],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":7,"Name":"雪","Disease":400,"Injury":0,"DurableDestroy":5,"LaborVariety":3,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":8,"Name":"暴雪","Disease":500,"Injury":0,"DurableDestroy":10,"LaborVariety":5,"Duration":[5,10],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":9,"Name":"寒流","Disease":400,"Injury":0,"DurableDestroy":0,"LaborVariety":4,"Duration":[5,10],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[20,40],"ICON":"","Describe":"随机村民颤抖"},
{"_t":"WeatherConfig","_id":10,"Name":"地震","Disease":0,"Injury":300,"DurableDestroy":30,"LaborVariety":10,"Duration":[3,5],"CD":[30],"WeaterEffect":"","SpecialEfficacyCD":[5,10],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":8,"Name":"暴雪","Disease":500,"Injury":0,"DurableDestroy":10,"LaborVariety":5,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":9,"Name":"寒流","Disease":400,"Injury":0,"DurableDestroy":0,"LaborVariety":4,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[20,40],"ICON":"","Describe":"随机村民颤抖"},
{"_t":"WeatherConfig","_id":10,"Name":"地震","Disease":0,"Injury":300,"DurableDestroy":30,"LaborVariety":10,"Duration":[10,20],"CD":[30,30],"WeaterEffect":"","SpecialEfficacyCD":[5,10],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":11,"Name":"流感","Disease":700,"Injury":0,"DurableDestroy":0,"LaborVariety":0,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[10,20],"ICON":"","Describe":"随机村民打喷嚏"},
]}

12
Excel/Json/s/WeatherConfig.txt

@ -1,13 +1,13 @@
{"list":[
{"_t":"WeatherConfig","_id":1,"Name":"大风","Disease":200,"Injury":0,"DurableDestroy":2,"LaborVariety":0,"Duration":[5,10],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[10,15],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":1,"Name":"大风","Disease":200,"Injury":0,"DurableDestroy":2,"LaborVariety":0,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[10,15],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":2,"Name":"小雨","Disease":250,"Injury":0,"DurableDestroy":1,"LaborVariety":1,"Duration":[20,30],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":3,"Name":"暴雨","Disease":300,"Injury":0,"DurableDestroy":3,"LaborVariety":2,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":4,"Name":"雷雨","Disease":350,"Injury":0,"DurableDestroy":5,"LaborVariety":3,"Duration":[5,10],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":5,"Name":"冰雹","Disease":300,"Injury":200,"DurableDestroy":15,"LaborVariety":3,"Duration":[3,5],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":4,"Name":"雷雨","Disease":350,"Injury":0,"DurableDestroy":5,"LaborVariety":3,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":5,"Name":"冰雹","Disease":300,"Injury":200,"DurableDestroy":15,"LaborVariety":3,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":6,"Name":"高温","Disease":400,"Injury":0,"DurableDestroy":0,"LaborVariety":3,"Duration":[50,100],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[10,15],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":7,"Name":"雪","Disease":400,"Injury":0,"DurableDestroy":5,"LaborVariety":3,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":8,"Name":"暴雪","Disease":500,"Injury":0,"DurableDestroy":10,"LaborVariety":5,"Duration":[5,10],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":9,"Name":"寒流","Disease":400,"Injury":0,"DurableDestroy":0,"LaborVariety":4,"Duration":[5,10],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[20,40],"ICON":"","Describe":"随机村民颤抖"},
{"_t":"WeatherConfig","_id":10,"Name":"地震","Disease":0,"Injury":300,"DurableDestroy":30,"LaborVariety":10,"Duration":[3,5],"CD":[30],"WeaterEffect":"","SpecialEfficacyCD":[5,10],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":8,"Name":"暴雪","Disease":500,"Injury":0,"DurableDestroy":10,"LaborVariety":5,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[0],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":9,"Name":"寒流","Disease":400,"Injury":0,"DurableDestroy":0,"LaborVariety":4,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[20,40],"ICON":"","Describe":"随机村民颤抖"},
{"_t":"WeatherConfig","_id":10,"Name":"地震","Disease":0,"Injury":300,"DurableDestroy":30,"LaborVariety":10,"Duration":[10,20],"CD":[30,30],"WeaterEffect":"","SpecialEfficacyCD":[5,10],"ICON":"","Describe":""},
{"_t":"WeatherConfig","_id":11,"Name":"流感","Disease":700,"Injury":0,"DurableDestroy":0,"LaborVariety":0,"Duration":[10,20],"CD":[2,3],"WeaterEffect":"","SpecialEfficacyCD":[10,20],"ICON":"","Describe":"随机村民打喷嚏"},
]}

BIN
Excel/WeatherConfig.xlsx

Binary file not shown.

21
Proto/OuterMessage.proto

@ -190,6 +190,7 @@ message UnitProto
repeated string EventNames = 22;
repeated int64 FighterList = 24;
repeated MonsterGroupProto MonsterGroupList = 25;
WeatherProto Weather = 26;
}
message M2C_CreateUnits // IActorMessage
@ -1441,4 +1442,24 @@ message M2C_CabinHarvest // IActorLocationResponse
int32 RpcId = 90;
int32 Error = 91;
string Message = 92;
}
message WeatherProto
{
int64 Id = 1;
int32 ConfigId = 2;
int32 State = 3; //1
}
message M2C_NtfWeatherStart // IActorMessage
{
int32 WeatherCfgId = 1;
}
message M2C_NtfWeatherEnd // IActorMessage
{
int32 WeatherCfgId = 1;
}

6
Server/Hotfix/Demo/Cabin/Handler/C2M_CabinSeedHandler.cs

@ -17,6 +17,10 @@ namespace ET
res.Error = ErrorCode.ERR_PeopleNotFound;
}
if (GameUtil.IsErrorSuc(res.Error) && farmland.FarmlandState != FarmlandState.FARMLAND_STATE_FREE)
{
res.Error = ErrorCode.ERR_FarmlandNotFree;
}
var cabin = unit.GetGrandChild<Cabin>(farmland.CabinId);
if (GameUtil.IsErrorSuc(res.Error) && cabin == null)
{
@ -35,7 +39,7 @@ namespace ET
if (GameUtil.IsErrorSuc(res.Error))
{
res.Error = FarmlandOperate.FarmlandSeed(unit, farmland, request.CropCfgId);
res.Error = CabinOperate.CabinSeed(unit, farmland, request.CropCfgId);
}
reply();

8
Server/Hotfix/Demo/Unit/UnitFactory.cs

@ -67,8 +67,8 @@ namespace ET
InitStoreComponent(unit);
InitMenuComponent(unit);
InitPrescriptionComponent(unit);
InitWeather(unit);
}
unit.InitPeopleNumberic();
return unit;
@ -194,6 +194,12 @@ namespace ET
}*/
}
public static void InitWeather(Unit unit)
{
Weather weather = unit.AddChild<Weather>();
unit.WeatherId = weather.Id;
}
}
}

12
Server/Hotfix/Demo/Unit/UnitHelper.cs

@ -158,5 +158,17 @@ namespace ET
{
MessageHelper.SendToClient(unit,new M2C_NotifyUpdateValley(){Ks = Ks,Vs = Vs});
}
public static void NotifyWeatherStart(Unit unit, int cfgId)
{
MessageHelper.SendToClient(unit,new M2C_NtfWeatherStart(){WeatherCfgId = cfgId});
}
public static void NotifyWeatherEnd(Unit unit, int cfgId)
{
MessageHelper.SendToClient(unit,new M2C_NtfWeatherEnd(){WeatherCfgId = cfgId});
}
}
}

3
Server/Hotfix/Server.Hotfix.csproj

@ -160,6 +160,9 @@
<Compile Include="..\..\Unity\Codes\Hotfix\Demo\Unit\UnitSystem.cs">
<Link>Demo\Unit\UnitSystem.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Codes\Hotfix\Demo\Weather\WeatherSystem.cs">
<Link>Demo\Weather\WeatherSystem.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Codes\Model\Demo\Config\WorldParam.cs">
<Link>Demo\WorldParam.cs</Link>
</Compile>

2
Server/Model/Base/MongoRegister.cs

@ -22,7 +22,7 @@ namespace ET
BsonSerializer.RegisterSerializer(typeof(Quaternion), new StructBsonSerialize<Quaternion>());
BsonSerializer.RegisterSerializer(typeof(ResourceAttri), new StructBsonSerialize<ResourceAttri>());
BsonSerializer.RegisterSerializer(typeof(ExtraOut), new StructBsonSerialize<ExtraOut>());
BsonSerializer.RegisterSerializer(typeof(WatherInfo), new StructBsonSerialize<WatherInfo>());
BsonSerializer.RegisterSerializer(typeof(WeatherInfo), new StructBsonSerialize<WeatherInfo>());
#elif ROBOT
BsonSerializer.RegisterSerializer(typeof(Quaternion), new StructBsonSerialize<Quaternion>());
BsonSerializer.RegisterSerializer(typeof(Vector3), new StructBsonSerialize<Vector3>());

36
Server/Model/Generate/Message/OuterMessage.cs

@ -446,6 +446,9 @@ namespace ET
[ProtoMember(25)]
public List<MonsterGroupProto> MonsterGroupList = new List<MonsterGroupProto>();
[ProtoMember(26)]
public WeatherProto Weather { get; set; }
}
[Message(OuterOpcode.M2C_CreateUnits)]
@ -2999,4 +3002,37 @@ namespace ET
}
[Message(OuterOpcode.WeatherProto)]
[ProtoContract]
public partial class WeatherProto: Object
{
[ProtoMember(1)]
public long Id { get; set; }
[ProtoMember(2)]
public int ConfigId { get; set; }
[ProtoMember(3)]
public int State { get; set; }
}
[Message(OuterOpcode.M2C_NtfWeatherStart)]
[ProtoContract]
public partial class M2C_NtfWeatherStart: Object, IActorMessage
{
[ProtoMember(1)]
public int WeatherCfgId { get; set; }
}
[Message(OuterOpcode.M2C_NtfWeatherEnd)]
[ProtoContract]
public partial class M2C_NtfWeatherEnd: Object, IActorMessage
{
[ProtoMember(1)]
public int WeatherCfgId { get; set; }
}
}

3
Server/Model/Generate/Message/OuterOpcode.cs

@ -179,5 +179,8 @@ namespace ET
public const ushort M2C_CabinUpdateFarmlands = 10176;
public const ushort C2M_CabinHarvest = 10177;
public const ushort M2C_CabinHarvest = 10178;
public const ushort WeatherProto = 10179;
public const ushort M2C_NtfWeatherStart = 10180;
public const ushort M2C_NtfWeatherEnd = 10181;
}
}

BIN
Unity/Assets/Bundles/Config/WeatherConfigCategory.bytes

Binary file not shown.

1
Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs

@ -21,7 +21,6 @@ namespace ET
unit.Day = unitProto.Day;
unit.EventSeed = unitProto.EventSeed;
unit.EventNames = unitProto.EventNames;
unit.SeasonConfig = SeasonConfigCategory.Instance.Get(unit.Season);
for (int i = 0; i < unitProto.FighterList.Count / 2; i++)
{

33
Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs

@ -45,8 +45,11 @@ namespace ET
}
#endif
[FriendClass(typeof(People))]
[FriendClass(typeof (Unit))]
[FriendClass(typeof (Farmland))]
[FriendClass(typeof (Building))]
public static class UnitSystem
{
public static void AddTime(this Unit self, int tick)
@ -82,6 +85,16 @@ namespace ET
synthesisComponent.Update(self, now);
}
var dt = now - self.UpdateTimeSec;
dt = dt / 1000;
if (dt > 0)
{
self.GetChild<Weather>(self.WeatherId).Update(self,(int)dt);
self.UpdateTimeSec += dt * 1000;
}
#endif
}
@ -108,8 +121,13 @@ namespace ET
UnitOperate.NightEvent(self, nightTime, time);
//每天长大一岁
self.AddAge();
//触发天气
self.GetChild<Weather>(self.WeatherId).Produce(self);
}
self.GameTime = time;
self.GetChild<Weather>(self.WeatherId).CheckStart(self,self.GameTime);
}
}
@ -149,6 +167,7 @@ namespace ET
self.SeasonConfig = SeasonConfigCategory.Instance.Get(self.Season);
self.InitPeopleNumberic();
self.InitGrandChildren();
self.UpdateTimeSec = self.UpdateTime;
}
public static void updateSeason(this Unit self)
@ -308,5 +327,19 @@ namespace ET
{
self.GrandChildren.Remove(id);
}
public static void OnWeatherEnd(this Unit self, int configId)
{
var config = WeatherConfigCategory.Instance.Get(configId);
foreach (var v in self.GetComponent<PeopleComponent>().Children.Values)
{
((People) v).Disease += config.Disease;
((People) v).Injury += config.Injury;
}
foreach (var v in self.GetComponent<BuildingComponent>().Children.Values)
{
((Building) v).Durable -= config.DurableDestroy;
}
}
}
}

13
Unity/Codes/Hotfix/Demo/Weather/Handler/M2C_NtfWeatherEndHandler.cs

@ -0,0 +1,13 @@
namespace ET
{
public class M2C_NtfWeatherEndHandler: AMHandler<M2C_NtfWeatherEnd>
{
protected override void Run(Session session, M2C_NtfWeatherEnd message)
{
}
}
}

10
Unity/Codes/Hotfix/Demo/Weather/Handler/M2C_NtfWeatherStartHandler.cs

@ -0,0 +1,10 @@
namespace ET.Handler
{
public class M2C_NtfWeatherStartHandler: AMHandler<M2C_NtfWeatherStart>
{
protected override void Run(Session session, M2C_NtfWeatherStart message)
{
UnitComponent.unit.OnWeatherEnd(message.WeatherCfgId);
}
}
}

125
Unity/Codes/Hotfix/Demo/Weather/WeatherSystem.cs

@ -0,0 +1,125 @@
using System.Collections.Generic;
namespace ET
{
[FriendClass(typeof(Weather))]
[FriendClass(typeof(Unit))]
public static class WeatherSystem
{
public static void FromMessage(this Weather self, WeatherProto weatherProto)
{
self.Id = weatherProto.Id;
self.ConfigId = weatherProto.ConfigId;
self.State = weatherProto.State;
}
public static WeatherProto ToMessage(this Weather self)
{
WeatherProto weatherProto = new WeatherProto();
weatherProto.Id = self.Id;
weatherProto.State = self.State;
return weatherProto;
}
public static void Produce(this Weather self,Unit unit)
{
if (self.Times >= 3 || self.ConfigId>0)
{
return;
}
var seasonConfig = unit.GetSeasonConfig();
var randomTimes = 0;
//随机季节
while (self.ConfigId==0 && randomTimes>=seasonConfig.WeatherGroup.Length)
{
var index = RandomHelper.RandomByWeight(seasonConfig.Weights);
var weatherId = seasonConfig.WeatherGroup[index];
randomTimes++;
WeatherInfo weatherInfo;
if (self.WeatherHistory.TryGetValue(weatherId,out weatherInfo))
{
if (weatherInfo.Cd >= unit.Day - weatherInfo.StartDay)
{
self.ConfigId = weatherId;
}
}
else
{
self.ConfigId = weatherId;
}
}
if (self.ConfigId == 0)
{
foreach (var v in seasonConfig.WeatherGroup)
{
WeatherInfo weatherInfo;
if (self.WeatherHistory.TryGetValue(v,out weatherInfo))
{
if (weatherInfo.Cd >= unit.Day - weatherInfo.StartDay)
{
self.ConfigId = v;
break;
}
}
else
{
self.ConfigId = v;
break;
}
}
}
if (self.ConfigId > 0)
{
self.Duration = RandomHelper.RandomNumber(self.Config.Duration[0], self.Config.Duration[1]+1);
var cd = RandomHelper.RandomNumber(self.Config.CD[0], self.Config.CD[1]+1);
self.StartTime = RandomHelper.RandomNumber(10, 16) * 100 + RandomHelper.RandomNumber(0, 60);
self.WeatherHistory[self.ConfigId] = new WeatherInfo() { ConfigId = self.ConfigId, Cd = cd, StartDay = unit.Day };
}
}
public static void CheckStart(this Weather self,Unit unit,int gameTime)
{
if (self.ConfigId == 0)
{
return;
}
if (self.StartTime < gameTime && self.State == 0)
{
self.State = 1;
#if SERVER
UnitHelper.NotifyWeatherStart(unit, self.ConfigId);
#endif
}
}
public static void Update(this Weather self, Unit unit, int tick)
{
if (self.State == 0)
{
return;
}
self.Duration -= tick;
if (self.Duration <= 0)
{
self.State = 0;
#if SERVER
UnitHelper.NotifyWeatherEnd(unit, self.ConfigId);
#endif
self.ConfigId = 0;
}
}
}
}

1
Unity/Codes/Model/Demo/People/People.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Options;

10
Unity/Codes/Model/Demo/Unit/Unit.cs

@ -6,7 +6,7 @@ using UnityEngine;
namespace ET
{
[ChildType(typeof(Battle))]
[ChildType]
#if SERVER
public sealed class Unit: Entity, IAwake, IAddComponent, IGetComponent,IUpdate
#else
@ -52,13 +52,14 @@ namespace ET
public int EventSeed;
public List<string> EventNames;
public int Hunger; //饥饿值
public long WeatherId;
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
public Dictionary<int, long> FighterDic=new Dictionary<int, long>();
[BsonIgnore]
public long UpdateTime;
public long UpdateTime; //山谷时间
[BsonIgnore]
public long UpdateValleyTime;
@ -72,6 +73,11 @@ namespace ET
[BsonIgnore]
public Dictionary<long, Entity> GrandChildren = new Dictionary<long, Entity>();
[BsonIgnore]
public long UpdateTimeSec;
}

14
Unity/Codes/Model/Demo/Weather/Weather.cs

@ -1,25 +1,29 @@
using System.Collections.Generic;
using MongoDB.Bson.Serialization.Attributes;
namespace ET
{
public struct WatherInfo
public struct WeatherInfo
{
public int ConfigId;
public int Cd;
public int StartTime; //game day
public int StartDay; //game day
}
public class Weather:Entity,IAwake,ISerializeToEntity
{
public int ConfigId;
public int Times; //当前季节触发次数
public int Cd;
public List<int> SpringList; //春天列表
public List<int> SummerList;
public List<int> AutumnList;
public List<int> WinterList;
public int StartTime;//开始时间,游戏时间
public int RealStartTime; //实际时间
public int StartTime;//开始时间(游戏时间)
public int Duration; //持续
public int State; //1表示天气影响中
public Dictionary<int, WeatherInfo> WeatherHistory = new Dictionary<int, WeatherInfo>();
[BsonIgnore]
public WeatherConfig Config => WeatherConfigCategory.Instance.Get(this.ConfigId);

36
Unity/Codes/Model/Generate/Message/OuterMessage.cs

@ -446,6 +446,9 @@ namespace ET
[ProtoMember(25)]
public List<MonsterGroupProto> MonsterGroupList = new List<MonsterGroupProto>();
[ProtoMember(26)]
public WeatherProto Weather { get; set; }
}
[Message(OuterOpcode.M2C_CreateUnits)]
@ -2999,4 +3002,37 @@ namespace ET
}
[Message(OuterOpcode.WeatherProto)]
[ProtoContract]
public partial class WeatherProto: Object
{
[ProtoMember(1)]
public long Id { get; set; }
[ProtoMember(2)]
public int ConfigId { get; set; }
[ProtoMember(3)]
public int State { get; set; }
}
[Message(OuterOpcode.M2C_NtfWeatherStart)]
[ProtoContract]
public partial class M2C_NtfWeatherStart: Object, IActorMessage
{
[ProtoMember(1)]
public int WeatherCfgId { get; set; }
}
[Message(OuterOpcode.M2C_NtfWeatherEnd)]
[ProtoContract]
public partial class M2C_NtfWeatherEnd: Object, IActorMessage
{
[ProtoMember(1)]
public int WeatherCfgId { get; set; }
}
}

3
Unity/Codes/Model/Generate/Message/OuterOpcode.cs

@ -179,5 +179,8 @@ namespace ET
public const ushort M2C_CabinUpdateFarmlands = 10176;
public const ushort C2M_CabinHarvest = 10177;
public const ushort M2C_CabinHarvest = 10178;
public const ushort WeatherProto = 10179;
public const ushort M2C_NtfWeatherStart = 10180;
public const ushort M2C_NtfWeatherEnd = 10181;
}
}

Loading…
Cancel
Save