public AugmentPickup SpawnAugment(Vector3 position, AugmentInfo info, Island island) { Vector2 posV2 = PosToV2(position); if (island == null || GetBuildingAtPosition(posV2) != null || GetPickupAtPosition(posV2) != null) { return(null); } if (!Crafting.instance.augmentInfos.Contains(info)) { Debug.LogError("Augment info not found in list"); return(null); } GameObject augmentGO = Instantiate(info.pickupPrefab, island.transform); augmentGO.transform.position = position; AugmentPickup augment = new AugmentPickup(info, augmentGO, island); pickups.Add(posV2, augment); island.pickups.Add(augment); SavedGame.UpdatePickups(); return(augment); }
public void Spawn() { GameObject tileAtPos = TerrainManager.instance.GetTileAtPosition(tilePos.ToVector2()); Vector3 spawnPos = new Vector3(tilePos.x, tileAtPos.transform.position.y, tilePos.y); Island island = tileAtPos.transform.parent.GetComponent <Island>(); for (int i = 0; i < stackHeight; i++) { switch (pickupType) { case 0: TerrainManager.instance.SpawnResource(spawnPos, ResourceInfo.GetInfoFromIndex(index), island); break; case 1: TerrainManager.instance.SpawnWeapon(spawnPos, WeaponInfo.GetInfoFromIndex(index), island); break; case 2: TerrainManager.instance.SpawnAugment(spawnPos, AugmentInfo.GetInfoFromIndex(index), island); break; default: Debug.LogError("Unrecognized pickup type"); break; } } }
public void InitAugments(List <int> augmentIndexes) { for (int i = 0; i < augmentIndexes.Count; i++) { body.augmentSlots [i].UpdateAugment(AugmentInfo.GetInfoFromIndex(augmentIndexes [i])); } }
public void DropAugment(int slotIndex) { if (!body.augmentSlots[slotIndex].isEmpty) { Vector2 posV2 = TerrainManager.PosToV2(playerTransform.position); if (tm.PadAtPosition(posV2) != null) { return; } if (tm.SpawnAugment(playerTransform.position, body.augmentSlots[slotIndex].augment, body.location) == null) { return; } } body.augmentSlots [slotIndex].UpdateAugment(AugmentInfo.GetInfoFromIndex(0)); if (!GameManager.isLoadingFromSave) { GameManager.instance.SaveThisTurn(); } OpenItemsUI(false); }
public void TestForCrafting() { foreach (Vector2 key in tm.pickups.Keys.ToList()) { if (ResourcePickup.IsAtPosition(key)) { ResourcePickup resourceToTest = tm.pickups [key] as ResourcePickup; Vector3 spawnPos; Craftable craftableInfo = GetCraftableForResource(resourceToTest, out spawnPos); if (craftableInfo is BuildingInfo) { BuildingInfo buildingInfo = craftableInfo as BuildingInfo; if (!blueprints.ContainsKey(resourceToTest)) { Building newBuilding = tm.SpawnBuilding(spawnPos, buildingInfo.prefab, buildingInfo, resourceToTest.island); blueprints.Add(resourceToTest, newBuilding); } } else if (craftableInfo is WeaponInfo) { WeaponInfo weaponInfo = craftableInfo as WeaponInfo; tm.SpawnWeapon(spawnPos, weaponInfo, resourceToTest.island); } else if (craftableInfo is AugmentInfo) { AugmentInfo augmentInfo = craftableInfo as AugmentInfo; tm.SpawnAugment(spawnPos, augmentInfo, resourceToTest.island); } } } }
void ResetAugments() { foreach (SlotData slot in augmentSlots) { if (slot.augment.ToIndex() == -1) { slot.UpdateAugment(AugmentInfo.GetInfoFromIndex(0)); } } }
public AugmentPickup(AugmentInfo _info, GameObject _augmentGO, Island _island) { info = _info; island = _island; gameObjects.Add(_augmentGO); if (_augmentGO != null) { UpdatePosition(); } }
public void UpdateAugment(AugmentInfo newAugment) { if (parent.childCount > 0) { Destroy(parent.GetChild(0).gameObject); } augment = newAugment; if (newAugment.augmentPrefab != null) { Instantiate(newAugment.augmentPrefab, parent); } }
public bool UpdateAugment(AugmentInfo newAugment) { SlotData slot = GetAvailableSlot(newAugment.type); if (slot != null) { slot.UpdateAugment(newAugment); if (healthBar != null) { healthBar.UpdateBar(health, maxHealth); } return(true); } else { return(false); } }