private void DoReadShipCreate() { int tmpUID = FReader.ReadInt32(); Landing tmpLanding = LandingByUID(tmpUID); /* пересмотреть логику */ if (tmpLanding.Ship != null) { return; } Player LOwner = SSHShared.FindPlayer(FReader.ReadInt32()); ShipType LShipType = (ShipType)FReader.ReadInt32(); Ship LShip = new Ship(tmpUID, LOwner, tmpLanding, LShipType) { State = (ShipState)FReader.ReadInt32(), Mode = (ShipMode)FReader.ReadInt32(), AttachedPlanet = PlanetByUID(FReader.ReadInt32()), Count = FReader.ReadInt32(), HP = FReader.ReadInt32(), Fuel = FReader.ReadInt32(), IsCapture = FReader.ReadBoolean(), IsAutoTarget = FReader.ReadBoolean(), }; LShip.Allocate(); }
// Перемещение в слот private void MoveToLanding() { Landing LLanding = (Landing)SSHShared.MonoTarget; // Если корабль не один, проверим хоткеи if (FSelf.Count > 1) { // При зажатом шифте просто делим пополам if (Engine.HotKey(KeyCode.LeftShift, true)) { Engine.SocketWriter.ShipSeparate(FSelf, LLanding.UID, FSelf.Count / 2); return; } else // При зажатом контроле - показываем запрос if (Engine.HotKey(KeyCode.LeftControl, true)) { SSHShared.UIModalManager.ShowSeparateCount("Separate", 1, FSelf.Count - 1, FSelf.Count / 2, false, (int ACount, bool ASave) => { Engine.SocketWriter.ShipSeparate(FSelf, LLanding.UID, ACount); }); return; } } // Иначе просто переместим Engine.SocketWriter.ShipMoveTo(FSelf, LLanding.Planet, LLanding.UID); }
private void DoReadShipRetarget() { Ship LShip = LandingByUID(FReader.ReadInt32()).Ship; ShipWeaponType LWeaponeType = (ShipWeaponType)FReader.ReadInt32(); Landing LLanding = LandingByUID(FReader.ReadInt32()); LShip.Weapon(LWeaponeType).Retarget(LLanding != null ? LLanding.Ship : null); }
// Конструктор сразу определяет тип данных public Ship(int AID, Player AOwner, Landing ALanding, ShipType AShipType) { UID = AID; Owner = AOwner; ShipType = AShipType; Landing = ALanding; Planet = ALanding.Planet; FTimers = new int[Enum.GetValues(typeof(ShipTimer)).Length]; Weapons = new ShipWeapon[Enum.GetValues(typeof(ShipWeaponType)).Length]; Transform = PrefabManager.CreateShip(ALanding.Transform, Owner.Race, AShipType).transform; Transform.SetParent(ALanding.Transform, false); FScript = Transform.GetComponent <MonoShip>(); }
// Установка зоны посадки private void SetLanding(Landing ALanding) { // Сбросим старый объект if (FLanding != null) { FLanding.Ship = null; } // Выставим новый if (ALanding != null) { FLanding = ALanding; FLanding.Ship = this; } }
// Создание массива слотов private void DoSlotsCreate() { FLanding = new Landing[C_TotalSlotCount + 1]; // Слоты бывают внутренние и внешние, создаем сразу оба типа for (int LIndex = 0; LIndex <= C_TotalSlotCount; LIndex++) { Landing LLanding = new Landing(LIndex, _SlotsArray, FSelf, LIndex > C_FightSlotCount); FLanding[LIndex] = LLanding; // Расположем на орбите if (LLanding.IsLowOrbit) { LLanding.Transform.localScale = new Vector3(0.8f, 0.8f, 0.8f); } } }
// Загрузка данных слота protected override void DoInit(Shared.Interactive ASubject) { FSelf = (Landing)ASubject; _Model.sprite = _SpritePassive; }