Browse Source

修改InitFarmlandDic

master
wserver/wangdisen 3 years ago
parent
commit
c9d7e77fb0
  1. 20
      Server/Hotfix/Demo/Unit/UnitFactory.cs
  2. 2
      Unity/Codes/Hotfix/Demo/Operate/ConstructOperate.cs
  3. 1
      Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs
  4. 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;
}
}
}
}
} }
} }

2
Unity/Codes/Hotfix/Demo/Operate/ConstructOperate.cs

@ -6,6 +6,7 @@ namespace ET
[FriendClass(typeof (Construct))] [FriendClass(typeof (Construct))]
[FriendClass(typeof (Building))] [FriendClass(typeof (Building))]
[FriendClass(typeof (Farmland))] [FriendClass(typeof (Farmland))]
[FriendClass(typeof(Unit))]
public static class ConstructOperate public static class ConstructOperate
{ {
public static Construct CreateConstruct(Unit unit, int configId, float x, float y, long id = 0, long buildingId = 0) public static Construct CreateConstruct(Unit unit, int configId, float x, float y, long id = 0, long buildingId = 0)
@ -178,6 +179,7 @@ namespace ET
{ {
var farmland = build.AddChild<Farmland>(); var farmland = build.AddChild<Farmland>();
farmland.FarmlandState = FarmlandState.FARMLAND_STATE_FREE; farmland.FarmlandState = FarmlandState.FARMLAND_STATE_FREE;
unit.FarmlandDic[farmland.Id] = farmland;
} }
} }

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