protected void OnMouseDown() { if (status == 1) { PlayerSaveData currentSaveData = TreeController.singleton.getCurrentSaveData(); if (currentSaveData.getGold() >= unlockPrice) { recursivelyChangeStatus(2); TreeController.singleton.setCurrentNode(this); currentSaveData.modifyGold(-unlockPrice); } } }
protected override void Start() { base.Start(); if (GameStorage.Exists(Application.persistentDataPath + SaveKey.PLAYERDATA_KEY)) { mySaveData = GameStorage.Load <PlayerSaveData>(Application.persistentDataPath + SaveKey.PLAYERDATA_KEY); gameObject.name = mySaveData.name; myCoin = mySaveData.getGold(); myCrystal = mySaveData.getCrystal(); } if (GameStorage.Exists(Application.persistentDataPath + SaveKey.LASTPLAYERCHECKPOINT_KEY)) { Vector3 checkpointPosition = GameStorage.Load <Vector3>(Application.persistentDataPath + SaveKey.LASTPLAYERCHECKPOINT_KEY); transform.position = checkpointPosition; } else { transform.position = startingPosition; } body = GetComponent <Rigidbody2D>(); JumpPower = 2; readyToAccomplishTheMission = true; sceneBackgrounds = new List <Background>(FindObjectsOfType <Background>()); registerObserver(GameObject.Find("Player Attribute UI").GetComponent <PlayerAttributeView>()); registerObserver(GameObject.Find("Player View Rect").GetComponent <PlayerViewRect>()); notifyObservers(); notifyObserversAboutUnderwaterStatus(); mySpriteController = GetComponent <SpriteAnimationController>(); animate(PlayerMovementStatus.IDLE, 0.5f, true); followPoint = transform.FindChild("Follow Point"); }
public void UpdateView(PlayerSaveData psd) { goldText.text = psd.getGold().ToString(); crystalText.text = psd.getCrystal().ToString(); }