LSUnitViewComponentSystem.cs 1.2 KB

1234567891011121314151617181920212223242526272829
  1. using UnityEngine;
  2. namespace ET.Client
  3. {
  4. public static class LSUnitViewComponentSystem
  5. {
  6. public class AwakeSystem: AwakeSystem<LSUnitViewComponent>
  7. {
  8. protected override void Awake(LSUnitViewComponent self)
  9. {
  10. Room room = self.Room();
  11. LSUnitComponent lsUnitComponent = room.LSWorld.GetComponent<LSUnitComponent>();
  12. foreach (long playerId in room.PlayerIds)
  13. {
  14. LSUnit lsUnit = lsUnitComponent.GetChild<LSUnit>(playerId);
  15. GameObject bundleGameObject = (GameObject)ResourcesComponent.Instance.GetAsset("Unit.unity3d", "Unit");
  16. GameObject prefab = bundleGameObject.Get<GameObject>("Skeleton");
  17. GameObject unitGo = UnityEngine.Object.Instantiate(prefab, GlobalComponent.Instance.Unit, true);
  18. unitGo.transform.position = lsUnit.Position.ToVector();
  19. LSUnitView lsUnitView = self.AddChildWithId<LSUnitView, GameObject>(lsUnit.Id, unitGo);
  20. lsUnitView.AddComponent<LSAnimatorComponent>();
  21. }
  22. }
  23. }
  24. }
  25. }