I purchased a code converter from the asset store to convert most of my scripts from C# to JS for implementation of In App Purchases on another App store not listed in Unity. However when I tested it with one of my cs files after converting it to JS this one in general
import System.Collections.Generic;
import UnityEngine.UI;
import GameFramework.GameStructure;
namespace CSFramework {
/// <summary>
/// A base UI class you can use for your slot game.
/// It is not necessary to inherit this class
/// </summary>
class BaseSlotGameUI extends MonoBehaviour
{
var slot: CustomSlot;
Text textMoney, textRoundCost, textRound, textIncome, textBet, textFreeSpin, textBonus, debugText;
GameObject goFreeSpin, goBonus;
public var betList: List.<int> = new List.<int>() {1, 10, 100};
var targetFrameRate: int = 70;
private var betIndex: int = 0;
protected virtual function Awake (): void {
slot.callbacks.onActivated.AddListener(OnActivated);
slot.callbacks.onDeactivated.AddListener(OnDeactivated);
slot.callbacks.onRoundStart.AddListener(OnRoundStart);
slot.callbacks.onReelStart.AddListener(OnReelStart);
slot.callbacks.onReelStop.AddListener(OnReelStop);
slot.callbacks.onProcessHit.AddListener(OnProcessHit);
slot.callbacks.onRoundComplete.AddListener(OnRoundComplete);
slot.callbacks.onSlotStateChange.AddListener(OnSlotStateChange);
slot.callbacks.onSlotModeChange.AddListener(OnSlotModeChange);
slot.callbacks.onLineSwitch.AddListener(OnLineSwitch);
var TotalCoins: int = PlayerPrefs.GetInt("P0.TotalCoins");
PlayerPrefs.SetInt("game1_balance", TotalCoins);
GameManager.Instance.Player.UpdatePlayerPrefs();
PlayerPrefs.Save();
slot.Activate();
Initialize();
}
virtual function Initialize (): void {
Application.targetFrameRate = targetFrameRate;
RefreshMoney();
RefreshBet();
RefreshRoundCost();
goFreeSpin.SetActive(false);
goBonus.SetActive(false);
slot.SetBet(betList[betIndex]);
}
/// <summary>
/// A callback method subscribed to CS's onActivated event.
/// It is invoked when CS is activated, precisely after an intro animation event(parallel progression).
/// </summary>
virtual function OnActivated (): void { ShowDebugText("onActivated"); }
/// <summary>
/// A callback method subscribed to CS's onDeactivated event.
/// It is invoked when CS is deactivated, after an Out-Transition is completed.
/// </summary>
virtual function OnDeactivated (): void { ShowDebugText("onDeactivated"); }
/// <summary>
/// A callback method subscribed to CS's onRoundStart event.
/// It is invoked at the start of every round.
/// </summary>
virtual function OnRoundStart (): void {
ShowDebugText("onRoundStart");
RefreshRoundInfo();
}
/// <summary>
/// A callback method subscribed to CS's onStartSpin event.
/// It is invoked each time a reel starts.
/// </summary>
virtual function OnReelStart (info: ReelInfo): void {
PlayerPrefs.SetInt("P0.TotalCoins", int.Parse(textMoney.text));
ShowDebugText("onStartSpin");
if (info.isFirstReel) {
RefreshRoundInfo();
RefreshMoney();
}
}
/// <summary>
/// A callback method subscribed to CS's onStopReel event.
/// It is invoked each time a reel stops.
/// ReelInfo contains information like which reel was stopped.
/// </summary>
virtual function OnReelStop (info: ReelInfo): void { ShowDebugText("onStopReel"); }
/*
/// <summary>
/// A callback method subscribed to CS's onRoundInterval event.
/// It is invoked when all the reels stop spinning and before Hit Check starts.
/// </summary>
virtual function OnRoundInterval (): void { ShowDebugText("onRoundInterval"); }
*/
/// <summary>
/// A callback method subscribed to CS's onProcessHit event.
/// It is invoked when a Hit Check is performed on a line or a scatter and if it is successful.
/// Information like which symbol holders were the subjects of the hit, how many chains the hit made and etc etc
/// are passed with HitInfo.
///
/// HitInfo also has a reference to a DOTween sequence(<see cref="DG.Tweening.DOTween.Sequence"/> that plays highlighting effects for the hit symbols.
///
/// </summary>
virtual function OnProcessHit (info: HitInfo): void {
PlayerPrefs.SetInt("P0.TotalCoins", int.Parse(textMoney.text));
GameManager.Instance.Player.UpdatePlayerPrefs();
PlayerPrefs.Save();
ShowDebugText("onProcessHit");
if (info.hitSymbol.payType == Symbol.PayType.Normal) RefreshMoney();
RefreshRoundInfo();
}
/// <summary>
/// An UnityAction subscribed to CS's onRoundComplete event.
/// It is invoked at the end of every round.
/// </summary>
virtual function OnRoundComplete (): void { ShowDebugText("onRoundComplete"); }
/// <summary>
/// A callback method subscribed to CS's onSlotStateChange event.
/// It is invoked when CS's state changes.
/// </summary>
virtual function OnSlotStateChange (): void { ShowDebugText("onSlotStateChange"); }
/// <summary>
/// A callback method subscribed to CS's onSlotModeChange event.
/// It is invoked when CS's mode changes(e.g going to free spin mode).
/// </summary>
virtual function OnSlotModeChange (info: SlotModeInfo): void {
ShowDebugText("onSlotModeChange");
if (info.lastMode == slot.modes.freeSpinMode) ToggleFreeSpin(false);
if (info.lastMode == slot.modes.bonusMode) ToggleBonus(false);
if (slot.currentMode == slot.modes.freeSpinMode) ToggleFreeSpin(true);
if (slot.currentMode == slot.modes.bonusMode) ToggleBonus(true);
RefreshFreeSpin();
RefreshBonus();
}
/// <summary>
/// An UnityAction subscribed to CS's onLineSwitch event.
/// It is invoked every time a line is turned on/off.
/// The current state of the line can be checked from the passed LineInfo.
/// </summary>
virtual function OnLineSwitch (info: LineInfo): void {
ShowDebugText("onLineSwitch");
RefreshRoundCost();
RefreshRoundInfo();
}
virtual function ShowDebugText (detail: String): void {
if (!debugText) return;
debugText.text = "Last Callback: " + detail;
}
virtual function RefreshRoundCost (): void { textRoundCost.text = "" + slot.gameInfo.roundCost; }
virtual function RefreshMoney (): void { textMoney.text = "" + slot.gameInfo.balance; GameManager.Instance.Player.RemoveCoins(int.Parse(textIncome.text)); }
virtual function RefreshBet (): void { textBet.text = "" + slot.gameInfo.bet; }
virtual function RefreshRoundInfo (): void {
textRound.text = "Round. " + (slot.gameInfo.roundsCompleted + 1);
textIncome.text = "( " + slot.gameInfo.roundBalance + " )";
RefreshFreeSpin();
RefreshBonus();
}
virtual function ToggleFreeSpin (enable: boolean): void { goFreeSpin.SetActive(enable); }
virtual function RefreshFreeSpin (): void { textFreeSpin.text = "" + slot.gameInfo.freeSpins; }
virtual function ToggleBonus (enable: boolean): void { goBonus.SetActive(enable); }
virtual function RefreshBonus (): void { textBonus.text = "" + slot.gameInfo.bonuses; }
virtual function SetBet (index: int): boolean {
if (!slot.isIdle || index < 0 || index >= betList.Count) return false;
betIndex = index;
slot.SetBet(betList[betIndex]);
RefreshBet();
RefreshRoundCost();
var true: return;
}
virtual function RaiseBet (): void { SetBet(betIndex + 1); }
virtual function LowerBet (): void { SetBet(betIndex - 1); }
virtual function EnableNextLine (): void { slot.lineManager.EnableNextLine(); }
virtual function DisableCurrentLine (): void { slot.lineManager.DisableCurrentLine(); }
}
}
I get these errors from Unity
Assets/CustomSlots/Script/BaseSlotGameUI.js(9,9): BCE0044: expecting }, found ‘class’.
Assets/CustomSlots/Script/BaseSlotGameUI.js(9,15): BCE0044: expecting EOF, found ‘BaseSlotGameUI’.
Nothing was changed in this script it was just converted from C# to JS, Can anyone help fix this issue so I know whats going on?
Just on a side note it says Csharp but it is JavaScript.