public static Packet GetPacket(ShipSystem system, float value) { EngSetEnergySubPacket esesp = new EngSetEnergySubPacket(system, value); ShipAction3Packet sap3 = new ShipAction3Packet(esesp); Packet retVal = new Packet(sap3); return retVal; }
protected void BeaconFixed(ShipSystem beacon) { if (OnBeaconFixed != null) { OnBeaconFixed(); } }
void Start() { system = GetComponentInParent <ShipSystem>(); timer = GetComponentInChildren <Slider>(); timer.maxValue = timeLimit; canvas = GetComponentInChildren <Canvas>(); canvas.enabled = false; }
public void InitializeSystem(ShipSystem shipSystem) { hasAssignedSystem = shipSystem != null; this.shipSystem = shipSystem; if (shipSystem != null) { shipSystem.AssignRoomControl(this); } }
void OnDestroy() { // temporary, think how to do better? assign from the editor? // I don't think this has a bad impact on performance. It isn't called on update. - Erin GameObject navyShipSystem = GameObject.FindGameObjectWithTag("ShipSystem"); ShipSystem owner = navyShipSystem?.GetComponent <ShipSystem>(); owner?.DestroyShip(this); }
public void Start() { system = GetComponentInParent <ShipSystem>(); for (int i = 0; i < 4; ++i) { buttonImages[i] = transform.GetChild(i).gameObject; } toggles = transform.GetComponentsInChildren <Toggle>(); TurnTogglesOn(); }
private void StartEnablingSystems() { while (shipResources.StoredEnergy >= minOperationalEnergyStorage && unavailablePowerSystems.Count > 0) { ShipSystem system = GetSystemWithHighestPriority(unavailablePowerSystems.ToArray()); if (system != null) { system.SetPowerAvailable(); unavailablePowerSystems.Remove(system); availablePowerSystems.Add(system); } } }
private void StartDisablingSystems() { while (GetPowerProduction() - GetPowerUsage() < 0 && unavailablePowerSystems.Count < numConsumerSystems) { ShipSystem system = GetSystemWithLowestPriority(availablePowerSystems.ToArray()); if (system != null) { system.SetPowerUnavailable(); unavailablePowerSystems.Add(system); availablePowerSystems.Remove(system); } } }
public void SetShip(int shipClass, ShipSystemModel model, ShipDriver driver) { GetComponent <Rigidbody>().mass = Mathf.Pow(2, shipClass); shipDriver = driver; shipSystem = new ShipSystem(model); this.shipClass = shipClass; maxHealth = new float[] { 1f, 4f, 12f, 36f, 250f * ((BattleConfig)GameState.sharedData["BattleConfig"]).battleDurationMultipier }[shipClass];// Mathf.Pow(maxHealth, shipClass + 1); health = maxHealth; shipDriver.SetShip(this); //turn enabled true gameObject.AddComponent <ShipIdentification>().ship = this; }
public void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("Player") && isEnemy) { ShipSystem ship = collision.gameObject.GetComponent <ShipSystem>(); ship.ShipDamage(bulletDamage); Destroy(gameObject); } else if (collision.gameObject.CompareTag("Enemy") && isPlayer) { EnemyAI enemyShip = collision.gameObject.GetComponent <EnemyAI>(); enemyShip.DamageEnemy(bulletDamage); Destroy(gameObject); } }
private ShipSystem GetSystemWithHighestPriority(ShipSystem[] systemList) { int highestPriority = int.MinValue; ShipSystem highestPrioritySystem = null; foreach (ShipSystem system in systemList) { if (system.PowerType == ShipSystem.SystemPowerType.Consumer && system.PowerPriority > highestPriority) { highestPriority = system.PowerPriority; highestPrioritySystem = system; } } return(highestPrioritySystem); }
private ShipSystem GetSystemWithLowestPriority(ShipSystem[] systemList) { int lowestPriority = int.MaxValue; ShipSystem lowestPrioritySystem = null; foreach (ShipSystem system in systemList) { if (system.PowerType == ShipSystem.SystemPowerType.Consumer && system.PowerPriority < lowestPriority) { lowestPriority = system.PowerPriority; lowestPrioritySystem = system; } } return(lowestPrioritySystem); }
public void setReference(ShipSystem s) { if (s is Shield) { shield = (Shield)s; } if (s is Engine) { engine = (Engine)s; } if (s is PDSController) { pds = (PDSController)s; } }
void FixedUpdate() { Debug.DrawRay(transform.position + Vector3.up * 0.75f, transform.forward * 6f, Color.red); RaycastHit hit; if (Physics.Raycast(transform.position + Vector3.up * 0.75f, transform.forward, out hit, 6f)) { if (eController.AnyButtonWasPressed) { Debug.Log("wrench swing"); anim.ResetTrigger("hit"); anim.SetTrigger("hit"); } if (hit.collider.gameObject == interaction) { return; } ShipSystem shipSystem = hit.collider.gameObject.GetComponent <ShipSystem>(); if (shipSystem != null) { if (interaction != null) { EndInteracting(); } if (!shipSystem.GetType().Equals(typeof(Turret)) && shipSystem.broken) { StartInteractingWrench(hit.collider.gameObject); } else { StartInteracting(hit.collider.gameObject); } } else if (interaction != null) { EndInteracting(); } } else if (interaction != null) { EndInteracting(); } }
public void Refresh() { // reset capacity and power consumption capacity = 0; powerConsumption = 0; int weaponsHP = Room.CurrentHP; // get capacity for (int i = 0; i < this.transform.childCount; i++) { ShipSystem weaponSystem = this.transform.GetChild(i).GetComponent <ShipSystem>(); capacity += weaponSystem.powerCap; powerConsumption += weaponSystem.powerConsumption; } powerCap = capacity; }
public void AssembleShip(ShipData shipData) { foreach (SystemData systemData in shipData.systemDatas) { RoomControl roomControl = GetRoomControl(systemData.room); ShipSystem shipSystem = CreateSystemObject(systemData.system, systemData.GetPosition(), systemData.GetRotation()); if (shipSystem == null) { Debug.LogError("Tried to create non existant system: " + systemData.system); } else { AssignSystemToRoomAndInit(shipSystem, roomControl); } } foreach (BuiltInSystemWithID systemRoom in builtInSystemRooms) { AssignSystemToRoomAndInit(systemRoom.system, systemRoom.roomControl); } }
void DealDamage(int damage) { if (target.broken) { //Select a new target (if possible) List <ShipSystem> options = new List <ShipSystem>(); foreach (ShipSystem ss in systems) { if (!ss.broken && !ss.unbreakable && !hulls.Contains(ss)) { options.Add(ss); } } if (options.Count > 0) { target = options[Random.Range(0, options.Count)]; } } target.TakeDamage(damage); }
public ShipKeyInput(ShipSystem ship) { ui = ScreenManager.GetScreen <PlayerUIBehaviour>(); var shipSystem = ship; if (shipSystem.keys.Any()) { foreach (var k in shipSystem.keys) { components.Add(new KeyComponent(k.Key, k.Value)); } actions.component = components.First().component; ui.SetUI(shipSystem.keys.Select(p => new LinksGroup() { key = p.Key, link = p.Value, name = p.Value.item.lName }).ToArray()); UpdateView(); } }
void Update() { if (State == PlayerState.Repairing) { if (currentRepairingSystem.Health < currentRepairingSystem.MaxHealth) { currentRepairingSystem.Repair(RepairRate * TimeManager.Instance.GameDeltaTime); uiManager.UpdateRepairBar(currentRepairingSystem.Health / currentRepairingSystem.MaxHealth); } else { StopRepairing(); } if (Input.GetMouseButtonDown(0)) { StopRepairing(); } } else if (State == PlayerState.Sleeping) { if (playerResources.Energy == playerResources.EnergyCap) { StopSleeping(); } if (Input.GetMouseButtonDown(0)) { StopSleeping(); } } else if (State == PlayerState.Sitting) { if (Input.GetMouseButtonDown(0)) { State = PlayerState.FreeMoving; } } else if (State == PlayerState.FreeMoving) { Vector3 forward = cameraTransform.TransformDirection(Vector3.forward); RaycastHit hit; hoveringObj = null; hoveringBrokenSystem = null; if (Physics.Raycast(cameraTransform.position, forward, out hit, InteractRange)) { hoveringObj = hit.transform.GetComponent <InteractableObject>(); if (hoveringObj) { if (hoveringObj is SystemInteractableObject) { SystemInteractableObject obj = (hoveringObj as SystemInteractableObject); // if(obj.System.Interactable) { if (obj.System.Broken) { uiManager.UpdateTooltipText("Repair " + obj.System.Name, true); hoveringBrokenSystem = obj.System; } else { uiManager.UpdateTooltipText(hoveringObj.DisplayText, hoveringObj.ShowMouseIcon); } uiManager.UpdateTooltipTextSub(obj.systemDescription); // } else { // uiManager.UpdateTooltipText(null, false); // } } else { uiManager.UpdateTooltipText(hoveringObj.DisplayText, hoveringObj.ShowMouseIcon); uiManager.UpdateTooltipTextSub(null); } } else { uiManager.UpdateTooltipText(null, false); uiManager.UpdateTooltipTextSub(null); } } else { uiManager.UpdateTooltipText(null, false); uiManager.UpdateTooltipTextSub(null); } if (Input.GetMouseButtonDown(0)) { if (hoveringObj != null) { if (hoveringBrokenSystem != null) { StartRepairing(hoveringBrokenSystem); } else { hoveringObj.Click(hit.point); } } } } if (State != PlayerState.AnimationLocked) { if (Input.GetMouseButton(1)) { TimeManager.Instance.Fast = true; } else { TimeManager.Instance.Fast = false; } } }
public controller() { m_carSystem = new CarSystem(); m_shipSystem = new ShipSystem(); }
/// <summary> /// Marks the given system as OK /// </summary> /// <param name="system">System.</param> public void SetOk(ShipSystem system) { SetSystemText(system, "OK"); SetSystemColor(system, Color.green); }
/// <summary> /// Set text value for specific system. Adds the system name as prefix /// </summary> private void SetSystemText(ShipSystem system, string text) { systemTexts[system].text = system.ToString() + " - " + text; }
public static Packet GetPacket(ShipSystem system, int value) { EngSetCoolantSubPacket escsp = new EngSetCoolantSubPacket(system, value); ShipAction2Packet sap2 = new ShipAction2Packet(escsp); return new Packet(sap2); }
public void SendEngSetEnergySubPacket(Guid connectionID, ShipSystem system, float value) { Send(connectionID, EngSetEnergySubPacket.GetPacket(system, value)); }
public ShipSystemViewModel(ShipSystem system) { this.system = system; }
void OnPowerAvailable(ShipSystem system) { NoPowerCover.SetActive(false); }
public GameSystem() { m_carSystem = new CarSystem(); m_shipSystem = new ShipSystem(); }
// Update is called once per frame public void setReadouts() { switch (systemType) { case ShipSystem.SystemType.Shields: shield = PlayerController.PC.shieldRef; system = (ShipSystem)shield; type.Display("Shields"); classification.Display(shield.getComponentClass()); field1.Display(shield.RegenRate + "/second"); field2.Display(shield.RegenDelay + " seconds"); power.Display(shield.PowerAllocation); icon.SpriteName = shield.Icon; break; case ShipSystem.SystemType.PointDefenseSystem: pds = PlayerController.PC.pdsref; system = (ShipSystem)pds; type.Display("Point Defense System"); classification.Display(pds.getComponentClass()); field1.Display(pds.MissileDestroyTime + " seconds"); field2.Display(pds.Range); power.Display(pds.PowerAllocation); icon.SpriteName = pds.Icon; break; case ShipSystem.SystemType.Engine: engine = PlayerController.PC.engineRef; system = (ShipSystem)engine; type.Display("Engines"); classification.Display(engine.getComponentClass()); field1.Display(engine.Speed); field2.Display(engine.CanBoost); field3.Display(engine.BoostDuration + " seconds"); power.Display(engine.PowerAllocation); icon.SpriteName = engine.Icon; break; case ShipSystem.SystemType.PowerGenerator: pg = PlayerController.PC.powerGenerator; if (apb == null) { apb = GetComponentInChildren<aPowerBar>(); apb.initalize(); } type.Display("Power Generator"); classification.Display(pg.getComponentClass()); field1.Display(pg.MaxAvailablePower); field2.Display(pg.AvailablePower); field3.Display(pg.powerProfiles); apb.updateValue(); description.Display(pg.getDescription()); upgradeDesc.Display(pg.getUpgradeDescription()); icon.SpriteName = pg.Icon; costValue = pg.upgradeCost; break; } if (system != null) { costValue = system.upgradeCost; description.Display(system.Description); upgradeDesc.Display(system.UpgradeDescription); } cost.Display(costValue); }
public void Initialize(ShipSystem S) { system = S; updateReadouts(); spb.initialize(); }
public void SendEngSetCoolantSubPacket(Guid connectionID, ShipSystem system, int value) { Send(connectionID, EngSetCoolantSubPacket.GetPacket(system, value)); }
public void createControls(ShipSystem s) { if (spmList.Count == 3) return; if (s.hasPowerToggle) return; GameObject o = TrashMan.spawn("SystemPowerManager", transform.position, transform.rotation); SystemPowerManager spm = o.GetComponent<SystemPowerManager>(); spmList.Add(spm); spm.Initialize(s); updateReadouts(); o.transform.parent = systemsPanel.gameObject.transform; s.hasPowerToggle = true; foreach (SystemPowerManager SPM in spmList) { SPM.updateReadouts(); } }
public EngSetCoolantSubPacket(ShipSystem system, int value) : base(ShipAction2SubPacketType.EngSetCoolantSubPacket, (int)system, value, 0, 0) { }
public void SelectSystem(ShipSystem system) { this._selectedSystem = system; }
/// <summary> /// Set color value for the system's text line /// </summary> private void SetSystemColor(ShipSystem system, Color color) { systemTexts[system].color = color; }
private void OnRemoveShipSystem(ShipSystem system) { this.shipSystemVMs.RemoveAll((vm) => ReferenceEquals(vm.system, system)); }
/// <summary> /// Writes a problem for the given system and marks it as problematic. /// </summary> public void SetProblem(ShipSystem system, string text) { SetSystemText(system, text); SetSystemColor(system, Color.red); }
public EngSetEnergySubPacket(ShipSystem system, float value) : base(ShipAction3SubPacketType.EngSetEnergySubPacket, value, 0.0F) { System = system; }
private void OnAddShipSystem(ShipSystem system) { this.shipSystemVMs.Add(new ShipSystemViewModel(system)); }
void OnPowerUnavailable(ShipSystem system) { NoPowerCover.SetActive(true); }
void OnBroken(ShipSystem system) { BrokenModel.SetActive(true); FixedModel.SetActive(false); }
void Start() { GameObject obj = this.gameObject; while(obj.GetComponent<ShipSystem>() == null) { if(obj.transform.parent == null) throw new Exception("No parent to add subsystem to"); obj = obj.transform.parent.gameObject; } system = obj.GetComponent<ShipSystem>() ; ship = obj; // The chasis of the ship is important system [this.name] = this.gameObject; base.Start(); }