void tryThrowingToChimney() { GameObject fire = GameObject.FindGameObjectWithTag("Fire"); ActionnableBehaviour fireBehaviour = fire.GetComponent <ActionnableBehaviour>(); if (fireBehaviour != null && fireBehaviour.playerInReach) { Debug.Log("chimney"); AudioSource audio = fire.GetComponent <AudioSource>(); if (audio != null && (carriedToy != null || carriedBox != null)) { audio.Play(); } if (carriedToy != null) { Destroy(carriedToy); carriedToy = null; takingObject = false; } if (carriedBox != null) { Destroy(carriedBox); carriedBox = null; takingObject = false; } } }
void tryFeedingSleigh() { GameObject sleigh = GameObject.FindGameObjectWithTag("Sleigh"); ActionnableBehaviour sleighBehaviour = sleigh.GetComponent <ActionnableBehaviour>(); if (sleighBehaviour != null && sleighBehaviour.playerInReach && takingObject && carriedBox != null) { ScoreBehaviour score = GameObject.FindGameObjectWithTag("Score").GetComponent <ScoreBehaviour>(); BoxBehaviour box = carriedBox.GetComponent <BoxBehaviour>(); if (box.toy.broken) { score.incrementScore(-100); } else { score.incrementScore(box.size * 100); AudioSource audio = sleigh.GetComponent <AudioSource>(); if (audio != null) { audio.Play(); } } takingObject = false; Destroy(carriedBox); carriedBox = null; } }
void tryRope() { GameObject rope = GameObject.FindGameObjectWithTag("Rope"); ActionnableBehaviour ropeBehaviour = rope.GetComponent <ActionnableBehaviour>(); if (carriedBox == null && ropeBehaviour != null && ropeBehaviour.playerInReach) { AudioSource audio = rope.GetComponent <AudioSource>(); if (audio != null) { audio.Play(); } bool smallBoxPresent = false, mediumBoxPresent = false, bigBoxPresent = false; GameObject[] boxes = GameObject.FindGameObjectsWithTag("box"); foreach (GameObject box in boxes) { BoxBehaviour boxBehaviour = box.GetComponent <BoxBehaviour>(); if (boxBehaviour != null) { switch (boxBehaviour.size) { case 1: smallBoxPresent = true; break; case 2: mediumBoxPresent = true; break; case 3: bigBoxPresent = true; break; } } } if (!smallBoxPresent) { GameObject.Instantiate(Resources.Load("10_PREFABS/SmallBox"), BoxBehaviour.smallBoxPosition, new Quaternion()); } if (!mediumBoxPresent) { GameObject.Instantiate(Resources.Load("10_PREFABS/MediumBox"), BoxBehaviour.mediumBoxPosition, new Quaternion()); } if (!bigBoxPresent) { GameObject.Instantiate(Resources.Load("10_PREFABS/BigBox"), BoxBehaviour.bigBoxPosition, new Quaternion()); } } }