plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent 195b696771
commit 779f2c8b20
14443 changed files with 23840465 additions and 452 deletions

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7b628c6ae6388624abbab523942d5428
folderAsset: yes
timeCreated: 1573354099
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,68 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class abilityPickup : pickupType
{
[Header ("Custom Pickup Settings")]
[Space]
public string abilityName;
playerAbilitiesSystem mainPlayerAbilitiesSystem;
GameObject lastCharacter;
public override bool checkIfCanBePicked ()
{
GameObject character = gameObject;
if (finderIsPlayer) {
character = player;
}
if (finderIsCharacter) {
character = npc;
}
playerComponentsManager mainPlayerComponentsManager = character.GetComponent<playerComponentsManager> ();
if (mainPlayerComponentsManager != null) {
mainPlayerAbilitiesSystem = mainPlayerComponentsManager.getPlayerAbilitiesSystem ();
if (mainPlayerAbilitiesSystem != null) {
canPickCurrentObject = true;
}
lastCharacter = character;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (finderIsPlayer) {
mainPlayerAbilitiesSystem.enableAbilityByName (abilityName);
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage (abilityName + " Unlocked");
}
}
if (finderIsCharacter) {
mainPlayerAbilitiesSystem.enableAbilityByName (abilityName);
}
if (lastCharacter != null) {
GKC_Utils.setUnlockStateOnSkill (lastCharacter.transform, abilityName, true);
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: dac43b8225991f44fba921bc23e3b7b5
timeCreated: 1634956359
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/abilityPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,165 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ammoPickup : pickupType
{
[Header ("Custom Pickup Settings")]
[Space]
public string ammoName;
public string unableToPickAmmoMessage = "You haven't weapons with this ammo type";
playerWeaponsManager weaponsManager;
public override bool checkIfCanBePicked ()
{
if (storePickupOnInventory) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
amountTaken = mainPickupObject.getLastinventoryAmountPicked ();
} else {
if (finderIsPlayer || finderIsCharacter) {
GameObject character = player;
if (finderIsCharacter) {
character = npc;
}
weaponsManager = character.GetComponent<playerWeaponsManager> ();
bool weaponAvailable = weaponsManager.checkIfWeaponIsAvailable (ammoName);
bool weaponHasAmmoLimit = weaponsManager.hasAmmoLimit (ammoName);
if (!weaponAvailable) {
inventoryManager mainInventoryManager = character.GetComponent<inventoryManager> ();
if (mainInventoryManager != null) {
if (mainInventoryManager.existInPlayerInventoryFromName (ammoName)) {
weaponAvailable = true;
if (showDebugPrint) {
print ("weapon is available in the inventory not equipped, but the ammo can be taken and added directly to the weapon");
}
}
}
}
if (weaponAvailable) {
if (weaponHasAmmoLimit) {
bool weaponHasMaximumAmmoAmount = weaponsManager.hasMaximumAmmoAmount (ammoName);
if (weaponHasMaximumAmmoAmount) {
if (showDebugPrint) {
print ("maximum amount on " + ammoName);
}
}
if (!weaponHasMaximumAmmoAmount) {
amountTaken = applyDamage.getPlayerWeaponAmmoAmountToPick (weaponsManager, ammoName, mainPickupObject.amount);
if (amountTaken > 0) {
canPickCurrentObject = true;
}
}
} else {
amountTaken = mainPickupObject.amount;
canPickCurrentObject = true;
}
} else {
showPickupTakenMessage (unableToPickAmmoMessage);
}
}
if (finderIsVehicle) {
vehicleWeaponSystem currentVehicleWeaponSystem = vehicle.GetComponentInChildren<vehicleWeaponSystem> ();
if (currentVehicleWeaponSystem != null) {
bool weaponAvailable = currentVehicleWeaponSystem.checkIfWeaponIsAvailable (ammoName);
bool weaponHasAmmoLimit = currentVehicleWeaponSystem.hasAmmoLimit (ammoName);
if (weaponAvailable) {
if (weaponHasAmmoLimit) {
bool weaponHasMaximumAmmoAmount = currentVehicleWeaponSystem.hasMaximumAmmoAmount (ammoName);
if (weaponHasMaximumAmmoAmount) {
if (showDebugPrint) {
print ("maximum amount on " + ammoName);
}
}
if (!weaponHasMaximumAmmoAmount) {
amountTaken = applyDamage.getVehicleWeaponAmmoAmountToPick (currentVehicleWeaponSystem, ammoName, mainPickupObject.amount);
if (amountTaken > 0) {
canPickCurrentObject = true;
}
}
} else {
amountTaken = mainPickupObject.amount;
canPickCurrentObject = true;
}
}
}
}
mainPickupObject.amount -= amountTaken;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (showDebugPrint) {
print ("total amount taken " + amountTaken);
}
if (!storePickupOnInventory) {
if (finderIsPlayer) {
weaponsManager.AddAmmo ((int)Mathf.Round (amountTaken), ammoName);
}
if (finderIsVehicle) {
mainPickupObject.vehicleHUD.getAmmo (ammoName, (int)Mathf.Round (amountTaken));
}
if (finderIsCharacter) {
weaponsManager.AddAmmo ((int)Mathf.Round (amountTaken), ammoName);
}
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
if (storePickupOnInventory) {
showPickupTakenMessage ("Ammo " + ammoName + " x " + Mathf.Round (amountTaken) + " Stored");
} else {
showPickupTakenMessage ("Ammo " + ammoName + " x " + Mathf.Round (amountTaken));
}
}
mainPickupObject.playPickupSound ();
if (mainPickupObject.amount > 0 && !takeWithTrigger) {
mainPickupObject.checkEventOnRemainingAmount ();
return;
}
mainPickupObject.removePickupFromLevel ();
}
public void setAmmoName (string newAmmoName)
{
ammoName = newAmmoName;
}
public override void renameObject (string newName)
{
setAmmoName (newName);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 8167ec4e24f98f34cb60166a6f106780
timeCreated: 1565408314
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/ammoPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,79 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class energyPickup : pickupType
{
public override bool checkIfCanBePicked ()
{
if (storePickupOnInventory) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
amountTaken = mainPickupObject.getLastinventoryAmountPicked ();
} else {
GameObject character = gameObject;
if (finderIsPlayer) {
character = player;
}
if (finderIsVehicle) {
character = vehicle;
}
if (finderIsCharacter) {
character = npc;
}
amountTaken = (int)applyDamage.getEnergyAmountToPick (character, mainPickupObject.amount);
//print (amountTaken);
if (amountTaken > 0) {
canPickCurrentObject = true;
}
mainPickupObject.amount -= amountTaken;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (showDebugPrint) {
print ("total amount taken " + amountTaken);
}
if (!storePickupOnInventory) {
if (finderIsPlayer) {
applyDamage.setEnergy (amountTaken, player);
}
if (finderIsVehicle) {
applyDamage.setEnergy (amountTaken, vehicle);
}
if (finderIsCharacter) {
applyDamage.setEnergy (amountTaken, npc);
}
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
if (storePickupOnInventory) {
showPickupTakenMessage ("Energy x " + amountTaken + " Stored");
} else {
showPickupTakenMessage ("Energy x " + amountTaken);
}
}
mainPickupObject.playPickupSound ();
if (mainPickupObject.amount > 0 && !takeWithTrigger) {
mainPickupObject.checkEventOnRemainingAmount ();
return;
}
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 7914c3b9a2587ed4188b0b5d93090c7b
timeCreated: 1565418784
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/energyPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class experienceMultiplierPickup : pickupType
{
[Header ("Custom Pickup Settings")]
[Space]
public float experienceMultiplierAmount;
public float experienceMultiplierDuration;
public override bool checkIfCanBePicked ()
{
GameObject character = gameObject;
if (finderIsPlayer) {
character = player;
canPickCurrentObject = true;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (finderIsPlayer) {
applyDamage.setExperienceMultiplier (experienceMultiplierAmount, player, experienceMultiplierDuration);
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage ("Exp Multiplier x " + experienceMultiplierAmount + " during " + experienceMultiplierDuration + " seconds");
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 82b7e09da54fe9549a8f3e0e79bda67e
timeCreated: 1568009967
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/experienceMultiplierPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class experiencePickup : pickupType
{
[Header ("Custom Pickup Settings")]
[Space]
public bool useExperienceRandomRange;
public Vector2 experienceRandomRange;
public override bool checkIfCanBePicked ()
{
GameObject character = gameObject;
if (finderIsPlayer) {
character = player;
amountTaken = mainPickupObject.amount;
canPickCurrentObject = true;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (finderIsPlayer) {
applyDamage.setExperience (amountTaken, player, transform, useExperienceRandomRange, experienceRandomRange);
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage ("Experience increased in " + amountTaken);
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 0face5655a3337a4bb597825cf1a803c
timeCreated: 1567478510
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/experiencePickup.cs
uploadId: 814740

View File

@@ -0,0 +1,113 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class generalPickup : pickupType
{
[Header ("Custom Settings")]
[Space]
public List<statInfo> statInfoList = new List<statInfo> ();
[Space]
[Space]
public string pickupName;
public override bool checkIfCanBePicked ()
{
if (storePickupOnInventory) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
amountTaken = mainPickupObject.getLastinventoryAmountPicked ();
} else {
canPickCurrentObject = true;
mainPickupObject.amount = 0;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (!storePickupOnInventory) {
GameObject character = player;
if (finderIsCharacter) {
character = npc;
}
//if the player is not driving then
playerComponentsManager currentPlayerComponetsManager = character.GetComponent<playerComponentsManager> ();
if (currentPlayerComponetsManager != null) {
playerStatsSystem currentPlayerStatsSystem = currentPlayerComponetsManager.getPlayerStatsSystem ();
remoteEventSystem currentRemoteEventSystem = currentPlayerComponetsManager.getRemoteEventSystem ();
if (currentPlayerStatsSystem != null) {
for (int k = 0; k < statInfoList.Count; k++) {
currentPlayerStatsSystem.addOrRemovePlayerStatAmount (statInfoList [k].Name, statInfoList [k].amountToAdd);
if (statInfoList [k].useRemoteEvent) {
if (currentRemoteEventSystem != null) {
for (int i = 0; i < statInfoList [k].remoteEventList.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (statInfoList [k].remoteEventList [i]);
}
}
}
}
}
}
checkIfEnableAbilitiesOnTakePickup (character);
checkIfActivateAbilitiesOnTakePickup (character);
checkIfaddNewBlueprintsUnlockedList (character);
}
//set the info in the screen to show the type of object used and its amount
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
if (storePickupOnInventory) {
showPickupTakenMessage (pickupName + " x " + amountTaken + " Stored");
} else {
showPickupTakenMessage (pickupName + " x " + amountTaken);
}
}
mainPickupObject.playPickupSound ();
checkIfUseInventoryObjectWhenPicked ();
mainPickupObject.removePickupFromLevel ();
}
public void setConsumableName (string newConsumableName)
{
pickupName = newConsumableName;
}
public override void renameObject (string newName)
{
setConsumableName (newName);
}
[System.Serializable]
public class statInfo
{
public string Name;
public float amountToAdd;
public bool useRemoteEvent;
public List<string> remoteEventList = new List<string> ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 3c55ae2b77268c742a44459d10293ec5
timeCreated: 1581134220
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/generalPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class grabObjectsStrengthPickup : pickupType
{
public override bool checkIfCanBePicked ()
{
GameObject character = gameObject;
if (finderIsPlayer) {
character = player;
canPickCurrentObject = true;
amountTaken = mainPickupObject.amount;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (finderIsPlayer) {
applyDamage.increaseStrengthAmountAndUpdateStat (amountTaken, player);
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage ("Grab Objects Strength + " + amountTaken);
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 1d80e62bb9be34443afa15f7e8f0b8d2
timeCreated: 1573591931
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/grabObjectsStrengthPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,93 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class healthPickup : pickupType
{
public override bool checkIfCanBePicked ()
{
if (storePickupOnInventory) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
amountTaken = mainPickupObject.getLastinventoryAmountPicked ();
} else {
GameObject character = gameObject;
if (finderIsPlayer) {
//if the player is not driving then increase an auxiliar value to check the amount of the same pickup that the player will use at once
//for example, when the player is close to more than one pickup, if he has 90/100 of health and he is close to two health pickups,
//he only will grab one of them.
character = player;
}
if (finderIsVehicle) {
//check the same if the player is driving and works in the same way for any type of pickup
character = vehicle;
}
if (finderIsCharacter) {
character = npc;
}
amountTaken = (int)applyDamage.getHealthAmountToPick (character, mainPickupObject.amount);
if (amountTaken > 0) {
canPickCurrentObject = true;
}
mainPickupObject.amount -= amountTaken;
}
if (showDebugPrint) {
print ("can pick current object " + canPickCurrentObject);
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (showDebugPrint) {
print ("total amount taken " + amountTaken);
}
if (!storePickupOnInventory) {
//if the player is not driving then
if (finderIsPlayer) {
//increase its health
applyDamage.setHeal (amountTaken, player);
}
//the player is driving so the pickup will recover its health
if (finderIsVehicle) {
applyDamage.setHeal (amountTaken, vehicle);
}
if (finderIsCharacter) {
applyDamage.setHeal (amountTaken, npc);
}
}
//set the info in the screen to show the type of object used and its amount
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
if (storePickupOnInventory) {
showPickupTakenMessage ("Health x " + amountTaken + " Stored");
} else {
showPickupTakenMessage ("Health x " + amountTaken);
}
}
mainPickupObject.playPickupSound ();
checkIfUseInventoryObjectWhenPicked ();
if (mainPickupObject.amount > 0 && !takeWithTrigger) {
mainPickupObject.checkEventOnRemainingAmount ();
return;
}
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 0eed069a022e38746836a59c5ab0b830
timeCreated: 1565417306
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/healthPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class inventoryExtraSpacePickup : pickupType
{
public override bool checkIfCanBePicked ()
{
if (finderIsPlayer) {
canPickCurrentObject = true;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (finderIsPlayer) {
int extraSpaceAmount = mainPickupObject.inventoryObjectManager.inventoryObjectInfo.amount;
player.GetComponent<inventoryManager> ().addInventoryExtraSpace (extraSpaceAmount);
if (useCustomPickupMessage) {
showPickupTakenMessage (extraSpaceAmount);
} else {
showPickupTakenMessage ("+" + extraSpaceAmount + " slots added to inventory");
}
mainPickupObject.playPickupSound ();
}
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d7c60d2168ca2df428232741a73c50ee
timeCreated: 1565420313
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/inventoryExtraSpacePickup.cs
uploadId: 814740

View File

@@ -0,0 +1,58 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class inventoryPickup : pickupType
{
public override bool checkIfCanBePicked ()
{
if (finderIsPlayer) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
amountTaken = mainPickupObject.getLastinventoryAmountPicked ();
}
if (finderIsCharacter) {
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (finderIsPlayer) {
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
if (storePickupOnInventory) {
string messageToUse = mainPickupObject.inventoryObjectManager.inventoryObjectInfo.Name;
if (amountTaken > 1) {
messageToUse += " x " + amountTaken;
} else {
messageToUse += " Stored";
}
showPickupTakenMessage (messageToUse);
}
}
mainPickupObject.playPickupSound ();
if (storePickupOnInventory && useInventoryObjectWhenPicked) {
if (mainPickupObject.playerInventoryManager != null) {
mainPickupObject.playerInventoryManager.useInventoryObjectByName (mainPickupObject.inventoryObjectManager.inventoryObjectInfo.Name, 1);
}
}
if (mainPickupObject.amount > 0 && !takeWithTrigger) {
mainPickupObject.checkEventOnRemainingAmount ();
return;
}
}
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d8982e4f1407a2f4ea4bb000cf842f7d
timeCreated: 1565419040
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/inventoryPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class inventoryWeightBagPickup : pickupType
{
public override bool checkIfCanBePicked ()
{
GameObject character = gameObject;
if (finderIsPlayer) {
character = player;
canPickCurrentObject = true;
amountTaken = mainPickupObject.amount;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (finderIsPlayer) {
applyDamage.increaseInventoryBagWeight (amountTaken, player);
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage ("Inventory Weight Bag + " + amountTaken);
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 8d1b00da7db9bba4a8e0b46a64e8dca1
timeCreated: 1573590261
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/inventoryWeightBagPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,63 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class jetpackFuelPickup : pickupType
{
public override bool checkIfCanBePicked ()
{
if (storePickupOnInventory) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
amountTaken = mainPickupObject.getLastinventoryAmountPicked ();
} else {
if (finderIsPlayer) {
canPickCurrentObject = true;
}
mainPickupObject.amount -= amountTaken;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (showDebugPrint) {
print ("total amount taken " + amountTaken);
}
if (!storePickupOnInventory) {
if (finderIsPlayer) {
playerComponentsManager mainPlayerComponentsManager = player.GetComponent<playerComponentsManager> ();
if (mainPlayerComponentsManager != null) {
jetpackSystem jetpackManager = mainPlayerComponentsManager.getJetpackSystem ();
if (jetpackManager) {
jetpackManager.getJetpackFuel (amountTaken);
}
}
}
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
if (storePickupOnInventory) {
showPickupTakenMessage ("Jetpack Fuel x " + amountTaken + " Stored");
} else {
showPickupTakenMessage ("Jetpack Fuel x " + amountTaken);
}
}
mainPickupObject.playPickupSound ();
if (mainPickupObject.amount > 0 && !takeWithTrigger) {
mainPickupObject.checkEventOnRemainingAmount ();
return;
}
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 82f642171b8f7b140b409aa83e987646
timeCreated: 1565419372
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/jetpackFuelPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mapPickup : pickupType
{
public override bool checkIfCanBePicked ()
{
if (finderIsPlayer) {
canPickCurrentObject = true;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (finderIsPlayer) {
GetComponent<mapZoneUnlocker> ().unlockMapZone ();
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage ("Map Zone Picked");
}
mainPickupObject.playPickupSound ();
}
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 97a8495f28e08004a8be4a88e363f8fa
timeCreated: 1565420649
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/mapPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,92 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class meleeShieldPickup : pickupType
{
[Header ("Custom Settings")]
[Space]
public string shieldName;
bool storePickedShieldsOnInventory;
public override bool checkIfCanBePicked ()
{
if (finderIsPlayer) {
if (mainPickupObject.inventoryObjectManager != null) {
bool storeShieldOnInventory = false;
playerComponentsManager mainPlayerComponentsManager = player.GetComponent<playerComponentsManager> ();
if (mainPlayerComponentsManager != null) {
meleeWeaponsGrabbedManager mainMeleeWeaponsGrabbedManager = mainPlayerComponentsManager.getMeleeWeaponsGrabbedManager ();
if (mainMeleeWeaponsGrabbedManager != null) {
if (mainMeleeWeaponsGrabbedManager.storePickedWeaponsOnInventory) {
storeShieldOnInventory = true;
} else {
mainMeleeWeaponsGrabbedManager.equipShield (shieldName);
}
}
}
if (storeShieldOnInventory) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
} else {
canPickCurrentObject = true;
}
storePickedShieldsOnInventory = true;
amountTaken = mainPickupObject.amount;
}
}
if (finderIsCharacter) {
findObjectivesSystem currentfindObjectivesSystem = npc.GetComponent<findObjectivesSystem> ();
if (currentfindObjectivesSystem != null) {
}
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
bool shieldPickedCorrectly = false;
if (finderIsPlayer) {
if (storePickedShieldsOnInventory) {
shieldPickedCorrectly = true;
} else {
// weaponPickedCorrectly = weaponsManager.pickWeapon (weaponName);
}
}
// if (finderIsCharacter) {
// weaponPickedCorrectly = weaponsManager.pickWeapon (weaponName);
// }
if (!shieldPickedCorrectly) {
return;
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage (shieldName + " Picked");
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
public void setMeleeShieldName (string newShieldName)
{
shieldName = newShieldName;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 5c15f0395041dc845b1966b2df287d60
timeCreated: 1617129107
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/meleeShieldPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,75 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class meleeWeaponConsumablePickup : pickupType
{
[Header ("Custom Settings")]
[Space]
public string weaponConsumableName;
// meleeWeaponsGrabbedManager mainMeleeWeaponsGrabbedManager;
bool storePickedWeaponsOnInventory;
public override bool checkIfCanBePicked ()
{
if (finderIsPlayer) {
if (mainPickupObject.inventoryObjectManager != null) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
storePickedWeaponsOnInventory = true;
amountTaken = mainPickupObject.amount;
}
}
if (finderIsCharacter) {
findObjectivesSystem currentfindObjectivesSystem = npc.GetComponent<findObjectivesSystem> ();
if (currentfindObjectivesSystem != null) {
if (currentfindObjectivesSystem.isSearchingWeapon ()) {
}
}
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
bool weaponPickedCorrectly = false;
if (finderIsPlayer) {
if (storePickedWeaponsOnInventory) {
weaponPickedCorrectly = true;
} else {
// weaponPickedCorrectly = weaponsManager.pickWeapon (weaponName);
}
}
// if (finderIsCharacter) {
// weaponPickedCorrectly = weaponsManager.pickWeapon (weaponName);
// }
if (!weaponPickedCorrectly) {
return;
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage (weaponConsumableName + " Picked");
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
public void setWeaponConsumableName (string newWeaponConsumableName)
{
weaponConsumableName = newWeaponConsumableName;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: fdf2a586c842bbb4fbb5700958b83c3d
timeCreated: 1623454046
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/meleeWeaponConsumablePickup.cs
uploadId: 814740

View File

@@ -0,0 +1,80 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class meleeWeaponPickup : pickupType
{
[Header ("Custom Settings")]
[Space]
public string weaponName;
// meleeWeaponsGrabbedManager mainMeleeWeaponsGrabbedManager;
bool storePickedWeaponsOnInventory;
public override bool checkIfCanBePicked ()
{
if (finderIsPlayer) {
if (mainPickupObject.inventoryObjectManager != null) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
storePickedWeaponsOnInventory = true;
amountTaken = mainPickupObject.amount;
}
}
if (finderIsCharacter) {
findObjectivesSystem currentfindObjectivesSystem = npc.GetComponent<findObjectivesSystem> ();
if (currentfindObjectivesSystem != null) {
if (currentfindObjectivesSystem.isSearchingWeapon ()) {
}
}
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
bool weaponPickedCorrectly = false;
if (finderIsPlayer) {
if (storePickedWeaponsOnInventory) {
weaponPickedCorrectly = true;
} else {
// weaponPickedCorrectly = weaponsManager.pickWeapon (weaponName);
}
}
// if (finderIsCharacter) {
// weaponPickedCorrectly = weaponsManager.pickWeapon (weaponName);
// }
if (!weaponPickedCorrectly) {
return;
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage (weaponName + " Picked");
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
public void setMeleeWeaponName (string newWeaponName)
{
weaponName = newWeaponName;
}
public override void renameObject (string newName)
{
setMeleeWeaponName (newName);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: f15dc510074910f40a97a479a23947b5
timeCreated: 1611322645
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/meleeWeaponPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class moneyPickup : pickupType
{
[Header ("Custom Pickup Settings")]
[Space]
public bool useMoneyRandomRange;
public Vector2 moneyRandomRange;
public override bool checkIfCanBePicked ()
{
GameObject character = gameObject;
if (finderIsPlayer) {
character = player;
amountTaken = mainPickupObject.amount;
canPickCurrentObject = true;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (finderIsPlayer) {
applyDamage.setMoney (amountTaken, player, useMoneyRandomRange, moneyRandomRange);
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d272fd2efc7b2cf498c166494842d029
timeCreated: 1567476405
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/moneyPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,88 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class oxygenPickup : pickupType
{
[Header ("Custom Pickup Settings")]
[Space]
public bool refillOxygen;
public override bool checkIfCanBePicked ()
{
if (storePickupOnInventory) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
amountTaken = mainPickupObject.getLastinventoryAmountPicked ();
} else {
GameObject character = gameObject;
if (finderIsPlayer) {
character = player;
}
if (finderIsCharacter) {
character = npc;
}
if (refillOxygen) {
amountTaken = mainPickupObject.amount;
} else {
amountTaken = (int)applyDamage.getOxygenAmountToPick (character, mainPickupObject.amount);
}
if (amountTaken > 0) {
canPickCurrentObject = true;
}
mainPickupObject.amount -= amountTaken;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (showDebugPrint) {
print ("total amount taken " + amountTaken);
}
if (!storePickupOnInventory) {
if (finderIsPlayer) {
if (refillOxygen) {
applyDamage.refillFullOxygen (player);
} else {
applyDamage.setOxygen (amountTaken, player);
}
}
if (finderIsCharacter) {
applyDamage.setOxygen (amountTaken, npc);
}
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
if (storePickupOnInventory) {
showPickupTakenMessage ("Oxygen x " + amountTaken + " Stored");
} else {
if (refillOxygen) {
showPickupTakenMessage ("Oxygen Refilled");
} else {
showPickupTakenMessage ("Oxygen x " + amountTaken);
}
}
}
mainPickupObject.playPickupSound ();
if (mainPickupObject.amount > 0 && !takeWithTrigger) {
mainPickupObject.checkEventOnRemainingAmount ();
return;
}
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 49c18972a90d38d4785aeabda22a5c2a
timeCreated: 1566641289
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/oxygenPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,194 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pickupType : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool storePickupOnInventory;
public bool useInventoryObjectWhenPicked;
[Space]
[Header ("Pickup Message Settings")]
[Space]
public bool useCustomPickupMessage = true;
[Space]
[TextArea (5, 15)] public string objectTakenAsPickupMessage;
[TextArea (5, 15)] public string objectTakenAsInventoryMessage;
[Space]
[TextArea (2, 6)] public string explanation = "Use -AMOUNT- in the position of the text \n to replace the amount picked if you need it";
[Space]
[Header ("Enable Abilities on Use Take Pickup Settings")]
[Space]
public bool useAbilitiesListToEnableOnTakePickup;
[Space]
public List<string> abilitiesListToEnableOnTakePickup = new List<string> ();
[Space]
[Header ("Activate Abilities on Take Pickup Settings")]
[Space]
public bool activateAbilityOnTakePickup;
[Space]
public string abilityNameToActiveOnTakePickup;
public bool abilityIsTemporallyActivated;
[Space]
[Header ("Crafting Settings")]
[Space]
public bool getCraftingRecipes;
public List<string> craftingRecipesList = new List<string> ();
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
[Space]
[Header ("Components")]
[Space]
public pickUpObject mainPickupObject;
protected bool canPickCurrentObject;
protected bool finderIsPlayer;
protected bool finderIsVehicle;
protected bool finderIsCharacter;
protected GameObject player;
protected GameObject vehicle;
protected GameObject npc;
protected bool takeWithTrigger;
protected int amountTaken;
public void takePickupByButton ()
{
assignPickupObjectState ();
if (checkIfCanBePicked ()) {
mainPickupObject.confirmTakePickupByButton ();
}
}
public void takePickupByTrigger ()
{
assignPickupObjectState ();
if (checkIfCanBePicked ()) {
mainPickupObject.confirmTakePickupByTrigger ();
}
}
public void assignPickupObjectState ()
{
canPickCurrentObject = false;
finderIsPlayer = mainPickupObject.finderIsPlayer;
finderIsVehicle = mainPickupObject.finderIsVehicle;
finderIsCharacter = mainPickupObject.finderIsCharacter;
player = mainPickupObject.player;
vehicle = mainPickupObject.vehicle;
npc = mainPickupObject.npc;
takeWithTrigger = mainPickupObject.takeWithTrigger;
}
public virtual bool checkIfCanBePicked ()
{
return canPickCurrentObject;
}
public virtual void confirmTakePickup ()
{
}
public virtual void showPickupTakenMessage (int amountToShow)
{
string currentPickedMessage = objectTakenAsPickupMessage;
if (storePickupOnInventory) {
currentPickedMessage = objectTakenAsInventoryMessage;
}
if (currentPickedMessage != "") {
string amountString = amountToShow.ToString ();
currentPickedMessage = currentPickedMessage.Replace ("-AMOUNT-", amountString);
mainPickupObject.showRecieveInfo (currentPickedMessage);
}
}
public virtual void showPickupTakenMessage (string messageToUse)
{
if (messageToUse != "") {
mainPickupObject.showRecieveInfo (messageToUse);
}
}
public void checkIfUseInventoryObjectWhenPicked ()
{
if (storePickupOnInventory && useInventoryObjectWhenPicked) {
if (mainPickupObject.playerInventoryManager != null) {
mainPickupObject.playerInventoryManager.useInventoryObjectByName (mainPickupObject.inventoryObjectManager.inventoryObjectInfo.Name, 1);
}
}
}
public virtual void checkIfEnableAbilitiesOnTakePickup (GameObject currentPlayer)
{
if (useAbilitiesListToEnableOnTakePickup && currentPlayer != null) {
GKC_Utils.enableOrDisableAbilityGroupByName (currentPlayer.transform, true, abilitiesListToEnableOnTakePickup);
}
}
public virtual void checkIfActivateAbilitiesOnTakePickup (GameObject currentPlayer)
{
if (activateAbilityOnTakePickup && currentPlayer != null) {
GKC_Utils.activateAbilityByName (currentPlayer.transform, abilityNameToActiveOnTakePickup, abilityIsTemporallyActivated, true);
}
}
public virtual void checkIfaddNewBlueprintsUnlockedList (GameObject currentPlayer)
{
if (getCraftingRecipes && currentPlayer != null) {
GKC_Utils.addNewBlueprintsUnlockedList (currentPlayer, craftingRecipesList);
}
}
public virtual void setObjectTakenAsPickupMessage (string newMessage)
{
objectTakenAsPickupMessage = newMessage;
}
public virtual void setObjectTakenAsInventoryMessage (string newMessage)
{
objectTakenAsInventoryMessage = newMessage;
}
public virtual void renameObject (string newName)
{
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 12fb58b0071c99a4791e904282c9c77e
timeCreated: 1565584169
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/pickupType.cs
uploadId: 814740

View File

@@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class powerPickup : pickupType
{
[Header ("Custom Pickup Settings")]
[Space]
public string powerName;
powersAndAbilitiesSystem powersAndAbilitiesManager;
public override bool checkIfCanBePicked ()
{
GameObject character = gameObject;
if (finderIsPlayer) {
character = player;
}
if (finderIsCharacter) {
character = npc;
}
powersAndAbilitiesManager = character.GetComponentInChildren<powersAndAbilitiesSystem> ();
if (powersAndAbilitiesManager != null) {
canPickCurrentObject = true;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (finderIsPlayer) {
powersAndAbilitiesManager.enableGeneralPower (powerName);
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage (powerName + " Activated");
}
}
if (finderIsCharacter) {
powersAndAbilitiesManager.enableGeneralPower (powerName);
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 35ba7130dfa9fc8469c2cd909de08a6d
timeCreated: 1565421365
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/powerPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class rewardPickup : pickupType
{
public objectExperienceSystem mainObjectExperienceSystem;
public override bool checkIfCanBePicked ()
{
GameObject character = gameObject;
if (finderIsPlayer) {
character = player;
canPickCurrentObject = true;
amountTaken = mainPickupObject.amount;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (finderIsPlayer) {
mainObjectExperienceSystem.sendExperienceToPlayer (player);
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage ("Rewards Obtained x " + amountTaken);
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 41ae62e50548b0d449f8f16fa5447c26
timeCreated: 1682831481
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/rewardPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,78 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class shieldPickup : pickupType
{
public override bool checkIfCanBePicked ()
{
if (storePickupOnInventory) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
amountTaken = mainPickupObject.getLastinventoryAmountPicked ();
} else {
GameObject character = gameObject;
if (finderIsPlayer) {
character = player;
}
if (finderIsVehicle) {
character = vehicle;
}
if (finderIsCharacter) {
character = npc;
}
amountTaken = (int)applyDamage.getShieldAmountToPick (character, mainPickupObject.amount);
if (amountTaken > 0) {
canPickCurrentObject = true;
}
mainPickupObject.amount -= amountTaken;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (showDebugPrint) {
print ("total amount taken " + amountTaken);
}
if (!storePickupOnInventory) {
if (finderIsPlayer) {
applyDamage.setShield (amountTaken, player);
}
if (finderIsVehicle) {
applyDamage.setShield (amountTaken, vehicle);
}
if (finderIsCharacter) {
applyDamage.setShield (amountTaken, npc);
}
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
if (storePickupOnInventory) {
showPickupTakenMessage ("Shield x " + amountTaken + " Stored");
} else {
showPickupTakenMessage ("Shield x " + amountTaken);
}
}
mainPickupObject.playPickupSound ();
if (mainPickupObject.amount > 0 && !takeWithTrigger) {
mainPickupObject.checkEventOnRemainingAmount ();
return;
}
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: ffe1e8eee22fbc846b3cb35e15184ff1
timeCreated: 1566400981
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/shieldPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class skillPointPickup : pickupType
{
public override bool checkIfCanBePicked ()
{
GameObject character = gameObject;
if (finderIsPlayer) {
character = player;
canPickCurrentObject = true;
amountTaken = mainPickupObject.amount;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (finderIsPlayer) {
applyDamage.setSkillPoints (amountTaken, player);
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage ("Skill point x " + amountTaken);
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: de44c4942ffcadc41b201f4a8b7a5230
timeCreated: 1568584281
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/skillPointPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,66 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class staminaPickup : pickupType
{
public override bool checkIfCanBePicked ()
{
if (storePickupOnInventory) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
amountTaken = mainPickupObject.getLastinventoryAmountPicked ();
} else {
GameObject character = gameObject;
if (finderIsPlayer) {
character = player;
}
if (finderIsCharacter) {
character = npc;
}
amountTaken = (int)applyDamage.getStaminaAmountToPick (character, mainPickupObject.amount);
if (amountTaken > 0) {
canPickCurrentObject = true;
}
mainPickupObject.amount -= amountTaken;
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (!storePickupOnInventory) {
if (finderIsPlayer) {
applyDamage.setStamina (amountTaken, player, false);
}
if (finderIsCharacter) {
applyDamage.setStamina (amountTaken, npc, false);
}
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
if (storePickupOnInventory) {
showPickupTakenMessage ("Stamina x " + amountTaken + " Stored");
} else {
showPickupTakenMessage ("Stamina x " + amountTaken);
}
}
mainPickupObject.playPickupSound ();
if (mainPickupObject.amount > 0 && !takeWithTrigger) {
mainPickupObject.checkEventOnRemainingAmount ();
return;
}
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 6a4f615b095167f4ab777b149064ba47
timeCreated: 1566497717
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/staminaPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,87 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class vehicleFuelPickup : pickupType
{
public override bool checkIfCanBePicked ()
{
if (finderIsPlayer) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
amountTaken = mainPickupObject.getLastinventoryAmountPicked ();
}
if (finderIsVehicle) {
//check the same if the player is driving and works in the same way for any type of pickup
amountTaken = (int)applyDamage.getFuelAmountToPick (vehicle, mainPickupObject.getAmountPicked ());
if (amountTaken > 0) {
canPickCurrentObject = true;
}
if (mainPickupObject.useAmountPerUnit) {
int amountUsed = Mathf.RoundToInt (amountTaken / mainPickupObject.amountPerUnit);
mainPickupObject.amount -= amountUsed;
if (showDebugPrint) {
print ("TOTAL " + amountUsed);
}
} else {
mainPickupObject.amount -= amountTaken;
}
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (showDebugPrint) {
print ("total amount taken " + amountTaken);
}
if (finderIsPlayer) {
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
string messageToUse = mainPickupObject.inventoryObjectManager.inventoryObjectInfo.Name;
if (amountTaken > 1) {
messageToUse += " x " + amountTaken;
} else {
messageToUse += " Stored";
}
showPickupTakenMessage (messageToUse);
}
mainPickupObject.playPickupSound ();
if (mainPickupObject.amount > 0 && !takeWithTrigger) {
mainPickupObject.checkEventOnRemainingAmount ();
return;
}
}
if (finderIsVehicle) {
if (showDebugPrint) {
print (amountTaken);
}
applyDamage.setFuel (amountTaken, vehicle);
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage ("Fuel x " + amountTaken);
}
mainPickupObject.playPickupSound ();
}
mainPickupObject.removePickupFromLevel ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d4a23efba695a5b43ba72b56eaecb2ea
timeCreated: 1565420846
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/vehicleFuelPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,57 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class weaponAttachmentPickup : pickupType
{
[Header ("Custom Pickup Settings")]
[Space]
public string weaponName;
public string attachmentName;
playerWeaponsManager weaponsManager;
public override bool checkIfCanBePicked ()
{
if (storePickupOnInventory) {
canPickCurrentObject = mainPickupObject.tryToPickUpObject ();
} else {
if (finderIsPlayer) {
weaponsManager = player.GetComponent<playerWeaponsManager> ();
if (weaponsManager.pickupAttachment (weaponName, attachmentName)) {
canPickCurrentObject = true;
}
if (!canPickCurrentObject) {
weaponsManager.showCantPickAttacmentMessage (attachmentName);
}
}
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
if (storePickupOnInventory) {
showPickupTakenMessage ("Attachment " + attachmentName + " Stored");
} else {
showPickupTakenMessage ("Attachment " + attachmentName + " Picked");
}
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
public void setAttachmentName (string newName)
{
attachmentName = newName;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 2fe40991c9651514c807c1089aaef4e7
timeCreated: 1565421125
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/weaponAttachmentPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,117 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class weaponPickup : pickupType
{
[Header ("Custom Pickup Settings")]
[Space]
public string weaponName;
playerWeaponsManager weaponsManager;
bool storePickedWeaponsOnInventory;
public override bool checkIfCanBePicked ()
{
if (finderIsPlayer) {
weaponsManager = player.GetComponent<playerWeaponsManager> ();
if (!weaponsManager.isAimingWeapons ()) {
bool canStoreAnyNumberSameWeapon = weaponsManager.canStoreAnyNumberSameWeaponState ();
bool weaponCanBePicked = weaponsManager.checkIfWeaponCanBePicked (weaponName);
if (canStoreAnyNumberSameWeapon) {
weaponCanBePicked = weaponsManager.checkIfWeaponExists (weaponName);
}
bool weaponsAreMoving = weaponsManager.weaponsAreMoving ();
if (weaponCanBePicked && !weaponsAreMoving && !weaponsManager.currentWeaponIsMoving ()) {
//check if the weapon can be stored in the inventory too
bool canBeStoredOnInventory = false;
bool hasInventoryObjectComponent = false;
if (weaponsManager.storePickedWeaponsOnInventory) {
if (mainPickupObject.inventoryObjectManager) {
hasInventoryObjectComponent = true;
canBeStoredOnInventory = mainPickupObject.tryToPickUpObject ();
storePickedWeaponsOnInventory = true;
}
}
if ((weaponsManager.storePickedWeaponsOnInventory && canBeStoredOnInventory) ||
!weaponsManager.storePickedWeaponsOnInventory || !hasInventoryObjectComponent) {
canPickCurrentObject = true;
}
}
}
}
if (finderIsCharacter) {
findObjectivesSystem currentfindObjectivesSystem = npc.GetComponent<findObjectivesSystem> ();
if (currentfindObjectivesSystem != null) {
if (currentfindObjectivesSystem.isSearchingWeapon ()) {
weaponsManager = npc.GetComponent<playerWeaponsManager> ();
if (!weaponsManager.isAimingWeapons ()) {
bool weaponCanBePicked = weaponsManager.checkIfWeaponCanBePicked (weaponName);
bool weaponsAreMoving = weaponsManager.weaponsAreMoving ();
if (weaponCanBePicked && !weaponsAreMoving) {
canPickCurrentObject = true;
}
}
}
}
}
return canPickCurrentObject;
}
public override void confirmTakePickup ()
{
bool weaponPickedCorrectly = false;
if (finderIsPlayer) {
if (storePickedWeaponsOnInventory) {
weaponPickedCorrectly = true;
} else {
weaponPickedCorrectly = weaponsManager.pickWeapon (weaponName);
}
}
if (finderIsCharacter) {
weaponPickedCorrectly = weaponsManager.pickWeapon (weaponName);
}
if (!weaponPickedCorrectly) {
return;
}
if (useCustomPickupMessage) {
showPickupTakenMessage (amountTaken);
} else {
showPickupTakenMessage (weaponName + " Picked");
}
mainPickupObject.playPickupSound ();
mainPickupObject.removePickupFromLevel ();
}
public void setWeaponName (string newWeaponName)
{
weaponName = newWeaponName;
}
public override void renameObject (string newName)
{
setWeaponName (newName);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 8ff014ababcdbec458d4042b69e61fdc
timeCreated: 1565419731
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/Pickups Behaviour/weaponPickup.cs
uploadId: 814740

View File

@@ -0,0 +1,546 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Events;
public class chestSystem : MonoBehaviour
{
public List<chestPickUpElementInfo> chestPickUpList = new List<chestPickUpElementInfo> ();
public List<pickUpElementInfo> managerPickUpList = new List<pickUpElementInfo> ();
public bool enablePickupsTriggerAtStart = true;
public bool setNewPickupTriggerRadius = true;
public float newPickupTriggerRadius = 3;
public bool setPickupsAsGetByTriggerTypeEnabled;
public bool randomContent;
public bool refillChestAfterDelay;
public float timeOpenedAfterEmpty = 1;
public float refilledTime;
public string openAnimationName;
public int numberOfObjects;
public int minAmount;
public int maxAmount;
public Transform placeWhereInstantiatePickUps;
public Vector3 placeOffset;
public Vector3 space;
public Vector2 amount;
public float pickUpScale;
public bool showGizmo;
public Color gizmoColor;
public Color gizmoLabelColor;
public float gizmoRadius;
public bool settings;
public bool isLocked;
public bool openWhenUnlocked;
public bool useElectronicDeviceManager;
public bool useEventOnOpenChest;
public UnityEvent eventOnOpenChest;
public bool useEventOnCloseChest;
public UnityEvent eventOnCloseChest;
public Animation chestAnim;
public Collider mainCollider;
public mapObjectInformation mapObjectInformationManager;
public string mainPickupManagerName = "Pickup Manager";
public bool useEventToSendSpawnedObjects;
public eventParameters.eventToCallWithGameObject eventToSendSpawnedObjects;
public bool setIgnoreExaminePickupObject;
List<GameObject> objectsList = new List<GameObject> ();
GameObject newObject;
GameObject objectsParent;
GameObject currentPlayer;
bool enter;
bool opened;
pickUpManager mainPickupManager;
pickUpObject currentPickUpObjectToCreate;
usingDevicesSystem usingDevicesManager;
GameObject objectToInstantiate;
Coroutine mainCoroutine;
void Start ()
{
objectsParent = transform.GetChild (0).gameObject;
if (chestAnim == null) {
chestAnim = GetComponent<Animation> ();
}
if (mainCollider == null) {
mainCollider = GetComponent<Collider> ();
}
if (isLocked) {
mainCollider.enabled = false;
}
if (mapObjectInformationManager == null) {
mapObjectInformationManager = GetComponent<mapObjectInformation> ();
}
}
public void stopUpdateCoroutine ()
{
if (mainCoroutine != null) {
StopCoroutine (mainCoroutine);
}
}
IEnumerator updateCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
updateState ();
yield return waitTime;
}
}
void updateState ()
{
//if the chest can be refilled once is has been opened, check if is empty, and then wait one second to close it again
if (opened && refillChestAfterDelay) {
if (objectsParent.transform.childCount == 0) {
StartCoroutine (waitTimeOpened ());
opened = false;
if (useEventOnCloseChest) {
eventOnCloseChest.Invoke ();
}
stopUpdateCoroutine ();
}
}
}
//instantiate the objects inside the chest, setting their configuration
void createObjects ()
{
numberOfObjects = 0;
for (int i = 0; i < chestPickUpList.Count; i++) {
chestPickUpElementInfo currentPickupElementInfo = chestPickUpList [i];
for (int k = 0; k < currentPickupElementInfo.chestPickUpTypeList.Count; k++) {
chestPickUpTypeElementInfo currentPickupInfo = currentPickupElementInfo.chestPickUpTypeList [k];
//of every object, create the amount set in the inspector, the ammo and the inventory objects will be added in future updates
int maxAmount = currentPickupInfo.amount;
int quantity = currentPickupInfo.quantity;
objectToInstantiate = managerPickUpList [currentPickupElementInfo.typeIndex].pickUpTypeList [currentPickupInfo.nameIndex].pickUpObject;
if (randomContent) {
maxAmount = (int)Random.Range (currentPickupInfo.amountLimits.x, currentPickupInfo.amountLimits.y);
}
for (int j = 0; j < maxAmount; j++) {
if (randomContent) {
quantity = (int)Random.Range (currentPickupInfo.quantityLimits.x, currentPickupInfo.quantityLimits.y);
}
newObject = (GameObject)Instantiate (objectToInstantiate, transform.position, Quaternion.identity);
currentPickUpObjectToCreate = newObject.GetComponent<pickUpObject> ();
if (currentPickUpObjectToCreate != null) {
currentPickUpObjectToCreate.amount = quantity;
if (setIgnoreExaminePickupObject) {
currentPickUpObjectToCreate.ignoreExamineObjectBeforeStoreEnabled = true;
}
if (setPickupsAsGetByTriggerTypeEnabled) {
currentPickUpObjectToCreate.setPickupOptionAsTrigger ();
}
}
newObject.transform.localScale = Vector3.one * pickUpScale;
addNewObject (newObject);
}
numberOfObjects += maxAmount;
}
}
//set a fix position inside the chest, according to the amount of objects instantiated
//the position of the first object
Vector3 originialPosition = placeWhereInstantiatePickUps.position
+ placeWhereInstantiatePickUps.right * placeOffset.x
+ placeWhereInstantiatePickUps.up * placeOffset.y
+ placeWhereInstantiatePickUps.forward * placeOffset.z;
Vector3 currentPosition = originialPosition;
int rows = 0;
int columns = 0;
//set the localposition of every object, so every object is actually inside the chest
for (int i = 0; i < numberOfObjects; i++) {
objectsList [i].transform.position = currentPosition;
currentPosition += placeWhereInstantiatePickUps.right * space.x;
if ((i + 1) % Mathf.Round (amount.y) == 0) {
currentPosition = originialPosition + placeWhereInstantiatePickUps.up * space.y * columns;
rows++;
currentPosition -= placeWhereInstantiatePickUps.forward * space.z * rows;
}
if (rows == Mathf.Round (amount.x)) {
columns++;
currentPosition = originialPosition + placeWhereInstantiatePickUps.up * space.y * columns;
rows = 0;
}
}
objectsList.Clear ();
}
public void addNewObject (GameObject newObject)
{
newObject.transform.SetParent (objectsParent.transform);
if (enablePickupsTriggerAtStart) {
if (setNewPickupTriggerRadius) {
SphereCollider currentPickupTrigger = newObject.GetComponentInChildren<SphereCollider> ();
if (currentPickupTrigger != null) {
currentPickupTrigger.radius = newPickupTriggerRadius;
}
}
} else {
SphereCollider currentPickupTrigger = newObject.GetComponentInChildren<SphereCollider> ();
if (currentPickupTrigger != null) {
currentPickupTrigger.enabled = false;
}
}
objectsList.Add (newObject);
if (useEventToSendSpawnedObjects) {
eventToSendSpawnedObjects.Invoke (newObject);
}
}
//when the player press the interaction button, this function is called
void activateDevice ()
{
if (useElectronicDeviceManager) {
return;
}
openOrCloseChest ();
}
public void openOrCloseChest ()
{
//check that the chest is not already opening, and play the open animation
if (!chestAnim.IsPlaying (openAnimationName)) {
if (!opened) {
chestAnim [openAnimationName].speed = 1;
chestAnim.Play (openAnimationName);
opened = true;
createObjects ();
if (useEventOnOpenChest) {
eventOnOpenChest.Invoke ();
}
mainCoroutine = StartCoroutine (updateCoroutine ());
if (!refillChestAfterDelay) {
disableChestInteraction ();
}
}
}
}
void disableChestInteraction ()
{
tag = "Untagged";
if (currentPlayer != null) {
usingDevicesManager = currentPlayer.GetComponent<usingDevicesSystem> ();
if (usingDevicesManager != null) {
usingDevicesManager.removeDeviceFromList (gameObject);
}
}
}
IEnumerator waitTimeOpened ()
{
WaitForSeconds delay = new WaitForSeconds (timeOpenedAfterEmpty);
yield return delay;
//when the second ends, play the open animation reversed, to close it, enabling the icon of open chest again
chestAnim [openAnimationName].speed = -1;
chestAnim [openAnimationName].time = chestAnim [openAnimationName].length;
chestAnim.Play (openAnimationName);
//wait the recharge time, so the chest can be reopened again
delay = new WaitForSeconds (chestAnim [openAnimationName].length + refilledTime);
yield return delay;
//once the waiting time is over, enable the interaction button of the player
tag = "device";
if (enter && usingDevicesManager != null) {
//enable the open icon in the hud
usingDevicesManager.checkTriggerInfo (mainCollider, true);
}
}
//check when the player enters or exits in the trigger of the chest
void OnTriggerEnter (Collider col)
{
if (!enter && col.CompareTag ("Player")) {
enter = true;
if (currentPlayer == null) {
currentPlayer = col.gameObject;
usingDevicesManager = currentPlayer.GetComponent<usingDevicesSystem> ();
}
}
}
void OnTriggerExit (Collider col)
{
if (col.CompareTag ("Player")) {
if (col.gameObject == currentPlayer) {
enter = false;
if (opened) {
disableChestInteraction ();
}
currentPlayer = null;
usingDevicesManager = null;
}
}
}
public void unlockChest ()
{
setLockedState (false);
}
public void setLockedState (bool state)
{
isLocked = state;
if (isLocked) {
if (mapObjectInformationManager != null) {
mapObjectInformationManager.addMapObject ("Locked Chest");
}
mainCollider.enabled = false;
} else {
if (openWhenUnlocked) {
if (currentPlayer != null) {
usingDevicesManager.checkTriggerInfo (mainCollider, true);
usingDevicesManager.inputActivateDevice ();
} else {
activateDevice ();
}
} else {
mainCollider.enabled = true;
}
if (mapObjectInformationManager != null) {
mapObjectInformationManager.addMapObject ("Chest");
}
}
}
public void getManagerPickUpList ()
{
if (mainPickupManager == null) {
GKC_Utils.instantiateMainManagerOnSceneWithType (mainPickupManagerName, typeof(pickUpManager));
mainPickupManager = FindObjectOfType<pickUpManager> ();
}
if (mainPickupManager != null) {
managerPickUpList.Clear ();
for (int i = 0; i < mainPickupManager.mainPickUpList.Count; i++) {
managerPickUpList.Add (mainPickupManager.mainPickUpList [i]);
}
updateComponent ();
}
}
public void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Chest Values", gameObject);
}
#if UNITY_EDITOR
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
void DrawGizmos ()
{
if (!Application.isPlaying && showGizmo && placeWhereInstantiatePickUps != null) {
Vector3 originialPosition = placeWhereInstantiatePickUps.position
+ placeWhereInstantiatePickUps.right * placeOffset.x
+ placeWhereInstantiatePickUps.up * placeOffset.y
+ placeWhereInstantiatePickUps.forward * placeOffset.z;
Vector3 currentPosition = originialPosition;
int rows = 0;
int columns = 0;
//set the localposition of every object, so every object is actually inside the chest
numberOfObjects = 0;
if (randomContent) {
minAmount = 0;
maxAmount = 0;
for (int i = 0; i < chestPickUpList.Count; i++) {
for (int j = 0; j < chestPickUpList [i].chestPickUpTypeList.Count; j++) {
minAmount += (int)chestPickUpList [i].chestPickUpTypeList [j].amountLimits.x;
maxAmount += (int)chestPickUpList [i].chestPickUpTypeList [j].amountLimits.y;
}
}
numberOfObjects = minAmount + maxAmount;
for (int i = 0; i < numberOfObjects; i++) {
if (i < minAmount) {
Gizmos.color = Color.blue;
Gizmos.DrawSphere (currentPosition, gizmoRadius);
Gizmos.color = gizmoLabelColor;
//Gizmos.DrawWireSphere (currentPosition, pickUpScale);
currentPosition += placeWhereInstantiatePickUps.right * space.x;
if (i != 0 && (i + 1) % Mathf.Round (amount.y) == 0) {
currentPosition = originialPosition + placeWhereInstantiatePickUps.up * space.y * columns;
rows++;
currentPosition -= placeWhereInstantiatePickUps.forward * space.z * rows;
}
if (rows == Mathf.Round (amount.x)) {
columns++;
currentPosition = originialPosition + placeWhereInstantiatePickUps.up * space.y * columns;
rows = 0;
}
}
if (i >= minAmount) {
Gizmos.color = Color.red;
Gizmos.DrawSphere (currentPosition, gizmoRadius);
Gizmos.color = gizmoLabelColor;
//Gizmos.DrawWireSphere (currentPosition, pickUpScale);
currentPosition += placeWhereInstantiatePickUps.right * space.x;
if (i != 0 && (i + 1) % Mathf.Round (amount.y) == 0) {
currentPosition = originialPosition + placeWhereInstantiatePickUps.up * space.y * columns;
rows++;
currentPosition -= placeWhereInstantiatePickUps.forward * space.z * rows;
}
if (rows == Mathf.Round (amount.x)) {
columns++;
currentPosition = originialPosition + placeWhereInstantiatePickUps.up * space.y * columns;
rows = 0;
}
}
}
} else {
for (int i = 0; i < chestPickUpList.Count; i++) {
for (int j = 0; j < chestPickUpList [i].chestPickUpTypeList.Count; j++) {
numberOfObjects += chestPickUpList [i].chestPickUpTypeList [j].amount;
}
}
for (int i = 0; i < numberOfObjects; i++) {
Gizmos.color = gizmoColor;
Gizmos.DrawSphere (currentPosition, gizmoRadius);
Gizmos.color = gizmoLabelColor;
//Gizmos.DrawWireSphere (currentPosition, pickUpScale);
currentPosition += placeWhereInstantiatePickUps.right * space.x;
if ((i + 1) % Mathf.Round (amount.y) == 0) {
currentPosition = originialPosition + placeWhereInstantiatePickUps.up * space.y * columns;
rows++;
currentPosition -= placeWhereInstantiatePickUps.forward * space.z * rows;
}
if (rows == Mathf.Round (amount.x)) {
columns++;
currentPosition = originialPosition + placeWhereInstantiatePickUps.up * space.y * columns;
rows = 0;
}
}
}
}
}
#endif
[System.Serializable]
public class chestPickUpElementInfo
{
public string pickUpType;
public int typeIndex;
public List<chestPickUpTypeElementInfo> chestPickUpTypeList = new List<chestPickUpTypeElementInfo> ();
}
[System.Serializable]
public class chestPickUpTypeElementInfo
{
public string name;
public int amount;
public int quantity;
public Vector2 amountLimits;
public Vector2 quantityLimits;
public int nameIndex;
}
}

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: d70ba8a60099f2b4d8996d8aa5d0c46e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/chestSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,224 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
public class crate : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public AudioClip brokenSound;
public AudioElement brokenAudioElement;
public float minVelocityToBreak;
public float breakForce = 10;
public ForceMode forceMode;
[Space]
[Header ("Fade or Remove Broken Pieces")]
[Space]
public bool fadeBrokenPieces = true;
public bool removeBrokenPiecesEnabled = true;
public float timeToRemove = 3;
public string defaultShaderName = "Legacy Shaders/Transparent/Diffuse";
public bool useCustomShader;
public Shader customShader;
[Space]
[Header ("Debug")]
[Space]
public bool canBeBroken = true;
[Space]
[Header ("Components")]
[Space]
public GameObject brokenCrate;
public Shader transparentShader;
public Rigidbody mainRigidbody;
bool broken;
List<Material> rendererParts = new List<Material> ();
int i, j;
int rendererPartsCount;
Material currentMaterial;
Coroutine mainCoroutine;
private void InitializeAudioElements ()
{
if (brokenSound != null) {
brokenAudioElement.clip = brokenSound;
}
}
void Start ()
{
InitializeAudioElements ();
getCrateRigidbody ();
}
IEnumerator updateCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
updateState ();
yield return waitTime;
}
}
void updateState ()
{
//if the crate has been broken, wait x seconds and then
if (broken) {
if (timeToRemove > 0) {
timeToRemove -= Time.deltaTime;
} else {
if (fadeBrokenPieces) {
rendererPartsCount = rendererParts.Count;
bool allPiecesFaded = true;
//change the alpha of the color in every renderer component in the fragments of the crate
for (i = 0; i < rendererPartsCount; i++) {
currentMaterial = rendererParts [i];
Color alpha = currentMaterial.color;
alpha.a -= Time.deltaTime / 5;
currentMaterial.color = alpha;
//once the alpha is 0, remove the gameObject
if (currentMaterial.color.a > 0) {
allPiecesFaded = false;
}
}
if (allPiecesFaded) {
Destroy (gameObject);
}
} else {
if (removeBrokenPiecesEnabled) {
Destroy (gameObject);
} else {
StopCoroutine (mainCoroutine);
}
}
}
}
}
//break this crate
public void breakCrate ()
{
//disable the main mesh of the crate and create the copy with the fragments
Vector3 originalRigidbodyVelocity = mainRigidbody.linearVelocity;
GetComponent<Collider> ().enabled = false;
GetComponent<MeshRenderer> ().enabled = false;
mainRigidbody.isKinematic = true;
//if the option break in pieces is enabled, create the broken crate
GameObject brokenCrateClone = (GameObject)Instantiate (brokenCrate, transform.position, transform.rotation);
brokenCrateClone.transform.localScale = transform.localScale;
brokenCrateClone.transform.SetParent (transform);
brokenAudioElement.audioSource = brokenCrateClone.GetComponent<AudioSource> ();
AudioPlayer.PlayOneShot (brokenAudioElement, gameObject);
if (fadeBrokenPieces) {
if (useCustomShader) {
transparentShader = customShader;
} else {
if (transparentShader == null) {
transparentShader = Shader.Find (defaultShaderName);
}
}
}
Component[] components = brokenCrateClone.GetComponentsInChildren (typeof(MeshRenderer));
int componentsLength = components.Length;
for (i = 0; i < componentsLength; i++) {
MeshRenderer child = components [i] as MeshRenderer;
//add a box collider to every piece of the crate
Rigidbody currentPartRigidbody = child.gameObject.AddComponent<Rigidbody> ();
child.gameObject.AddComponent<MeshCollider> ().convex = true;
if (fadeBrokenPieces) {
//change the shader of the fragments to fade them
int materialsLength = child.materials.Length;
for (j = 0; j < child.materials.Length; j++) {
Material temporalMaterial = child.materials [j];
temporalMaterial.shader = transparentShader;
rendererParts.Add (temporalMaterial);
}
}
if (originalRigidbodyVelocity.magnitude > minVelocityToBreak) {
currentPartRigidbody.AddForce (originalRigidbodyVelocity, forceMode);
} else {
currentPartRigidbody.AddForce (breakForce * (child.transform.position - transform.position), forceMode);
}
}
//kill the health component, to call the functions when the object health is 0
if (!applyDamage.checkIfDead (gameObject)) {
applyDamage.killCharacter (gameObject);
}
//search the player in case he had grabbed the crate when it exploded
broken = true;
mainCoroutine = StartCoroutine (updateCoroutine ());
//if the object is being carried by the player, make him drop it
GKC_Utils.checkDropObject (gameObject);
}
//if the player grabs this crate, disable its the option to break it
public void crateCanBeBrokenState (bool state)
{
canBeBroken = state;
}
//if the crate collides at enough speed, break it
void OnCollisionEnter (Collision col)
{
if (mainRigidbody != null && mainRigidbody.linearVelocity.magnitude > minVelocityToBreak && canBeBroken && !broken) {
breakCrate ();
}
}
public void getCrateRigidbody ()
{
if (mainRigidbody == null) {
mainRigidbody = GetComponent<Rigidbody> ();
}
}
public void setBarrelRigidbody (Rigidbody rigidbodyToUse)
{
mainRigidbody = rigidbodyToUse;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: e5a54ab3eb0671943a5ed187e5dd9260
timeCreated: 1468081978
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/crate.cs
uploadId: 814740

View File

@@ -0,0 +1,453 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class dropPickUpSystem : MonoBehaviour
{
public bool dropPickupsEnabled = true;
public bool useCustomTransformPositionToSpawn;
public Transform customTransformPositionToSpawn;
public List<dropPickUpElementInfo> dropPickUpList = new List<dropPickUpElementInfo> ();
public List<pickUpElementInfo> managerPickUpList = new List<pickUpElementInfo> ();
public float dropDelay;
public bool destroyAfterDropping;
public float pickUpScale;
public bool setPickupScale;
public bool randomContent;
public float maxRadiusToInstantiate = 1;
public Vector3 pickUpOffset;
public bool dropRandomObject;
public float extraForceToPickup = 5;
public float extraForceToPickupRadius = 5;
public ForceMode forceMode = ForceMode.Impulse;
public string mainPickupManagerName = "Pickup Manager";
public string mainInventoryManagerName = "Main Inventory Manager";
public bool showGizmo;
public bool useGeneralProbabilityDropObjects;
[Range (0, 100)] public float generalProbabilityDropObjects;
public bool useEventToSendSpawnedObjects;
public eventParameters.eventToCallWithGameObject eventToSendSpawnedObjects;
public bool ignoreCreateDropPickupObjectsActive;
GameObject newObject;
pickUpManager mainPickupManager;
GameObject objectToInstantiate;
inventoryListManager mainInventoryListManager;
bool mainInventoryManagerFound;
Vector3 targetPosition;
Quaternion targetRotation;
public void setIgnoreCreateDropPickupObjectsActiveState (bool state)
{
ignoreCreateDropPickupObjectsActive = state;
}
//instantiate the objects in the enemy position, setting their configuration
public void createDropPickUpObjects ()
{
if (!dropPickupsEnabled) {
return;
}
if (ignoreCreateDropPickupObjectsActive) {
return;
}
if (!gameObject.activeInHierarchy) {
return;
}
mainCoroutine = StartCoroutine (createDropPickUpObjectsCoroutine ());
}
Coroutine mainCoroutine;
void stopMainCoroutine ()
{
if (mainCoroutine != null) {
StopCoroutine (mainCoroutine);
}
}
IEnumerator createDropPickUpObjectsCoroutine ()
{
WaitForSeconds delay = new WaitForSeconds (dropDelay);
yield return delay;
if (useCustomTransformPositionToSpawn) {
targetPosition = customTransformPositionToSpawn.position;
targetRotation = customTransformPositionToSpawn.rotation;
} else {
targetPosition = transform.position;
targetRotation = transform.rotation;
}
targetPosition += getOffset ();
bool checkDropListResult = true;
if (dropRandomObject) {
int randomCategoryIndex = Random.Range (0, managerPickUpList.Count);
int nameIndex = Random.Range (0, managerPickUpList [randomCategoryIndex].pickUpTypeList.Count);
objectToInstantiate = managerPickUpList [randomCategoryIndex].pickUpTypeList [nameIndex].pickUpObject;
instantiateObject (1, 1, 0, 0);
stopMainCoroutine ();
checkDropListResult = false;
}
if (checkDropListResult) {
int dropPickUpListCount = dropPickUpList.Count;
int managerPickUpListCount = managerPickUpList.Count;
for (int i = 0; i < dropPickUpListCount; i++) {
dropPickUpElementInfo categoryList = dropPickUpList [i];
int typeIndex = categoryList.typeIndex;
int dropPickUpTypeListCount = categoryList.dropPickUpTypeList.Count;
bool dropRandomObjectFromList = categoryList.dropRandomObjectFromList;
for (int k = 0; k < dropPickUpTypeListCount; k++) {
dropPickUpTypeElementInfo pickupTypeList = categoryList.dropPickUpTypeList [k];
int nameIndex = pickupTypeList.nameIndex;
//of every object, create the amount set in the inspector, the ammo and the inventory objects will be added in future updates
int maxAmount = pickupTypeList.amount;
int quantity = pickupTypeList.quantity;
if (randomContent) {
maxAmount = (int)Random.Range (pickupTypeList.amountLimits.x, pickupTypeList.amountLimits.y);
}
if (typeIndex < managerPickUpListCount && nameIndex < managerPickUpList [typeIndex].pickUpTypeList.Count) {
if (pickupTypeList.dropCraftingBlueprintIngredients) {
checkMainInventoryManager ();
List<int> amountList = new List<int> ();
List<GameObject> objectList =
mainInventoryListManager.getDisassemblePiecesOfCraftingObjectByName (pickupTypeList.blueprintName, ref amountList);
if (objectList != null) {
int objectListCount = objectList.Count;
for (int l = 0; l < objectListCount; l++) {
bool canSpawnObjectResult = true;
if (useGeneralProbabilityDropObjects) {
if (!pickupTypeList.ignoreProbabilityDropObjects) {
float randomProbability = Random.Range (0, 100);
if (pickupTypeList.useCustomProbabilityDropObjects) {
if (randomProbability < pickupTypeList.customProbabilityDropObjects) {
canSpawnObjectResult = false;
}
} else {
if (randomProbability < generalProbabilityDropObjects) {
canSpawnObjectResult = false;
}
}
}
}
if (canSpawnObjectResult) {
objectToInstantiate = objectList [l];
instantiateObject (pickupTypeList.amountMultiplier, amountList [l], (int)pickupTypeList.quantityLimits.x, (int)pickupTypeList.quantityLimits.y);
}
}
}
} else {
bool canSpawnObjectResult = true;
if (useGeneralProbabilityDropObjects) {
if (!pickupTypeList.ignoreProbabilityDropObjects) {
float randomProbability = Random.Range (0, 100);
if (pickupTypeList.useCustomProbabilityDropObjects) {
if (randomProbability < pickupTypeList.customProbabilityDropObjects) {
canSpawnObjectResult = false;
}
} else {
if (randomProbability < generalProbabilityDropObjects) {
canSpawnObjectResult = false;
}
}
}
}
if (canSpawnObjectResult) {
if (dropRandomObjectFromList) {
int randomElementIndex = Random.Range (0, categoryList.dropPickUpTypeList.Count);
nameIndex = categoryList.dropPickUpTypeList [randomElementIndex].nameIndex;
maxAmount = 1;
quantity = 1;
}
if (pickupTypeList.dropRandomObject) {
nameIndex = Random.Range (0, managerPickUpList [typeIndex].pickUpTypeList.Count);
maxAmount = 1;
quantity = 1;
}
objectToInstantiate = managerPickUpList [typeIndex].pickUpTypeList [nameIndex].pickUpObject;
instantiateObject (maxAmount, quantity, (int)pickupTypeList.quantityLimits.x, (int)pickupTypeList.quantityLimits.y);
if (dropRandomObjectFromList) {
stopMainCoroutine ();
}
}
}
}
}
}
if (destroyAfterDropping) {
Destroy (gameObject);
}
}
}
void instantiateObject (int maxAmount, int quantity, int quantityLimitsX, int quantityLimitsY)
{
bool objectToInstantiateFound = false;
if (objectToInstantiate != null) {
for (int j = 0; j < maxAmount; j++) {
if (randomContent) {
quantity = (int)Random.Range (quantityLimitsX, quantityLimitsY);
}
newObject = (GameObject)Instantiate (objectToInstantiate, targetPosition, targetRotation);
newObject.name = objectToInstantiate.name;
pickUpObject currentPickUpObject = newObject.GetComponent<pickUpObject> ();
if (currentPickUpObject != null) {
currentPickUpObject.amount = quantity;
}
if (setPickupScale) {
newObject.transform.localScale = pickUpScale * Vector3.one;
}
//set a random position and rotation close to the enemy position
newObject.transform.position += maxRadiusToInstantiate * Random.insideUnitSphere;
//apply force to the objects
Rigidbody currentRigidbody = newObject.GetComponent<Rigidbody> ();
Vector3 forcePosition = transform.position;
if (useCustomTransformPositionToSpawn) {
forcePosition = customTransformPositionToSpawn.position;
}
if (currentRigidbody != null) {
currentRigidbody.AddExplosionForce (extraForceToPickup, forcePosition, extraForceToPickupRadius, 1, forceMode);
}
if (useEventToSendSpawnedObjects) {
eventToSendSpawnedObjects.Invoke (newObject);
}
}
objectToInstantiateFound = true;
}
if (!objectToInstantiateFound) {
print ("Warning, the pickups haven't been configured correctly in the pickup manager inspector");
}
}
public void setDropPickupsEnabledState (bool state)
{
dropPickupsEnabled = state;
}
public void getManagerPickUpList ()
{
if (mainPickupManager == null) {
GKC_Utils.instantiateMainManagerOnSceneWithType (mainPickupManagerName, typeof(pickUpManager));
mainPickupManager = FindObjectOfType<pickUpManager> ();
}
if (mainPickupManager != null) {
managerPickUpList.Clear ();
for (int i = 0; i < mainPickupManager.mainPickUpList.Count; i++) {
managerPickUpList.Add (mainPickupManager.mainPickUpList [i]);
}
updateComponent ();
print ("Updating Pickup Manager Info");
}
}
public void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update drop pickups system", gameObject);
}
public Vector3 getOffset ()
{
if (useCustomTransformPositionToSpawn) {
return (pickUpOffset.x * customTransformPositionToSpawn.right +
pickUpOffset.y * customTransformPositionToSpawn.up +
pickUpOffset.z * customTransformPositionToSpawn.forward);
} else {
return (pickUpOffset.x * transform.right + pickUpOffset.y * transform.up + pickUpOffset.z * transform.forward);
}
}
void checkMainInventoryManager ()
{
if (!mainInventoryManagerFound) {
getMainInventoryManager ();
}
}
public void getMainInventoryManager ()
{
if (mainInventoryListManager == null) {
mainInventoryManagerFound = mainInventoryListManager != null;
if (!mainInventoryManagerFound) {
mainInventoryListManager = inventoryListManager.Instance;
mainInventoryManagerFound = mainInventoryListManager != null;
}
if (!mainInventoryManagerFound) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (inventoryListManager.getMainManagerName (), typeof(inventoryListManager), true);
mainInventoryListManager = inventoryListManager.Instance;
mainInventoryManagerFound = mainInventoryListManager != null;
}
if (!mainInventoryManagerFound) {
mainInventoryListManager = FindObjectOfType<inventoryListManager> ();
mainInventoryManagerFound = mainInventoryListManager != null;
}
} else {
print ("Main Inventory Manager is already on the scene");
}
}
public void setDropPickupsEnabledStateFromEditor (bool state)
{
setDropPickupsEnabledState (state);
updateComponent ();
}
#if UNITY_EDITOR
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
void DrawGizmos ()
{
if (!Application.isPlaying && showGizmo) {
Gizmos.color = Color.green;
if (useCustomTransformPositionToSpawn) {
Gizmos.DrawWireSphere (customTransformPositionToSpawn.position + getOffset (), maxRadiusToInstantiate);
} else {
Gizmos.DrawWireSphere (transform.position + getOffset (), maxRadiusToInstantiate);
}
}
}
#endif
[System.Serializable]
public class dropPickUpElementInfo
{
public string pickUpType;
public int typeIndex;
public List<dropPickUpTypeElementInfo> dropPickUpTypeList = new List<dropPickUpTypeElementInfo> ();
public bool dropRandomObjectFromList;
}
[System.Serializable]
public class dropPickUpTypeElementInfo
{
public string name;
public int amount;
public int quantity;
public Vector2 amountLimits;
public Vector2 quantityLimits;
public int nameIndex;
public bool dropRandomObject;
public bool dropCraftingBlueprintIngredients;
public string blueprintName;
public int amountMultiplier = 1;
public bool useCustomProbabilityDropObjects;
[Range (0, 100)]public float customProbabilityDropObjects;
public bool ignoreProbabilityDropObjects;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 588ca58a306e45b4fb859657abb01de1
timeCreated: 1483990065
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/dropPickUpSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,401 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GameKitController.Audio;
public class explosiveBarrel : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool breakInPieces;
public bool canDamageToExplosiveBarrelOwner = true;
public float explosionForceToBarrelPieces = 5;
public float explosionRadiusToBarrelPieces = 30;
public ForceMode forceModeToBarrelPieces = ForceMode.Impulse;
[Space]
[Header ("Explosion/Damage Settings")]
[Space]
public float explosionDamage;
public bool ignoreShield;
public float damageRadius;
public float minVelocityToExplode;
public float explosionDelay;
public float explosionForce = 300;
public int damageTypeID = -1;
public bool damageCanBeBlocked = true;
[Space]
[Header ("Other Explosion Settings")]
[Space]
public bool pushCharacters = true;
public bool killObjectsInRadius;
public ForceMode explosionForceMode;
public bool userLayerMask;
public LayerMask layer;
public bool applyExplosionForceToVehicles = true;
public float explosionForceToVehiclesMultiplier = 0.2f;
public bool searchClosestWeakSpot;
[Space]
[Header ("Damage Over Time Settings")]
[Space]
public bool damageTargetOverTime;
public float damageOverTimeDelay;
public float damageOverTimeDuration;
public float damageOverTimeAmount;
public float damageOverTimeRate;
public bool damageOverTimeToDeath;
public bool removeDamageOverTimeState;
[Space]
[Header ("Audio Settings")]
[Space]
public AudioClip explosionSound;
public AudioElement explosionAudioElement;
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEventOnObjectsFound;
public string remoteEventName;
[Space]
[Header ("Fade or Remove Broken Pieces")]
[Space]
public bool fadeBrokenPieces = true;
public bool removeBrokenPiecesEnabled = true;
public float timeToRemove = 3;
public string defaultShaderName = "Legacy Shaders/Transparent/Diffuse";
public bool useCustomShader;
public Shader customShader;
public string colorPropertyName = "_Color";
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool canExplode = true;
[Space]
[Header ("Gizmo Settings")]
[Space]
public bool showGizmo;
[Space]
[Header ("Components")]
[Space]
public GameObject brokenBarrel;
public GameObject explosionParticles;
public Shader transparentShader;
public Rigidbody mainRigidbody;
bool exploded;
List<Material> rendererParts = new List<Material> ();
int i, j;
GameObject barrelOwner;
bool isDamaged;
Vector3 damageDirection;
Vector3 damagePosition;
int rendererPartsCount;
Material currentMaterial;
Coroutine mainCoroutine;
int colorID;
private void InitializeAudioElements ()
{
if (explosionSound != null) {
explosionAudioElement.clip = explosionSound;
}
}
void Start ()
{
InitializeAudioElements ();
getBarrelRigidbody ();
}
IEnumerator updateCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
updateState ();
yield return waitTime;
}
}
void updateState ()
{
//if the barrel has exploded, wait a seconds and then
if (exploded) {
if (timeToRemove > 0) {
timeToRemove -= Time.deltaTime;
} else {
if (fadeBrokenPieces) {
//change the alpha of the color in every renderer component in the fragments of the barrel
rendererPartsCount = rendererParts.Count;
bool allPiecesFaded = true;
for (i = 0; i < rendererPartsCount; i++) {
currentMaterial = rendererParts [i];
if (currentMaterial.HasProperty (colorID)) {
Color alpha = currentMaterial.color;
alpha.a -= Time.deltaTime / 5;
currentMaterial.color = alpha;
//once the alpha is 0, remove the gameObject
if (currentMaterial.color.a > 0) {
allPiecesFaded = false;
}
}
}
if (allPiecesFaded) {
Destroy (gameObject);
}
} else {
if (removeBrokenPiecesEnabled) {
Destroy (gameObject);
} else {
StopCoroutine (mainCoroutine);
}
}
}
}
}
//explode this barrel
public void explodeBarrel ()
{
if (exploded) {
return;
}
//if the barrel has not been throwing by the player, the barrel owner is the barrel itself
if (barrelOwner == null) {
barrelOwner = gameObject;
}
//disable the main mesh of the barrel and create the copy with the fragments of the barrel
GetComponent<Collider> ().enabled = false;
GetComponent<MeshRenderer> ().enabled = false;
if (mainRigidbody != null) {
mainRigidbody.isKinematic = true;
}
if (fadeBrokenPieces) {
if (useCustomShader) {
transparentShader = customShader;
} else {
if (transparentShader == null) {
transparentShader = Shader.Find (defaultShaderName);
}
}
}
Vector3 currentPosition = transform.position;
//check all the colliders inside the damage radius
applyDamage.setExplosion (currentPosition, damageRadius, userLayerMask, layer, barrelOwner, canDamageToExplosiveBarrelOwner,
gameObject, killObjectsInRadius, true, false, explosionDamage, pushCharacters, applyExplosionForceToVehicles,
explosionForceToVehiclesMultiplier, explosionForce, explosionForceMode, true, barrelOwner.transform, ignoreShield,
useRemoteEventOnObjectsFound, remoteEventName, damageTypeID,
damageTargetOverTime, damageOverTimeDelay, damageOverTimeDuration, damageOverTimeAmount,
damageOverTimeRate, damageOverTimeToDeath, removeDamageOverTimeState, damageCanBeBlocked, searchClosestWeakSpot);
//create the explosion particles
GameObject explosionParticlesClone = (GameObject)Instantiate (explosionParticles, transform.position, transform.rotation);
explosionParticlesClone.transform.SetParent (transform);
//if the option break in pieces is enabled, create the barrel broken
if (breakInPieces) {
if (fadeBrokenPieces) {
colorID = Shader.PropertyToID (colorPropertyName);
}
GameObject brokenBarrelClone = (GameObject)Instantiate (brokenBarrel, transform.position, transform.rotation);
brokenBarrelClone.transform.localScale = transform.localScale;
brokenBarrelClone.transform.SetParent (transform);
explosionAudioElement.audioSource = brokenBarrelClone.GetComponent<AudioSource> ();
AudioPlayer.PlayOneShot (explosionAudioElement, gameObject);
Component [] components = brokenBarrelClone.GetComponentsInChildren (typeof (MeshRenderer));
int componentsLength = components.Length;
for (i = 0; i < componentsLength; i++) {
MeshRenderer child = components [i] as MeshRenderer;
//add force to every piece of the barrel and add a box collider
Rigidbody currentPartRigidbody = child.gameObject.AddComponent<Rigidbody> ();
child.gameObject.AddComponent<BoxCollider> ();
currentPartRigidbody.AddExplosionForce (explosionForceToBarrelPieces, child.transform.position, explosionRadiusToBarrelPieces, 1, forceModeToBarrelPieces);
if (fadeBrokenPieces) {
//change the shader of the fragments to fade them
int materialsLength = child.materials.Length;
for (j = 0; j < materialsLength; j++) {
Material temporalMaterial = child.materials [j];
temporalMaterial.shader = transparentShader;
rendererParts.Add (temporalMaterial);
}
}
}
}
//kill the health component, to call the functions when the object health is 0
if (!applyDamage.checkIfDead (gameObject)) {
applyDamage.killCharacter (gameObject);
}
//search the player in case he had grabbed the barrel when it exploded
exploded = true;
mainCoroutine = StartCoroutine (updateCoroutine ());
//if the object is being carried by the player, make him drop it
GKC_Utils.checkDropObject (gameObject);
}
//if the player grabs this barrel, disable its explosion by collisions
public void canExplodeState (bool state)
{
canExplode = state;
}
public void setExplosiveBarrelOwner (GameObject newBarrelOwner)
{
barrelOwner = newBarrelOwner;
}
//if the barrel collides at enough speed, explode it
void OnCollisionEnter (Collision col)
{
if (canExplode && !exploded) {
if (showDebugPrint) {
print ("Collision velocity " + col.relativeVelocity.magnitude);
}
if (Mathf.Abs (col.relativeVelocity.magnitude) > minVelocityToExplode) {
explodeBarrel ();
return;
}
if (mainRigidbody != null) {
if (Mathf.Abs (mainRigidbody.linearVelocity.magnitude) > minVelocityToExplode) {
explodeBarrel ();
}
}
}
}
public void getBarrelRigidbody ()
{
if (mainRigidbody == null) {
mainRigidbody = GetComponent<Rigidbody> ();
}
}
public void setBarrelRigidbody (Rigidbody rigidbodyToUse)
{
mainRigidbody = rigidbodyToUse;
}
public void waitToExplode ()
{
if (explosionDelay > 0) {
StartCoroutine (waitToExplodeCorutine ());
} else {
explodeBarrel ();
}
}
//delay to explode the barrel
IEnumerator waitToExplodeCorutine ()
{
WaitForSeconds delay = new WaitForSeconds (explosionDelay);
yield return delay;
explodeBarrel ();
}
//set the explosion values from other component
public void setExplosionValues (float force, float radius)
{
explosionForce = force;
damageRadius = radius;
}
#if UNITY_EDITOR
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
void DrawGizmos ()
{
if (showGizmo) {
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere (transform.position, damageRadius);
}
}
#endif
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: a58029f21749f274b8a8c94ae0b2bae7
timeCreated: 1463506192
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/explosiveBarrel.cs
uploadId: 814740

View File

@@ -0,0 +1,29 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[System.Serializable]
public class pickUpElementInfo
{
public string pickUpType;
public List<pickUpTypeElementInfo> pickUpTypeList = new List<pickUpTypeElementInfo> ();
public bool useGeneralIcon;
public Texture generalIcon;
public bool useCustomIconPrefab;
public GameObject customIconPrefab;
[System.Serializable]
public class pickUpTypeElementInfo
{
public string Name;
public GameObject pickUpObject;
public Texture pickupIcon;
public bool useCustomPickupIcon;
public bool useCustomIconPrefab;
public GameObject customIconPrefab;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: f532501880f8f634cae080f2564d5438
timeCreated: 1483988396
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/pickUpElementInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,9 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
public class pickUpIcon : MonoBehaviour
{
public pickUpIconInfo pickUpElementInfo;
}

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: bccb97ec92e9b334e9ea1032f8898d92
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/pickUpIcon.cs
uploadId: 814740

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[System.Serializable]
public class pickUpIconInfo
{
public int ID;
public string name;
public GameObject iconObject;
public GameObject texture;
public GameObject target;
public Transform targetTransform;
public bool iconActive;
public RawImage pickupIconImage;
public bool paused;
public RectTransform iconRectTransform;
public CanvasGroup mainCanvasGroup;
public GameObject iconPrefab;
public Texture iconTexture;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 59ea485bb9c18234da4fe9b28c15ab14
timeCreated: 1540594511
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/pickUpIconInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,259 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Events;
public class pickUpManager : MonoBehaviour
{
public bool showIconsActive = true;
public List<pickUpElementInfo> mainPickUpList = new List<pickUpElementInfo> ();
public List<pickUpIconInfo> pickUpIconList = new List<pickUpIconInfo> ();
public List<playerPickupIconManager> playerPickupIconManagerList = new List<playerPickupIconManager> ();
int currentID = 0;
public const string mainManagerName = "Pickup Manager";
public static string getMainManagerName ()
{
return mainManagerName;
}
private static pickUpManager _pickUpManagerInstance;
public static pickUpManager Instance { get { return _pickUpManagerInstance; } }
bool instanceInitialized;
public void getComponentInstance ()
{
if (instanceInitialized) {
return;
}
if (_pickUpManagerInstance != null && _pickUpManagerInstance != this) {
Destroy (this.gameObject);
return;
}
_pickUpManagerInstance = this;
instanceInitialized = true;
}
void Awake ()
{
getComponentInstance ();
}
public void addNewPlayer (playerPickupIconManager newPlayer)
{
if (!showIconsActive) {
return;
}
playerPickupIconManagerList.Add (newPlayer);
int pickUpIconListCount = pickUpIconList.Count;
if (pickUpIconListCount > 0) {
for (int i = 0; i < pickUpIconListCount; i++) {
newPlayer.setPickUpIcon (
pickUpIconList [i].target,
pickUpIconList [i].iconTexture,
pickUpIconList [i].ID,
pickUpIconList [i].iconPrefab);
}
}
}
//set what type of pick up is this object, and the object that the icon has to follow
public void setPickUpIcon (GameObject target, string pickupIconGeneralName, string pickupIconName)
{
if (!showIconsActive) {
return;
}
int targetIndex = pickUpIconList.FindIndex (s => s.target == target);
if (targetIndex > -1) {
//print (target.name + " alredy added, cancelling");
return;
}
pickUpIconInfo newIcon = new pickUpIconInfo ();
newIcon.name = target.name;
newIcon.ID = currentID;
newIcon.target = target;
newIcon.targetTransform = target.transform;
Texture iconTexture = null;
GameObject iconPrefab = null;
int pickupListIndex = mainPickUpList.FindIndex (s => s.pickUpType.ToLower () == pickupIconGeneralName.ToLower ());
if (pickupListIndex > -1) {
pickUpElementInfo currentPickupElementInfo = mainPickUpList [pickupListIndex];
bool useGeneralIcon = currentPickupElementInfo.useGeneralIcon;
int customIndexTexture = -1;
if (!pickupIconName.Equals ("")) {
int pickupTypeIndex = currentPickupElementInfo.pickUpTypeList.FindIndex (s => s.Name.ToLower () == pickupIconName.ToLower ());
if (pickupTypeIndex > -1) {
customIndexTexture = pickupTypeIndex;
useGeneralIcon = false;
}
}
if (useGeneralIcon) {
iconTexture = currentPickupElementInfo.generalIcon;
} else {
if (customIndexTexture > -1) {
iconTexture = currentPickupElementInfo.pickUpTypeList [customIndexTexture].pickupIcon;
}
}
bool useCustomIconPrefab = currentPickupElementInfo.useCustomIconPrefab;
if (customIndexTexture > -1) {
if (currentPickupElementInfo.pickUpTypeList [customIndexTexture].useCustomIconPrefab) {
iconPrefab = currentPickupElementInfo.pickUpTypeList [customIndexTexture].customIconPrefab;
useCustomIconPrefab = false;
}
}
if (useCustomIconPrefab) {
iconPrefab = currentPickupElementInfo.customIconPrefab;
}
}
newIcon.iconTexture = iconTexture;
newIcon.iconPrefab = iconPrefab;
pickUpIconList.Add (newIcon);
for (int i = 0; i < playerPickupIconManagerList.Count; i++) {
playerPickupIconManagerList [i].setPickUpIcon (target, iconTexture, currentID, iconPrefab);
}
currentID++;
}
//destroy the icon
public void removeTarget (GameObject target)
{
if (!showIconsActive) {
return;
}
for (int i = 0; i < pickUpIconList.Count; i++) {
if (pickUpIconList [i].target != null) {
if (pickUpIconList [i].target == target) {
removeAtTarget (pickUpIconList [i].ID, i);
return;
}
}
}
}
public void removeAtTarget (int objectID, int objectIndex)
{
if (!showIconsActive) {
return;
}
for (int i = 0; i < playerPickupIconManagerList.Count; i++) {
playerPickupIconManagerList [i].removeAtTargetByID (objectID);
}
pickUpIconList.RemoveAt (objectIndex);
}
public void removeElementFromPickupListCalledByPlayer (int objectID)
{
if (!showIconsActive) {
return;
}
for (int i = 0; i < pickUpIconList.Count; i++) {
if (pickUpIconList [i].ID == objectID) {
pickUpIconList.RemoveAt (i);
return;
}
}
}
public void setPauseState (bool state, GameObject iconObject)
{
if (!showIconsActive) {
return;
}
for (int i = 0; i < pickUpIconList.Count; i++) {
if (pickUpIconList [i].target == iconObject) {
pickUpIconList [i].paused = state;
for (int j = 0; j < playerPickupIconManagerList.Count; j++) {
playerPickupIconManagerList [j].setPauseState (state, i);
}
}
}
}
public void setNamesConfigured (int currentIndex)
{
pickUpElementInfo currentpickUpElementInfo = mainPickUpList [currentIndex];
for (int i = 0; i < currentpickUpElementInfo.pickUpTypeList.Count; i++) {
if (currentpickUpElementInfo.pickUpTypeList [i].pickUpObject != null) {
currentpickUpElementInfo.pickUpTypeList [i].Name = currentpickUpElementInfo.pickUpTypeList [i].pickUpObject.name;
}
}
}
public void addNewPickup ()
{
pickUpElementInfo newPickupElementInfo = new pickUpElementInfo ();
newPickupElementInfo.pickUpType = "New Pickup Type";
mainPickUpList.Add (newPickupElementInfo);
udpateComponent ();
}
public void addNewPickupToList (int index)
{
pickUpElementInfo.pickUpTypeElementInfo newPickupTypeElementInfo = new pickUpElementInfo.pickUpTypeElementInfo ();
newPickupTypeElementInfo.Name = "New Pickup";
mainPickUpList [index].pickUpTypeList.Add (newPickupTypeElementInfo);
udpateComponent ();
}
public void udpateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Pickup Manager", gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 7ae1246834b448749b013599d6528d0e
timeCreated: 1483988079
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/pickUpManager.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: b2931b7a580d5044082b16e57d353cd2
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/pickUpObject.cs
uploadId: 814740

View File

@@ -0,0 +1,298 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
public class pickUpsScreenInfo : MonoBehaviour
{
public bool pickUpScreenInfoEnabled;
public float durationTimerPerText;
public float verticalDistance;
public float horizontalOffset;
public bool adjustTextSizeDelta = true;
public float textSizeDeltaOffsetMultiplier = -1;
public bool useIconsEnabled;
public float iconHeight;
public float verticalIconOffset;
public float horizontalIconOffset;
public bool usedByAI;
public GameObject originalIcon;
public Transform pickupsInfoParent;
public GameObject originalText;
public RectTransform originalTextRectTransform;
public playerController mainPlayerController;
public string textToAddFromEditor;
List<pickupScreenInfo> textList = new List<pickupScreenInfo> ();
float lastTexTime;
float heightToRemove;
bool elementsStored;
//display in the screen the type of pick ups that the objects grabs, setting their names and amount grabbed, setting the text position and the time that
//is visible
void FixedUpdate ()
{
if (!pickUpScreenInfoEnabled) {
return;
}
if (elementsStored) {
//if there are text elements, then check the timer, and delete them
if (textList.Count > 0) {
if (Time.time > lastTexTime + durationTimerPerText) {
heightToRemove = textList [0].infoHeight;
if (textList.Count > 1) {
if (textList [1].hasIcon && !textList [0].hasIcon) {
heightToRemove = verticalIconOffset;
}
}
Destroy (textList [0].pickupText.gameObject);
if (textList [0].hasIcon) {
Destroy (textList [0].pickupIcon.gameObject);
}
textList.RemoveAt (0);
if (textList.Count == 0) {
elementsStored = false;
}
setPositions ();
lastTexTime = Time.time;
}
}
}
}
//the player has grabbed a pick up, so display the info in the screen, instantiating a new text component
public void recieveInfo (string info)
{
if (usedByAI || mainPlayerController.isPlayerMenuActive ()) {
return;
}
if (pickUpScreenInfoEnabled) {
GameObject newText = (GameObject)Instantiate (originalText, originalText.transform.position, Quaternion.identity);
RectTransform newTextRectTransform = newText.GetComponent<RectTransform> ();
if (!newTextRectTransform.gameObject.activeSelf) {
newTextRectTransform.gameObject.SetActive (true);
}
newTextRectTransform.SetParent (pickupsInfoParent);
newTextRectTransform.localScale = Vector3.one;
if (adjustTextSizeDelta) {
if (info.Length > 12) {
float extraPositionX = info.Length - 12;
newTextRectTransform.sizeDelta = new Vector2 (newTextRectTransform.sizeDelta.x + extraPositionX * 20, newTextRectTransform.sizeDelta.y);
}
}
newTextRectTransform.anchoredPosition += Vector2.right * horizontalOffset;
if (adjustTextSizeDelta) {
newTextRectTransform.anchoredPosition += textSizeDeltaOffsetMultiplier * Vector2.right * (newTextRectTransform.sizeDelta.x / 2);
}
float infoHeight = 0;
float verticalOffset = 0;
if (textList.Count > 0) {
verticalOffset = textList [textList.Count - 1].verticalOffset;
if (textList [textList.Count - 1].hasIcon) {
verticalOffset += verticalIconOffset;
} else {
verticalOffset += verticalDistance;
}
}
infoHeight = verticalDistance;
Vector2 extraPosition = Vector2.up * (verticalOffset);
newTextRectTransform.anchoredPosition += extraPosition;
newText.GetComponent<Text> ().text = info;
pickupScreenInfo newPickupScreenInfo = new pickupScreenInfo ();
newPickupScreenInfo.pickupText = newTextRectTransform;
newPickupScreenInfo.verticalOffset = verticalOffset;
newPickupScreenInfo.infoHeight = infoHeight;
textList.Add (newPickupScreenInfo);
elementsStored = true;
lastTexTime = Time.time;
}
}
public void recieveInfo (string info, Texture icon)
{
if (usedByAI || mainPlayerController.isPlayerMenuActive ()) {
return;
}
if (pickUpScreenInfoEnabled) {
if (!useIconsEnabled) {
recieveInfo (info);
return;
}
GameObject newText = (GameObject)Instantiate (originalText, originalText.transform.position, Quaternion.identity);
RectTransform newTextRectTransform = newText.GetComponent<RectTransform> ();
if (!newTextRectTransform.gameObject.activeSelf) {
newTextRectTransform.gameObject.SetActive (true);
}
newTextRectTransform.SetParent (pickupsInfoParent);
newTextRectTransform.localScale = Vector3.one;
if (adjustTextSizeDelta) {
if (info.Length > 12) {
float extraPositionX = info.Length - 12;
newTextRectTransform.sizeDelta = new Vector2 (newTextRectTransform.sizeDelta.x + extraPositionX * 20, newTextRectTransform.sizeDelta.y);
}
}
newTextRectTransform.anchoredPosition +=
Vector2.right * horizontalOffset +
(-Vector2.right * (iconHeight + horizontalIconOffset));
if (adjustTextSizeDelta) {
newTextRectTransform.anchoredPosition += textSizeDeltaOffsetMultiplier * Vector2.right * (newTextRectTransform.sizeDelta.x / 2);
}
float infoHeight = 0;
float verticalOffset = 0;
if (textList.Count > 0) {
verticalOffset = textList [textList.Count - 1].verticalOffset;
infoHeight = verticalIconOffset;
verticalOffset += infoHeight;
}
infoHeight = verticalIconOffset;
Vector2 extraPosition = Vector2.up * (verticalOffset);
newTextRectTransform.anchoredPosition += extraPosition;
newText.GetComponent<Text> ().text = info;
GameObject newIcon = (GameObject)Instantiate (originalIcon, originalIcon.transform.position, Quaternion.identity);
RectTransform newIconRectTransform = newIcon.GetComponent<RectTransform> ();
if (!newIconRectTransform.gameObject.activeSelf) {
newIconRectTransform.gameObject.SetActive (true);
}
newIconRectTransform.SetParent (pickupsInfoParent);
newIconRectTransform.localScale = Vector3.one;
newIconRectTransform.anchoredPosition += new Vector2 (horizontalIconOffset, 0);
newIconRectTransform.anchoredPosition += extraPosition;
if (icon != null) {
newIcon.GetComponent<RawImage> ().texture = icon;
}
pickupScreenInfo newPickupScreenInfo = new pickupScreenInfo ();
newPickupScreenInfo.pickupText = newTextRectTransform;
newPickupScreenInfo.pickupIcon = newIconRectTransform;
newPickupScreenInfo.hasIcon = true;
newPickupScreenInfo.verticalOffset = verticalOffset;
newPickupScreenInfo.infoHeight = infoHeight;
textList.Add (newPickupScreenInfo);
elementsStored = true;
lastTexTime = Time.time;
}
}
void setPositions ()
{
for (int i = 0; i < textList.Count; i++) {
// print (heightToRemove + " " + textList [i].verticalOffset + " " + textList [i].infoHeight);
textList [i].verticalOffset -= heightToRemove;
Vector2 extraPosition = heightToRemove * Vector2.up;
if (textList [i].hasIcon) {
textList [i].pickupIcon.anchoredPosition -= extraPosition;
}
textList [i].pickupText.anchoredPosition -= extraPosition;
}
}
public void setPickUpScreenInfoEnabled (bool state)
{
pickUpScreenInfoEnabled = state;
}
public void setPickUpScreenInfoEnabledFromEditor (bool state)
{
pickUpScreenInfoEnabled = state;
GKC_Utils.updateComponent (this);
}
public void setUsedByAIState (bool state)
{
usedByAI = state;
}
public void addTextFromEditor ()
{
recieveInfo (textToAddFromEditor);
}
public void addTextAndIconFromEditor ()
{
recieveInfo (textToAddFromEditor, null);
}
[System.Serializable]
public class pickupScreenInfo
{
public RectTransform pickupText;
public bool hasIcon;
public RectTransform pickupIcon;
public float verticalOffset;
public float infoHeight;
}
}

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 8c76a4e8db3d19f4d8fd3ba501f15d95
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/pickUpsScreenInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,517 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
public class playerPickupIconManager : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool showIconsActive = true;
public bool showIconsPaused;
public LayerMask layer;
public LayerMask layerForFirstPerson;
public LayerMask layerForFBA;
public checkIconType checkIcontype;
public float maxDistanceIconEnabled;
[Space]
[Header ("Other Settings")]
[Space]
public string mainManagerName = "Pickup Manager";
public string mainPanelName = "Pickup Objects Icons";
public bool useCanvasGroupOnIcons;
[Space]
[Header ("Debug")]
[Space]
public List<pickUpIconInfo> pickUpIconList = new List<pickUpIconInfo> ();
[Space]
[Header ("Components")]
[Space]
public GameObject pickUpIconObject;
public Transform pickupObjectIconParent;
public Camera mainCamera;
public pickUpManager mainPickupManager;
public playerController playerControllerManager;
public playerCamera mainPlayerCamera;
Transform mainCameraTransform;
Vector3 targetPosition;
Vector3 cameraPosition;
Vector3 screenPoint;
Vector3 direction;
float distance;
LayerMask currentLayer;
//how to check if the icon is visible,
// -using a raycast from the object to the camera
// -using distance from the object to the player position
// -visible always that the player is looking at the object position
public enum checkIconType
{
raycast,
distance,
always_visible,
nothing
}
Vector2 mainCanvasSizeDelta;
Vector2 halfMainCanvasSizeDelta;
Vector2 iconPosition2d;
bool usingScreenSpaceCamera;
bool targetOnScreen;
float screenWidth;
float screenHeight;
pickUpIconInfo currentPickUpIconInfo;
int pickUpIconListCount;
bool screenResolutionAssigned;
bool mainPanelParentLocated;
bool mainPanelParentChecked;
bool layerForThirdPersonAssigned;
bool layerForFirstPersonAssigned;
bool layerForFBAAssigned;
void Awake ()
{
if (showIconsActive) {
initializeElements ();
}
}
void initializeElements ()
{
bool pickupManagerLocated = (mainPickupManager != null);
if (!pickupManagerLocated) {
mainPickupManager = pickUpManager.Instance;
pickupManagerLocated = mainPickupManager != null;
}
if (!pickupManagerLocated) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (pickUpManager.getMainManagerName (), typeof(pickUpManager), true);
mainPickupManager = pickUpManager.Instance;
pickupManagerLocated = (mainPickupManager != null);
}
if (!pickupManagerLocated) {
mainPickupManager = FindObjectOfType<pickUpManager> ();
pickupManagerLocated = mainPickupManager != null;
}
if (pickupManagerLocated) {
mainPickupManager.addNewPlayer (this);
} else {
showIconsActive = false;
}
}
void Start ()
{
mainCanvasSizeDelta = mainPlayerCamera.getMainCanvasSizeDelta ();
halfMainCanvasSizeDelta = mainCanvasSizeDelta * 0.5f;
usingScreenSpaceCamera = mainPlayerCamera.isUsingScreenSpaceCamera ();
if (mainCamera == null) {
mainCamera = mainPlayerCamera.getMainCamera ();
}
mainCameraTransform = mainCamera.transform;
}
void FixedUpdate ()
{
if (!showIconsActive || showIconsPaused) {
return;
}
pickUpIconListCount = pickUpIconList.Count;
if (pickUpIconListCount == 0) {
return;
}
if (playerControllerManager.isPlayerOnFirstPerson ()) {
if (!layerForThirdPersonAssigned) {
currentLayer = layerForFirstPerson;
layerForThirdPersonAssigned = true;
layerForFirstPersonAssigned = false;
layerForFBAAssigned = false;
}
} else {
if (playerControllerManager.isFullBodyAwarenessActive ()) {
if (!layerForFBAAssigned) {
currentLayer = layerForFBA;
layerForThirdPersonAssigned = false;
layerForFirstPersonAssigned = false;
layerForFBAAssigned = true;
}
} else {
if (!layerForFirstPersonAssigned) {
currentLayer = layer;
layerForThirdPersonAssigned = false;
layerForFirstPersonAssigned = true;
layerForFBAAssigned = false;
}
}
}
if (!usingScreenSpaceCamera) {
if (!screenResolutionAssigned) {
updateScreenValues ();
screenResolutionAssigned = true;
}
}
cameraPosition = mainCameraTransform.position;
for (int i = 0; i < pickUpIconListCount; i++) {
currentPickUpIconInfo = pickUpIconList [i];
if (currentPickUpIconInfo.paused) {
if (currentPickUpIconInfo.iconActive) {
enableOrDisableIcon (false, i);
currentPickUpIconInfo.iconActive = false;
}
} else {
//get the target position from global to local in the screen
targetPosition = currentPickUpIconInfo.targetTransform.position;
if (usingScreenSpaceCamera) {
screenPoint = mainCamera.WorldToViewportPoint (targetPosition);
targetOnScreen = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < 1 && screenPoint.y > 0 && screenPoint.y < 1;
} else {
screenPoint = mainCamera.WorldToScreenPoint (targetPosition);
targetOnScreen = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < screenWidth && screenPoint.y > 0 && screenPoint.y < screenHeight;
}
//if the target is visible in the screen, enable the icon
if (targetOnScreen) {
//use a raycast to check if the icon is visible
if (checkIcontype == checkIconType.raycast) {
distance = GKC_Utils.distance (targetPosition, cameraPosition);
if (distance <= maxDistanceIconEnabled) {
//set the direction of the raycast
direction = targetPosition - cameraPosition;
direction = direction / direction.magnitude;
//Debug.DrawRay(target.transform.position,-direction*distance,Color.red);
//if the raycast find an obstacle between the pick up and the camera, disable the icon
if (Physics.Raycast (targetPosition, -direction, distance, currentLayer)) {
if (currentPickUpIconInfo.iconActive) {
enableOrDisableIcon (false, i);
currentPickUpIconInfo.iconActive = false;
}
} else {
//else, the raycast reachs the camera, so enable the pick up icon
if (!currentPickUpIconInfo.iconActive) {
enableOrDisableIcon (true, i);
currentPickUpIconInfo.iconActive = true;
}
}
} else {
if (currentPickUpIconInfo.iconActive) {
enableOrDisableIcon (false, i);
currentPickUpIconInfo.iconActive = false;
}
}
} else if (checkIcontype == checkIconType.distance) {
//if the icon uses the distance, then check it
distance = GKC_Utils.distance (targetPosition, cameraPosition);
if (distance <= maxDistanceIconEnabled) {
if (!currentPickUpIconInfo.iconActive) {
enableOrDisableIcon (true, i);
currentPickUpIconInfo.iconActive = true;
}
} else {
if (currentPickUpIconInfo.iconActive) {
enableOrDisableIcon (false, i);
currentPickUpIconInfo.iconActive = false;
}
}
} else {
//else, always visible when the player is looking at its direction
if (!currentPickUpIconInfo.iconActive) {
enableOrDisableIcon (true, i);
currentPickUpIconInfo.iconActive = true;
}
}
if (currentPickUpIconInfo.iconActive) {
if (usingScreenSpaceCamera) {
iconPosition2d = new Vector2 ((screenPoint.x * mainCanvasSizeDelta.x) - halfMainCanvasSizeDelta.x,
(screenPoint.y * mainCanvasSizeDelta.y) - halfMainCanvasSizeDelta.y);
currentPickUpIconInfo.iconRectTransform.anchoredPosition = iconPosition2d;
} else {
currentPickUpIconInfo.iconObject.transform.position = new Vector3 (screenPoint.x, screenPoint.y, 0);
}
}
} else {
//else the icon is only disabled, when the player is not looking at its direction
if (currentPickUpIconInfo.iconActive) {
enableOrDisableIcon (false, i);
currentPickUpIconInfo.iconActive = false;
}
}
}
}
}
public void enableOrDisableIcon (bool state, int index)
{
if (useCanvasGroupOnIcons) {
if (state) {
if (pickUpIconList [index].mainCanvasGroup.alpha != 1) {
pickUpIconList [index].mainCanvasGroup.alpha = 1;
}
} else {
if (pickUpIconList [index].mainCanvasGroup.alpha != 0) {
pickUpIconList [index].mainCanvasGroup.alpha = 0;
}
}
} else {
if (pickUpIconList [index].iconObject.activeSelf != state) {
pickUpIconList [index].iconObject.SetActive (state);
}
}
}
//set what type of pick up is this object, and the object that the icon has to follow
public void setPickUpIcon (GameObject target, Texture targetTexture, int objectID, GameObject iconPrefab)
{
if (!showIconsActive) {
return;
}
if (checkIcontype == checkIconType.nothing) {
return;
}
if (mainPanelParentChecked) {
if (!mainPanelParentLocated) {
return;
}
} else {
mainPanelParentChecked = true;
if (!mainPanelParentLocated) {
mainPanelParentLocated = pickupObjectIconParent != null;
if (!mainPanelParentLocated) {
GameObject newPanelParentGameObject = GKC_Utils.getHudElementParent (playerControllerManager.gameObject, mainPanelName);
if (newPanelParentGameObject != null) {
pickupObjectIconParent = newPanelParentGameObject.transform;
mainPanelParentLocated = pickupObjectIconParent != null;
GKC_Utils.updateCanvasValuesByPlayer (playerControllerManager.gameObject, null, newPanelParentGameObject);
}
}
if (!mainPanelParentLocated) {
return;
}
}
}
pickUpIconListCount = pickUpIconList.Count;
for (int i = 0; i < pickUpIconListCount; i++) {
if (pickUpIconList [i].ID == objectID) {
return;
}
}
GameObject currentIconPrefab = pickUpIconObject;
if (iconPrefab != null) {
currentIconPrefab = iconPrefab;
}
GameObject newIconElement = (GameObject)Instantiate (currentIconPrefab, Vector3.zero, Quaternion.identity, pickupObjectIconParent);
pickUpIconInfo newIcon = newIconElement.GetComponent<pickUpIcon> ().pickUpElementInfo;
newIconElement.transform.localScale = Vector3.one;
newIconElement.transform.localPosition = Vector3.zero;
newIcon.target = target;
newIcon.targetTransform = target.transform;
if (!newIconElement.gameObject.activeSelf) {
newIconElement.gameObject.SetActive (true);
}
newIcon.ID = objectID;
if (targetTexture != null) {
newIcon.pickupIconImage.texture = targetTexture;
}
newIcon.iconActive = true;
pickUpIconList.Add (newIcon);
if (!showIconsActive) {
if (useCanvasGroupOnIcons) {
if (newIcon.mainCanvasGroup.alpha != 0) {
newIcon.mainCanvasGroup.alpha = 0;
}
} else {
if (newIcon.iconObject.activeSelf) {
newIcon.iconObject.SetActive (false);
}
}
newIcon.iconActive = false;
}
if (showIconsPaused) {
if (pickupObjectIconParent != null) {
if (pickupObjectIconParent.gameObject.activeSelf == showIconsPaused) {
pickupObjectIconParent.gameObject.SetActive (!showIconsPaused);
}
}
}
}
//destroy the icon
public void removeAtTarget (int index)
{
if (!showIconsActive) {
return;
}
if (index < pickUpIconList.Count) {
if (pickUpIconList [index].iconObject) {
Destroy (pickUpIconList [index].iconObject);
}
mainPickupManager.removeElementFromPickupListCalledByPlayer (pickUpIconList [index].ID);
pickUpIconList.RemoveAt (index);
} else {
print ("WARNING: the index to remove in player pickup icon manager is not correct, check the object picked to see if the icon is configured correctly");
}
}
public void removeAtTargetByID (int objectID)
{
if (!showIconsActive) {
return;
}
for (int i = 0; i < pickUpIconList.Count; i++) {
if (pickUpIconList [i].ID == objectID) {
if (pickUpIconList [i].iconObject != null) {
Destroy (pickUpIconList [i].iconObject);
}
pickUpIconList.RemoveAt (i);
return;
}
}
}
public void setPauseState (bool state, int index)
{
if (!showIconsActive) {
return;
}
if (index < pickUpIconList.Count) {
pickUpIconList [index].paused = state;
}
}
public void pauseOrResumeShowIcons (bool state)
{
showIconsPaused = state;
if (pickupObjectIconParent != null) {
if (pickupObjectIconParent.gameObject.activeSelf == showIconsPaused) {
pickupObjectIconParent.gameObject.SetActive (!showIconsPaused);
}
}
}
public void pauseOrResumeShowIconsFromEditor (bool state)
{
pauseOrResumeShowIcons (state);
updateComponent ();
}
public void setShowIconsActiveState (bool state)
{
showIconsActive = state;
}
public void updateScreenValues ()
{
screenWidth = Screen.width;
screenHeight = Screen.height;
}
public void setShowIconsActiveStateFromEditor (bool state)
{
setShowIconsActiveState (state);
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Player Pickup Manager", gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d595a40b4409395428c53a9728536575
timeCreated: 1527790498
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/PickUps/playerPickupIconManager.cs
uploadId: 814740