public void Initialize() { mg_BeanCounter active = MinigameManager.GetActive <mg_BeanCounter>(); if (!active.Resources.HasLoadedGameSounds) { active.Resources.LoadGameSounds(); } m_background = active.Resources.GetInstancedResource(mg_bc_EResourceList.GAME_ASSET_BACKGROUND); MinigameSpriteHelper.SetSpriteLayer(m_background, -100); Vector3 localScale = m_background.transform.localScale; MinigameSpriteHelper.FitSpriteToScreen(active.MainCamera, m_background, _preserveAspect: false); MinigameSpriteHelper.AssignParent(m_background, base.gameObject); base.gameObject.transform.localScale = m_background.transform.localScale; m_background.transform.localScale = localScale; GameObject gameObject = base.gameObject.transform.Find("mg_bc_penguin").gameObject; Penguin = gameObject.GetComponent <mg_bc_Penguin>(); Penguin.GameLogic = this; GameObject gameObject2 = base.gameObject.transform.Find("mg_bc_dropzone").gameObject; DropZone = gameObject2.GetComponent <mg_bc_DropZone>(); GameObject gameObject3 = base.gameObject.transform.Find("mg_bc_truck").gameObject; Truck = gameObject3.GetComponent <mg_bc_Truck>(); Truck.CanSpawnLives = Penguin.Lives.Value < 4; GameObject gameObject4 = base.gameObject.transform.Find("mg_bc_left_edge").gameObject; GameObject gameObject5 = base.gameObject.transform.Find("mg_bc_right_edge").gameObject; Penguin.SetMovementLimits(gameObject4.transform.localPosition.x, gameObject5.transform.localPosition.x); ScoreController.Initialize(Truck); }
protected void Awake() { BaseContainer = MinigameSpriteHelper.CreateContainer("mg_pr_GameContainer"); mg_PuffleRoundup active = MinigameManager.GetActive <mg_PuffleRoundup>(); m_background = active.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_BACKGROUND); MinigameSpriteHelper.SetSpriteLayer(m_background, -100); Vector3 localScale = m_background.transform.localScale; MinigameSpriteHelper.FitSpriteToScreen(active.MainCamera, m_background, _preserveAspect: false); MinigameSpriteHelper.AssignParent(m_background, BaseContainer); BaseContainer.transform.localScale = m_background.transform.localScale; m_background.transform.localScale = localScale; BaseContainer.transform.parent = active.transform; m_caughtGo = GetComponentInChildren <mg_pr_UICaughtCount>(); m_escapedGo = GetComponentInChildren <mg_pr_UIEscapedCount>(); }
public void SpawnObsticles(int numToSpawn) { int i = 0; bool flag = false; int num = 0; Vector3 vector = default(Vector3); for (; i < numToSpawn; i++) { flag = false; while (!flag) { vector.x = Random.Range(-5f, 5f); vector.y = Random.Range(-4f, 3f); flag = !penBoundsGO.GetComponent <SpriteRenderer>().bounds.Contains(vector); num++; if (num > 100) { return; } } switch (Random.Range(1, 4)) { case 1: Rock1 = Minigame.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_OBSTICLE_ROCK1); MinigameSpriteHelper.SetSpriteLayer(Rock1, 0); MinigameSpriteHelper.AssignParent(Rock1, m_ObsticleContainer); Rock1.transform.position = vector; break; case 2: Rock2 = Minigame.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_OBSTICLE_ROCK2); MinigameSpriteHelper.SetSpriteLayer(Rock2, 0); MinigameSpriteHelper.AssignParent(Rock2, m_ObsticleContainer); Rock2.transform.position = vector; break; case 3: Stump = Minigame.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_OBSTICLE_STUMP); MinigameSpriteHelper.SetSpriteLayer(Stump, 0); MinigameSpriteHelper.AssignParent(Stump, m_ObsticleContainer); Stump.transform.position = vector; break; } } }
public void SpawnPuffles() { int i = 0; int num = 10; bool flag = false; int num2 = 0; Vector3 vector = default(Vector3); for (; i < num; i++) { flag = false; while (!flag) { vector.x = Random.Range(-5f, 5f); vector.y = Random.Range(-4f, 3f); flag = !penBoundsGO.GetComponent <SpriteRenderer>().bounds.Contains(vector); num2++; if (num2 > 100) { return; } } switch (Random.Range(1, 11)) { case 1: PuffleWhite = Minigame.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_PUFFLE_WHITE); MinigameSpriteHelper.SetSpriteLayer(PuffleWhite, 50); MinigameSpriteHelper.AssignParent(PuffleWhite, m_PuffleContainer); PuffleWhite.transform.position = vector; break; case 2: PuffleYellow = Minigame.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_PUFFLE_YELLOW); MinigameSpriteHelper.SetSpriteLayer(PuffleYellow, 50); MinigameSpriteHelper.AssignParent(PuffleYellow, m_PuffleContainer); PuffleYellow.transform.position = vector; break; case 3: PuffleOrange = Minigame.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_PUFFLE_ORANGE); MinigameSpriteHelper.SetSpriteLayer(PuffleOrange, 50); MinigameSpriteHelper.AssignParent(PuffleOrange, m_PuffleContainer); PuffleOrange.transform.position = vector; break; case 4: PuffleRed = Minigame.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_PUFFLE_RED); MinigameSpriteHelper.SetSpriteLayer(PuffleRed, 50); MinigameSpriteHelper.AssignParent(PuffleRed, m_PuffleContainer); PuffleRed.transform.position = vector; break; case 5: PufflePink = Minigame.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_PUFFLE_PINK); MinigameSpriteHelper.SetSpriteLayer(PufflePink, 50); MinigameSpriteHelper.AssignParent(PufflePink, m_PuffleContainer); PufflePink.transform.position = vector; break; case 6: PufflePurple = Minigame.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_PUFFLE_PURPLE); MinigameSpriteHelper.SetSpriteLayer(PufflePurple, 50); MinigameSpriteHelper.AssignParent(PufflePurple, m_PuffleContainer); PufflePurple.transform.position = vector; break; case 7: PuffleBlue = Minigame.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_PUFFLE_BLUE); MinigameSpriteHelper.SetSpriteLayer(PuffleBlue, 50); MinigameSpriteHelper.AssignParent(PuffleBlue, m_PuffleContainer); PuffleBlue.transform.position = vector; break; case 8: PuffleGreen = Minigame.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_PUFFLE_GREEN); MinigameSpriteHelper.SetSpriteLayer(PuffleGreen, 50); MinigameSpriteHelper.AssignParent(PuffleGreen, m_PuffleContainer); PuffleGreen.transform.position = vector; break; case 9: PuffleBrown = Minigame.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_PUFFLE_BROWN); MinigameSpriteHelper.SetSpriteLayer(PuffleBrown, 50); MinigameSpriteHelper.AssignParent(PuffleBrown, m_PuffleContainer); PuffleBrown.transform.position = vector; break; case 10: PuffleBlack = Minigame.Resources.GetInstancedResource(mg_pr_EResourceList.GAME_ASSET_PUFFLE_BLACK); MinigameSpriteHelper.SetSpriteLayer(PuffleBlack, 50); MinigameSpriteHelper.AssignParent(PuffleBlack, m_PuffleContainer); PuffleBlack.transform.position = vector; break; } } }