IEnumerator PrintPart(GameObject shipModule) { foreach (ParticleSystem particleSystem in printParticles) { particleSystem.Play(); } yield return(new WaitForSeconds(0.2f)); newPart = Instantiate(shipModule, printPoint.position, printPoint.rotation).GetComponent <ShipModule>(); SceneManager.instance.AddGravityBody(newPart.GetComponent <Rigidbody>()); newPart.Dematerialize(PartPrinterData.instance.printMaterial); meshRenderer = newPart.GetComponent <MeshRenderer>(); SetPartOpacity(partOpacity); yield return(new WaitForSeconds(PartPrinterData.instance.printTime)); foreach (ParticleSystem particleSystem in printParticles) { particleSystem.Stop(); } yield return(new WaitForSeconds(0.2f)); newPart.Materialize(); newPart = null; partOpacity = 0f; }
public void UpdateModuleStatus(ShipModule module, GameTypes.ModuleType type, bool connected) { switch (type) { case GameTypes.ModuleType.FuelPack: if (connected) { fuelPack = module.GetComponent <FuelPack>(); Debug.Log("Ship: Fuel pack connected"); } else { fuelPack = null; Debug.Log("Ship: Fuel pack disconnected"); } break; case GameTypes.ModuleType.Thrusters: if (connected) { thrusters = module.GetComponent <Thrusters>(); Debug.Log("Ship: Thrusters connected"); } else { thrusters = null; Debug.Log("Ship: Thrusters disconnected"); } break; case GameTypes.ModuleType.Boosters: if (connected) { boosters = module.GetComponent <Boosters>(); Debug.Log("Ship: Boosters connected"); } else { boosters = null; Debug.Log("Ship: Boosters disconnected"); } break; case GameTypes.ModuleType.QuantumDrive: if (connected) { quantumDrive = module.GetComponent <QuantumDrive>(); Debug.Log("Ship: Quantum Drive connected"); } else { quantumDrive = null; Debug.Log("Ship: Quantum Drive disconnected"); } break; } }
// Update is called once per frame void Update() { if (shipPart != null) { Vector2 mouseInWorldSpace = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (moduleGridSystem.IsInBoat(mouseInWorldSpace) && shipPart != null) { shipPart.transform.position = moduleGridSystem.GetPositionForCellIndex(moduleGridSystem.GetCellIndexFromPosition(mouseInWorldSpace)); if (!moduleGridSystem.CanPLaceModule(moduleGridSystem.GetCellIndexFromPosition(mouseInWorldSpace), shipPart.GetComponent <ShipModule>().moduleSize)) { shipPart.GetComponent <SpriteRenderer>().color = new Color(0.9f, 0.3f, 0.3f, 0.5f); } else { shipPart.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0.5f); } } if (Input.GetMouseButtonDown(0)) { if (shipPart != null && moduleGridSystem.IsInBoat(mouseInWorldSpace) && moduleGridSystem.CanPLaceModule(moduleGridSystem.GetCellIndexFromPosition(mouseInWorldSpace), shipPart.GetComponent <ShipModule>().moduleSize)) { shipPart.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1); shipPart.GetComponent <SpriteRenderer>().sortingOrder = 0; ShipModule shipModule = shipPart.GetComponent <ShipModule>(); Storage storage = StorageManager.Instance.GetStorageRefence(); storage.wood.Amount -= shipModule.cost.woodCost; shipModule.ActivateModule(); Ship.Instance.shipParts.Add(shipModule); moduleGridSystem.PutGameObjectOnPosition(shipPart.gameObject, mouseInWorldSpace); shipPart = null; } } else if (Input.GetMouseButtonDown(1)) { Destroy(shipPart.gameObject); shipPart = null; } } }
public void SetShipPartToPlace(ShipModule shipModule) { if (shipPart != null) { Destroy(shipPart.gameObject); } shipPart = shipModule; shipPart.GetComponent <SpriteRenderer>().sortingOrder = 1; }