|
|
|
@ -7,7 +7,6 @@ namespace ET
|
|
|
|
|
{ |
|
|
|
|
public override void Awake(Unit self) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -26,7 +25,7 @@ namespace ET
|
|
|
|
|
if (dt > timeRate) |
|
|
|
|
{ |
|
|
|
|
int tick = Convert.ToInt32(dt / timeRate); |
|
|
|
|
self.UpdateTime +=tick* timeRate; |
|
|
|
|
self.UpdateTime += tick* timeRate; |
|
|
|
|
UnitSystem.AddTime(self, tick); |
|
|
|
|
} |
|
|
|
|
UnitSystem.Update(self,now); |
|
|
|
@ -45,7 +44,7 @@ namespace ET
|
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
[FriendClass(typeof(Unit))] |
|
|
|
|
[FriendClass(typeof (Unit))] |
|
|
|
|
public static class UnitSystem |
|
|
|
|
{ |
|
|
|
|
public static void AddTime(this Unit self, int tick) |
|
|
|
@ -72,10 +71,9 @@ namespace ET
|
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void Update(this Unit self,long now) |
|
|
|
|
public static void Update(this Unit self, long now) |
|
|
|
|
{ |
|
|
|
|
#if SERVER |
|
|
|
|
|
|
|
|
|
var synthesisComponent = self.GetComponent<SynthesisComponent>(); |
|
|
|
|
if (synthesisComponent != null) |
|
|
|
|
{ |
|
|
|
@ -97,7 +95,7 @@ namespace ET
|
|
|
|
|
m = m % 60; |
|
|
|
|
var time = h * 100 + m; |
|
|
|
|
// todo 月圆之夜 入夜时间加长 |
|
|
|
|
var nightTime = self.GetNightTime(); |
|
|
|
|
var nightTime = self.GetNightTime(); |
|
|
|
|
if (time >= nightTime) |
|
|
|
|
{ |
|
|
|
|
Log.Info($"----------------day: {self.Day}, nightTime: {nightTime}"); |
|
|
|
@ -107,9 +105,9 @@ namespace ET
|
|
|
|
|
self.EventSeed = 1; |
|
|
|
|
UnitOperate.NightEvent(self, nightTime, time); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.GameTime = time; |
|
|
|
|
if (gameTime>self.GameTime) |
|
|
|
|
if (gameTime > self.GameTime) |
|
|
|
|
{ |
|
|
|
|
//每天长大一岁 |
|
|
|
|
self.AddAge(); |
|
|
|
@ -141,7 +139,7 @@ namespace ET
|
|
|
|
|
PeopleComponent pc = self.GetComponent<PeopleComponent>(); |
|
|
|
|
foreach (var v in pc.Children.Values) |
|
|
|
|
{ |
|
|
|
|
((People)v).InitNumericComponent(); |
|
|
|
|
((People) v).InitNumericComponent(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -161,11 +159,11 @@ namespace ET
|
|
|
|
|
{ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
self.Season = self.SeasonConfig.Id; |
|
|
|
|
#if SERVER |
|
|
|
|
UnitHelper.NofityUpdateValley(self, new List<int> { NumericType.Season }, new List<long> { self.Season }); |
|
|
|
|
UnitHelper.NofityUpdateValley(self, new List<int> { NumericType.Season }, new List<long> { self.Season }); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void SetEmbattle(this Unit self, Dictionary<int, long> FighterDic) |
|
|
|
@ -175,7 +173,6 @@ namespace ET
|
|
|
|
|
|
|
|
|
|
public static void EnterBattle(this Unit self, long enemyUnitId) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static bool ExitBattle(this Unit self) |
|
|
|
@ -194,9 +191,10 @@ namespace ET
|
|
|
|
|
public static bool CanBorn(this Unit self, int resConfigId) |
|
|
|
|
{ |
|
|
|
|
var resConfig = ResourcesConfigCategory.Instance.Get(resConfigId); |
|
|
|
|
for(int i=0;i<resConfig.RebornCondition.Length;i++) |
|
|
|
|
for (int i = 0; i < resConfig.RebornCondition.Length; i++) |
|
|
|
|
{ |
|
|
|
|
if (resConfig.RebornCondition[i] == (int)ResourcesRebornConditionEnum.SEASON &&resConfig.RebornConditionParameters[i]!=self.Season) |
|
|
|
|
if (resConfig.RebornCondition[i] == (int) ResourcesRebornConditionEnum.SEASON && |
|
|
|
|
resConfig.RebornConditionParameters[i] != self.Season) |
|
|
|
|
{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
@ -208,9 +206,10 @@ namespace ET
|
|
|
|
|
public static bool CanReborn(this Unit self, int resConfigId) |
|
|
|
|
{ |
|
|
|
|
var resConfig = ResourcesConfigCategory.Instance.Get(resConfigId); |
|
|
|
|
for(int i=0;i<resConfig.RebornCondition.Length;i++) |
|
|
|
|
for (int i = 0; i < resConfig.RebornCondition.Length; i++) |
|
|
|
|
{ |
|
|
|
|
if (resConfig.RebornCondition[i] == (int)ResourcesRebornConditionEnum.SEASON &&resConfig.RebornConditionParameters[i]!=self.Season) |
|
|
|
|
if (resConfig.RebornCondition[i] == (int) ResourcesRebornConditionEnum.SEASON && |
|
|
|
|
resConfig.RebornConditionParameters[i] != self.Season) |
|
|
|
|
{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
@ -225,21 +224,18 @@ namespace ET
|
|
|
|
|
self.GetComponent<BuildingComponent>()?.DurableReduce(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void AddFarmland(this Unit self,Farmland farmland) |
|
|
|
|
{ |
|
|
|
|
self.FarmlandDic[farmland.Id] = farmland; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void RemoveFarmland(this Unit self, Farmland farmland) |
|
|
|
|
{ |
|
|
|
|
self.FarmlandDic.Remove(farmland.Id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void UpdateGameTime(this Unit self) |
|
|
|
|
{ |
|
|
|
|
foreach (var v in self.FarmlandDic.Values) |
|
|
|
|
//update farmland |
|
|
|
|
foreach (var v in self.GrandChildren.Values) |
|
|
|
|
{ |
|
|
|
|
((Farmland)v).Update(); |
|
|
|
|
if (v.GetType() == typeof (Farmland)) |
|
|
|
|
{ |
|
|
|
|
((Farmland) v).Update(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -258,17 +254,35 @@ namespace ET
|
|
|
|
|
{ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach (var v in self.GetComponent<BuildingComponent>().Children.Values) |
|
|
|
|
{ |
|
|
|
|
foreach (var c in v.Children.Values) |
|
|
|
|
{ |
|
|
|
|
if (c.GetType() == typeof (Farmland)) |
|
|
|
|
{ |
|
|
|
|
self.FarmlandDic[c.Id] = (Farmland) c; |
|
|
|
|
} |
|
|
|
|
self.AddGrandChild(c); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static T GetGrandChild<T>(this Unit self, long id) where T : Entity |
|
|
|
|
{ |
|
|
|
|
Entity child; |
|
|
|
|
if (self.GrandChildren.TryGetValue(id, out child)) |
|
|
|
|
{ |
|
|
|
|
return (T) child; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void AddGrandChild<T>(this Unit self, T entity) where T : Entity |
|
|
|
|
{ |
|
|
|
|
self.GrandChildren[entity.Id] = entity; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void RemoveGrandChild(this Unit self,long id) |
|
|
|
|
{ |
|
|
|
|
self.GrandChildren.Remove(id); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |