79 lines
1.7 KiB
C#
79 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class GKCVendorConditionSystem : GKCConditionInfo
|
|
{
|
|
[Header ("Custom Settings")]
|
|
[Space]
|
|
|
|
public int vendorObjectAmount;
|
|
|
|
public bool useInfiniteVendorAmount;
|
|
|
|
public float vendorObjectPrice;
|
|
|
|
public float customMoneyChangeSpeed = 20;
|
|
|
|
|
|
public override bool checkIfConditionCompleteAndReturnResult ()
|
|
{
|
|
if (!checkIfPlayerAssigned ()) {
|
|
return false;
|
|
}
|
|
|
|
bool conditionResult = checkConditionResult ();
|
|
|
|
setConditionResult (conditionResult);
|
|
|
|
return conditionResult;
|
|
}
|
|
|
|
public override void checkIfConditionComplete ()
|
|
{
|
|
if (!checkIfPlayerAssigned ()) {
|
|
return;
|
|
}
|
|
|
|
bool conditionResult = checkConditionResult ();
|
|
|
|
setConditionResult (conditionResult);
|
|
}
|
|
|
|
bool checkConditionResult ()
|
|
{
|
|
bool conditionResult = false;
|
|
|
|
playerComponentsManager mainPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
|
|
|
if (mainPlayerComponentsManager != null) {
|
|
currencySystem mainCurrencySystem = mainPlayerComponentsManager.getCurrencySystem ();
|
|
|
|
if (mainCurrencySystem != null) {
|
|
bool currentConditionState = true;
|
|
|
|
if (mainCurrencySystem.getCurrentMoneyAmount () < vendorObjectPrice) {
|
|
currentConditionState = false;
|
|
}
|
|
|
|
if (currentConditionState) {
|
|
if (useInfiniteVendorAmount || vendorObjectAmount > 0) {
|
|
mainCurrencySystem.increaseTotalMoneyAmount (-vendorObjectPrice, customMoneyChangeSpeed);
|
|
|
|
if (!useInfiniteVendorAmount) {
|
|
vendorObjectAmount--;
|
|
}
|
|
} else {
|
|
currentConditionState = false;
|
|
}
|
|
|
|
}
|
|
|
|
conditionResult = currentConditionState;
|
|
}
|
|
}
|
|
|
|
return conditionResult;
|
|
}
|
|
}
|