UnitFactory.cs 789 B

12345678910111213141516171819202122232425
  1. 
  2. using GFGGame;
  3. namespace ET
  4. {
  5. public static class UnitFactory
  6. {
  7. public static Unit Create(Scene currentScene, UnitInfo unitInfo)
  8. {
  9. UnitComponent unitComponent = currentScene.GetComponent<UnitComponent>();
  10. Unit unit = unitComponent.AddChildWithId<Unit>(unitInfo.UnitId);
  11. unitComponent.Add(unit);
  12. //数值组件
  13. NumericComponent numericComponent = unit.AddComponent<NumericComponent>();
  14. unit.AddComponent<ObjectWait>();
  15. for (int i = 0; i < unitInfo.Ks.Count; ++i)
  16. {
  17. numericComponent.Set(unitInfo.Ks[i], unitInfo.Vs[i]);
  18. }
  19. //角色信息
  20. RoleDataManager.InitServerData();
  21. return unit;
  22. }
  23. }
  24. }