private void InitializeEquipment() { int[] numEquipment = customization.numEquipment; for (int i = 0; i < numEquipment[0]; i++) { WeaponEquipment weaponEquipment = gameObject.AddComponent <WeaponEquipment>(); weaponEquipment.Initialize("Turret", 0, 1, 0, 0.2f, 0.5f, 10f); equipment.Add(weaponEquipment); } for (int i = 0; i < numEquipment[1]; i++) { ResearchEquipment researchEquipment = gameObject.AddComponent <ResearchEquipment>(); researchEquipment.Initialize("Geological Research Equipment", 0, 1, ResearchTypes.Geology, 2, 6f); equipment.Add(researchEquipment); } for (int i = 0; i < numEquipment[2]; i++) { ResearchEquipment researchEquipment = gameObject.AddComponent <ResearchEquipment>(); researchEquipment.Initialize("Biological Research Equipment", 0, 1, ResearchTypes.Biology, 2, 6f); equipment.Add(researchEquipment); } for (int i = 0; i < numEquipment[3]; i++) { ResearchEquipment researchEquipment = gameObject.AddComponent <ResearchEquipment>(); researchEquipment.Initialize("Archeological Research Equipment", 0, 1, ResearchTypes.Archeology, 2, 6f); equipment.Add(researchEquipment); } }
private void CheckForNearbyResearchMaterial() { if (sampleCollectionsLeft == 0) // don't check if we are already scanning something { //make a list of the research equipment that we have List <ResearchEquipment> researchEquipmentArray = new List <ResearchEquipment>(); foreach (Equipment equipment in PlayerManager.instance.equipment) { if (equipment is ResearchEquipment) { ResearchEquipment researchEquipment = (ResearchEquipment)equipment; researchEquipmentArray.Add(researchEquipment); } } if (researchEquipmentArray.Count == 0) { Debug.Log("No research equipment available."); return; } scanMaxRange = 0f; //start scanning using each different type of research equipment that we have foreach (ResearchEquipment e in researchEquipmentArray) { float range = e.range; if (.5f * range > scanMaxRange) { scanMaxRange = .5f * range; } float scanTime = e.scanTime; Collider[] nearbyMaterials = Physics.OverlapSphere(transform.position, range, researchMaterialMask); if (nearbyMaterials.Length > 0) { //check if a valid research material is within range for (int i = 0; i < nearbyMaterials.Length; i++) { ResearchMaterial researchMaterial = nearbyMaterials[i].GetComponent <ResearchMaterial>(); if (researchMaterial.GetResearchType() == e.type) { //scan the research material StartCoroutine(MaterialScanRoutine(scanTime, researchMaterial)); break; } } } } } }
private void InitializeStats() { foreach (Equipment eq in PlayerManager.instance.equipment) { if (eq is WeaponEquipment) { WeaponEquipment w = eq as WeaponEquipment; WeaponUpgradeStruct wu = new WeaponUpgradeStruct(800, 1, w.damage, w.inaccuracy, w.fireRate, w.range); wu.Upgrade(); upgradeStructs.Add(wu); structVals.Add(0); } else if (eq is StorageEquipment) { StorageEquipment s = eq as StorageEquipment; StorageUpgradeStruct su = new StorageUpgradeStruct(700, 1, s.capacity); su.Upgrade(); upgradeStructs.Add(su); structVals.Add(1); } else if (eq is EnergyEquipment) { EnergyEquipment e = eq as EnergyEquipment; EnergyUpgradeStruct ee = new EnergyUpgradeStruct(850, 1, e.energyCapacity); ee.Upgrade(); upgradeStructs.Add(ee); structVals.Add(2); } else if (eq is TransmitterEquipment) { TransmitterEquipment t = eq as TransmitterEquipment; TransUpgradeStruct tu = new TransUpgradeStruct(700, 1, t.uploadFactor); tu.Upgrade(); upgradeStructs.Add(tu); structVals.Add(3); } else { ResearchEquipment r = eq as ResearchEquipment; ResearchUpgradeStruct ru = new ResearchUpgradeStruct(750, 1, r.scanTime, r.range); ru.Upgrade(); upgradeStructs.Add(ru); structVals.Add(4); } } }
// Start is called before the first frame update void Start() { totalMaterials = PlayerManager.instance.pickedUpResearchMaterials.Count; storage = (StorageEquipment)PlayerManager.instance.equipment[2]; totalCapacity = storage.capacity; capacityText.text = String.Format("Capacity: {0}/{1}", totalMaterials, totalCapacity); bool foundGeo = false; bool foundArch = false; bool foundBio = false; for (int i = 2; i < PlayerManager.instance.equipment.Count; i++) { if (PlayerManager.instance.equipment[i] is ResearchEquipment) { ResearchEquipment e = (ResearchEquipment)PlayerManager.instance.equipment[i]; if (e.type == ResearchTypes.Geology) { foundGeo = true; } else if (e.type == ResearchTypes.Archeology) { foundArch = true; } else { foundBio = true; } } } if (!foundGeo) { missingResearchType = ResearchTypes.Geology; archImageSpot.sprite = archImage; bioImageSpot.sprite = bioImage; } else if (!foundBio) { missingResearchType = ResearchTypes.Biology; archImageSpot.sprite = archImage; geoImageSpot.sprite = geoImage; } else if (!foundArch) { missingResearchType = ResearchTypes.Archeology; bioImageSpot.sprite = bioImage; geoImageSpot.sprite = geoImage; } geoSlotText.text = ""; bioSlotText.text = ""; archSlotText.text = ""; equipmentPrefab = (GameObject)Resources.Load("EquipmentSlot"); equipmentParent = this.gameObject.transform.GetChild(1).gameObject; foreach (Equipment e in PlayerManager.instance.equipment) { slot = Instantiate(equipmentPrefab) as GameObject; slot.transform.SetParent(equipmentParent.transform, false); slots.Add(slot); equipmentText = slot.transform.GetChild(0).GetComponent <Text>(); levelText = slot.transform.GetChild(1).GetComponent <Text>(); equipmentText.text = String.Format("{0}", e.name); levelText.text = String.Format("Level: {0}", e.level); Image icon = slot.transform.GetChild(2).GetComponent <Image>(); if (e is TransmitterEquipment) { slot.transform.GetChild(2).GetComponent <Image>().sprite = transmitterImage; } else if (e is EnergyEquipment) { slot.transform.GetChild(2).GetComponent <Image>().sprite = batteryImage; } else if (e is StorageEquipment) { slot.transform.GetChild(2).GetComponent <Image>().sprite = storageImage; } else if (e is WeaponEquipment) { slot.transform.GetChild(2).GetComponent <Image>().sprite = weaponImage; } else if (e is ResearchEquipment) { ResearchEquipment rE = (ResearchEquipment)e; if (rE.type == ResearchTypes.Archeology) { slot.transform.GetChild(2).GetComponent <Image>().sprite = archImage; } else if (rE.type == ResearchTypes.Biology) { slot.transform.GetChild(2).GetComponent <Image>().sprite = bioImage; } else if (rE.type == ResearchTypes.Geology) { slot.transform.GetChild(2).GetComponent <Image>().sprite = geoImage; } } } equipmentParent.SetActive(equipmentToggle); }