|
|
|
@ -7,7 +7,6 @@ namespace ET
|
|
|
|
|
{ |
|
|
|
|
public override void Awake(Unit self) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -75,7 +74,6 @@ namespace ET
|
|
|
|
|
public static void Update(this Unit self, long now) |
|
|
|
|
{ |
|
|
|
|
#if SERVER |
|
|
|
|
|
|
|
|
|
var synthesisComponent = self.GetComponent<SynthesisComponent>(); |
|
|
|
|
if (synthesisComponent != null) |
|
|
|
|
{ |
|
|
|
@ -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 }); |
|
|
|
|
#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) |
|
|
|
@ -196,7 +193,8 @@ namespace ET
|
|
|
|
|
var resConfig = ResourcesConfigCategory.Instance.Get(resConfigId); |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
@ -210,7 +208,8 @@ namespace ET
|
|
|
|
|
var resConfig = ResourcesConfigCategory.Instance.Get(resConfigId); |
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |