if (detailRefs != null)
{
detailName.text = detailRefs.nameLabel;
detailInfo.text = detailRefs.infoLabel;
sortaImage.sprite = detailRefs.sortaImage;
if(detailRefs.sort == DetailRefs.objectsorts.hull)
{
hullInfo.SetActive(true);
hardwareInfo.SetActive(false);
strenght[0].text = detailRefs.strength.ToString();
mass[0].text = detailRefs.density.ToString();
}
else if (detailRefs.sort == DetailRefs.objectsorts.hardware)
{
hullInfo.SetActive(false);
hardwareInfo.SetActive(true);
strenght[1].text = detailRefs.strength.ToString();
energy[0].text = detailRefs.energy.ToString();
mass[1].text = detailRefs.density.ToString();
}
public void FitToChildren()
{
bool hasBounds = false;
Bounds bounds = new Bounds(Vector3.zero, Vector3.zero);
for (int i = 0; i <ship.transform.childCount; ++i)
{
Renderer childRenderer = ship.transform.GetChild(i).GetComponent<Renderer>();
if (childRenderer != null)
{
if (hasBounds)
{
bounds.Encapsulate(childRenderer.bounds);
}
else
{
bounds = childRenderer.bounds;
hasBounds = true;
}
}
}
playerShip.transform.position = bounds.center - ship.transform.position;
}
if (PS.energy + detailRefs.energy > PS.maxEnergy)
{
debugHUB.SetActive(true);
debugText.text = "ВНИМАНИЕ! НЕДОСТАТОЧНО ЭНЕРГИИ! УВЕЛИЧЬТЕ МАКСИМАЛЬНЫЙ ПОКАЗАТЕЛЬ С ПОМОЩЬЮ ГЕНЕРАТОРОВ!";
}
else if (iMass >= maxMass)
{
debugHUB.SetActive(true);
debugText.text = "ВНИМАНИЕ! СЛИШКОМ БОЛЬШАЯ МАССА! СТАБИЛИЗИРУЙТЕ ЭТОТ ПОКАЗАТЕЛЬ УДАЛИВ ТЯЖЕЛЫЕ ДЕТАЛИ!";
}
else if (count == maxCount)
{
debugHUB.SetActive(true);
debugText.text = "ВНИМАНИЕ! КОЛИЧЕСТВО ДЕТАЛЕЙ ОГРАНИЧЕНО, УДАЛИТЕ НЕНУЖНЫЕ ДЕТАЛИ ЧТОБЫ ПОСТАВИТЬ ДРУГИЕ!";
}
else
{
debugHUB.SetActive(false);
debugText.text = "";
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestructibleObject : MonoBehaviour
{
void OnMouseDown()
{
Destroy(gameObject);
}
}
public bool IsRemove;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AddComponent : MonoBehaviour {
public GameObject buildingCamera;
Rigidbody rig;
void Start()
{
buildingCamera = GameObject.FindGameObjectWithTag("MainCamera");
}
void Update ()
{
BuildingSystem BS = buildingCamera.GetComponent<BuildingSystem>();
if (BS.IsRemove)
{
if (rig == null)
{
rig = gameObject.AddComponent<Rigidbody>();
rig.constraints = RigidbodyConstraints.FreezeAll;
}
}
if (!BS.IsRemove)
{
if (rig != null)
Destroy(rig);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BuildingHUB : MonoBehaviour {
public GameObject buildingCamera;
public GameObject currentPreview;
BuildingSystem buildingSystem;
void Start()
{
buildingSystem = buildingCamera.GetComponent<BuildingSystem>();
}
void Update ()
{
currentPreview = buildingSystem.currentpreview.gameObject;
if (buildingSystem.IsBuilding && Input.GetKeyDown(KeyCode.Delete))
{
ToRemove();
}
if (buildingSystem.IsRemove && Input.GetKeyDown(KeyCode.Escape))
{
RemoveToEscape();
}
}
public void ToRemove()
{
buildingSystem.IsRemove = true;
buildingSystem.IsBuilding = false;
currentPreview.SetActive(false);
}
public void RemoveToEscape()
{
buildingSystem.IsRemove = false;
buildingSystem.IsBuilding = true;
currentPreview.SetActive(true);
}
}