Browse Source

修改InitFarmlandDic

master
wserver/wangdisen 3 years ago
parent
commit
c326f76e8f
  1. 20
      Server/Hotfix/Demo/Unit/UnitFactory.cs
  2. 1
      Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs
  3. 20
      Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs

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

@ -57,7 +57,6 @@ namespace ET
unit.SeasonConfig = SeasonConfigCategory.Instance.Get(unit.Season); unit.SeasonConfig = SeasonConfigCategory.Instance.Get(unit.Season);
unitComponent.AddChild(unit); unitComponent.AddChild(unit);
InitNoDb(unit);
} }
else else
{ {
@ -195,23 +194,6 @@ namespace ET
}*/ }*/
} }
public static void InitNoDb(Unit unit)
{
var bc = unit.GetComponent<BuildingComponent>();
if (bc == null)
{
return;
}
foreach (var v in unit.GetComponent<BuildingComponent>().Children.Values)
{
foreach (var c in v.Children.Values)
{
if (c.GetType() == typeof (Farmland))
{
unit.FarmlandDic[c.Id] = (Farmland) c;
}
}
}
}
} }
} }

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

@ -110,6 +110,7 @@ namespace ET
unitComponent.Add(unit); unitComponent.Add(unit);
unit.AddComponent<ObjectWait>(); unit.AddComponent<ObjectWait>();
unit.InitFarmlandDic();
Game.EventSystem.Publish(new EventType.AfterUnitCreate() {Unit = unit}); Game.EventSystem.Publish(new EventType.AfterUnitCreate() {Unit = unit});
return unit; return unit;

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

@ -146,6 +146,7 @@ namespace ET
self.UpdateValleyTime = TimeHelper.ServerUnix(); self.UpdateValleyTime = TimeHelper.ServerUnix();
self.SeasonConfig = SeasonConfigCategory.Instance.Get(self.Season); self.SeasonConfig = SeasonConfigCategory.Instance.Get(self.Season);
self.InitPeopleNumberic(); self.InitPeopleNumberic();
self.InitFarmlandDic();
} }
public static void updateSeason(this Unit self) public static void updateSeason(this Unit self)
@ -245,6 +246,25 @@ namespace ET
((People) v).GrowUp(); ((People) v).GrowUp();
} }
} }
public static void InitFarmlandDic(this Unit self)
{
var bc = self.GetComponent<BuildingComponent>();
if (bc == null)
{
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;
}
}
}
}
} }
} }
Loading…
Cancel
Save