23 changed files with 338 additions and 23 deletions
Binary file not shown.
@ -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":"随机村民打喷嚏"}, |
||||
]} |
||||
|
@ -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":"随机村民打喷嚏"}, |
||||
]} |
||||
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,13 @@
|
||||
namespace ET |
||||
{ |
||||
|
||||
|
||||
public class M2C_NtfWeatherEndHandler: AMHandler<M2C_NtfWeatherEnd> |
||||
{ |
||||
protected override void Run(Session session, M2C_NtfWeatherEnd message) |
||||
{ |
||||
|
||||
|
||||
} |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
|
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue