Actor_CreateUnitsHandler.cs 606 B

1234567891011121314151617181920212223
  1. using UnityEngine;
  2. namespace Model
  3. {
  4. [MessageHandler(Opcode.Actor_CreateUnits)]
  5. public class Actor_CreateUnitsHandler : AMHandler<Actor_CreateUnits>
  6. {
  7. protected override void Run(Actor_CreateUnits message)
  8. {
  9. foreach (UnitInfo unitInfo in message.Units)
  10. {
  11. Unit unit = UnitFactory.Create(unitInfo.UnitId);
  12. unit.Position = new Vector3(unitInfo.X / 1000f, 0, unitInfo.Z / 1000f);
  13. unit.IntPos = new VInt3(unitInfo.X, 0, unitInfo.Z);
  14. if (PlayerComponent.Instance.MyPlayer.UnitId == unit.Id)
  15. {
  16. Game.Scene.GetComponent<CameraComponent>().Unit = unit;
  17. }
  18. }
  19. }
  20. }
  21. }