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; } } }
void SwitchWeapons(int weaponIndex) { WeaponInfo currentWeaponInfo = body.weapon.info; if (currentWeaponInfo.ToIndex() != 0) { Vector2 posV2 = TerrainManager.PosToV2(playerTransform.position); if (tm.PadAtPosition(posV2) != null) { return; } if (tm.SpawnWeapon(playerTransform.position, currentWeaponInfo, body.location) == null) { return; } } body.weapon.info = WeaponInfo.GetInfoFromIndex(weaponIndex); body.weapon.UpdateWeapon(); if (!GameManager.isLoadingFromSave) { GameManager.instance.SaveThisTurn(); } }