protected override void OnRabitEnter(RabbitControl rabit) { LevelController.current.levelStatus.levelPassed = true; bool allCrystals = LevelController.current.levelStatus.hasBlueCrystal && LevelController.current.levelStatus.hasRedCrystal && LevelController.current.levelStatus.hasGreenCrystal; if (allCrystals) { LevelController.current.levelStatus.hasAllCrystals = true; } string str = JsonUtility.ToJson(LevelController.current.levelStatus); PlayerPrefs.SetString("stats" + LevelController.current.lvl, str); Debug.Log("Written " + str); string allCoins = PlayerPrefs.GetString("allCoins", null); if (allCoins == null) { allCoins = "0"; } bool result; int number; result = int.TryParse(allCoins, out number); if (result) { number = Int32.Parse(allCoins.ToString()); } number += LevelController.current.coins; PlayerPrefs.SetString("allCoins", number.ToString()); winPanelObj = Instantiate(prefabWinPanel); winPanelObj.transform.SetParent(canvas.transform, false); winPanel = winPanelObj.GetComponent <WinPanelScript>(); winPanel.showStatistic(LevelController.current.coins, LevelController.current.fruits, LevelController.current.fruitsMax, LevelController.current.crystalBlue, LevelController.current.crystalGreen, LevelController.current.crystalRed); }
public void onRabitDeath(RabbitControl rabit) { int currLifes = rabit.getLifes(); if (currLifes == 2) { life3.sprite = empty_life; } else if (currLifes == 1) { life2.sprite = empty_life; } else { life1.sprite = empty_life; } if (currLifes > 0) { rabit.transform.position = this.startingPosition; } else { levelStatus.levelPassed = false; string str = JsonUtility.ToJson(levelStatus); PlayerPrefs.SetString("stats" + lvl, str); Debug.Log("Written " + str); losePanelObj = Instantiate(prefabLosePanel); losePanelObj.transform.SetParent(canvas.transform, false); losePanel = losePanelObj.GetComponent <LosePanelScript>(); losePanel.showStatistic(crystalBlue, crystalGreen, crystalRed); } }
void OnTriggerEnter2D(Collider2D collider) { RabbitControl rabit = collider.GetComponent <RabbitControl>(); if (rabit != null) { this.OnRabitHit(rabit); } }
protected override void OnRabitHit(RabbitControl rabit) { if (canCollect) { LevelController.current.addFruits(1); string name = this.gameObject.name; LevelController.current.levelStatus.collectedFruitsList.Add(name); this.CollectedHide(); } }
void OnTriggerEnter2D(Collider2D collider) { RabbitControl rabit = collider.GetComponent <RabbitControl>(); if (rabit != null) { rabit.fall(); LevelController.current.onRabitDeath(rabit); } }
protected override void OnRabitHit(RabbitControl rabit) { if (rabit.getAfterMushroom() == true) { rabit.addBomb(); } if (rabit.getBig() == false && rabit.getBombBonus() == false) { rabit.die(); } rabit.setSmall(); if (rabit.getBombBonus() == false) { this.CollectedHide(); } }
// Use this for initialization void Start() { walkSource = gameObject.AddComponent <AudioSource>(); walkSource.clip = walkSound; dieSource = gameObject.AddComponent <AudioSource>(); dieSource.clip = dieSound; groundSource = gameObject.AddComponent <AudioSource>(); groundSource.clip = groundSound; rabbit = this; myBody = this.GetComponent <Rigidbody2D>(); LevelController.current.setStartPosition(transform.position); this.rabbitParent = this.transform.parent; isBig = false; standartSize = this.transform.localScale; bigSize.Set(standartSize.x * 1.5f, standartSize.y * 1.5f, standartSize.z); animator = this.GetComponent <Animator>(); lifes = 3; }
protected override void OnRabitHit(RabbitControl rabit) { string name = this.gameObject.name; int type = 0; if (name.Equals("gem-2")) { type = 1; } else if (name.Equals("gem-3")) { type = 2; } else { type = 3; } LevelController.current.addCrystals(type); this.CollectedHide(); }
protected override void OnRabitHit(RabbitControl rabit) { rabit.setBig(); rabit.setAfterMushroom(true); this.CollectedHide(); }
protected virtual void OnRabitHit(RabbitControl rabit) { }
protected override void OnRabitEnter(RabbitControl rabit) { SceneManager.LoadScene("Level1"); }
protected override void OnRabitHit(RabbitControl rabit) { rabit.die(); this.CollectedHide(); }
protected override void OnRabitHit(RabbitControl rabit) { LevelController.current.addCoins(1); this.CollectedHide(); }
protected virtual void OnRabitEnter(RabbitControl rabit) { }