//Dealing with the player stat dictionary public int getStat(string resourceName) { if (!ShipResources.ContainsKey(resourceName)) { ShipResources.Add(resourceName, 0); } //returns the value of the given stat return(ShipResources[resourceName]); }
public void setStat(string resourceName, int Value) { if (ShipResources.ContainsKey(resourceName)) { ShipResources[resourceName] = Value; } else { //If the stat doesnt exist and we are setting it, lets just create it ShipResources.Add(resourceName, Value); } // }
public void changeStat(string resourceName, int statChange) { if (ShipResources.ContainsKey(resourceName)) { ShipResources[resourceName] = getStat(resourceName) + statChange; if (ShipResources[resourceName] < 0) { ShipResources[resourceName] = 0; } } else { //If the stat doesnt exist and we are setting it, lets just create it ShipResources.Add(resourceName, statChange); } // }
// Start is called before the first frame update void Start() { shipResources = GetComponent <ShipResources>(); mainCamera = GameObject.Find("Main Camera").GetComponent <Camera>(); joystick = GameObject.Find("Fixed Joystick").GetComponent <FixedJoystick>(); r = GetComponent <Rigidbody>(); r.useGravity = false; lookRotation = transform.rotation; defaultShipRotation = spaceshipRoot.localEulerAngles; rotationZ = defaultShipRotation.z; mainCamera.transform.position = cameraPosition.position; mainCamera.transform.rotation = cameraPosition.rotation; if (useMouse) { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } }
void Awake() { instance = this; }