public override void BuildState() { main = BateController.Instance; m_selectionScene = AFAssetManager.Instance.Instantiate <GameObject>(AFAssetManager.GetDirectoryOwner("preFabs/PreFabSelectionScene")); background = GameObject.Find("BG"); bgAssetUrl = main.AddPlatformAndQualityToUrl(bgAssetUrl); background.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(bgAssetUrl); background.GetComponent <Image>().preserveAspect = true; btP1 = GameObject.Find("onePBtn"); p1AssetUrl = main.AddPlatformAndQualityToUrl(p1AssetUrl); btP1.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(p1AssetUrl); btP1.GetComponent <Button>().onClick.AddListener(OnClickP1); btP1.GetComponent <Image>().preserveAspect = true; btP2 = GameObject.Find("twoPBtn"); p2AssetUrl = main.AddPlatformAndQualityToUrl(p2AssetUrl); btP2.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(p2AssetUrl); btP2.GetComponent <Button>().onClick.AddListener(OnClickP2); btP2.GetComponent <Image>().preserveAspect = true; Add(m_selectionScene); base.BuildState(); }
public void StartScene(BateGameState m_game) { main = BateController.Instance; game = m_game; bgUrl = main.AddPlatformAndQualityToUrl(bgUrl); closeXUrl = main.AddPlatformAndQualityToUrl(closeXUrl); returnUrl = main.AddPlatformAndQualityToUrl(returnUrl); soundOnUrl = main.AddPlatformAndQualityToUrl(soundOnUrl); soundOffUrl = main.AddPlatformAndQualityToUrl(soundOffUrl); p1SelectedUrl = main.AddPlatformAndQualityToUrl(p1SelectedUrl); p2SelectedUrl = main.AddPlatformAndQualityToUrl(p2SelectedUrl); background = GameObject.Find("bg"); closeBtn = GameObject.Find("closeX"); returnBtn = GameObject.Find("return"); soundOnBtn = GameObject.Find("soundOn"); soundOffBtn = GameObject.Find("soundOff"); p1SelectedBtn = GameObject.Find("p1Selected"); p2SelectedBtn = GameObject.Find("p2Selected"); background.GetComponent <Image>().sprite = Instantiate(AFAssetManager.Instance.Load <Sprite>(bgUrl)) as Sprite; background.GetComponent <Image>().preserveAspect = true; closeBtn.GetComponent <Image>().sprite = Instantiate(AFAssetManager.Instance.Load <Sprite>(closeXUrl)) as Sprite; closeBtn.GetComponent <Image>().preserveAspect = true; closeBtn.GetComponent <Button>().onClick.AddListener(this.Close); closeBtn.SetActive(true); returnBtn.GetComponent <Image>().sprite = Instantiate(AFAssetManager.Instance.Load <Sprite>(returnUrl)) as Sprite; returnBtn.GetComponent <Image>().preserveAspect = true; returnBtn.GetComponent <Button>().onClick.AddListener(main.GoToMenu); returnBtn.SetActive(true); soundOnBtn.GetComponent <Image>().sprite = Instantiate(AFAssetManager.Instance.Load <Sprite>(soundOnUrl)) as Sprite; soundOnBtn.GetComponent <Image>().preserveAspect = true; soundOnBtn.GetComponent <Button>().interactable = (main.IsSounding); soundOnBtn.SetActive(main.IsSounding); soundOnBtn.GetComponent <Button>().onClick.AddListener(this.PlaySound); soundOffBtn.GetComponent <Image>().sprite = Instantiate(AFAssetManager.Instance.Load <Sprite>(soundOffUrl)) as Sprite; soundOffBtn.GetComponent <Image>().preserveAspect = true; soundOffBtn.GetComponent <Button>().interactable = (!main.IsSounding); soundOffBtn.SetActive(!main.IsSounding); soundOffBtn.GetComponent <Button>().onClick.AddListener(this.MuteSound); p1SelectedBtn.GetComponent <Image>().sprite = Instantiate(AFAssetManager.Instance.Load <Sprite>(p1SelectedUrl)) as Sprite; p1SelectedBtn.GetComponent <Image>().preserveAspect = true; p1SelectedBtn.GetComponent <Button>().interactable = (main.PlayerNumber == 1); p1SelectedBtn.SetActive(p1SelectedBtn.GetComponent <Button>().interactable); p1SelectedBtn.GetComponent <Button>().onClick.AddListener(this.SinglePlayer); p2SelectedBtn.GetComponent <Image>().sprite = Instantiate(AFAssetManager.Instance.Load <Sprite>(p2SelectedUrl)) as Sprite; p2SelectedBtn.GetComponent <Image>().preserveAspect = true; p2SelectedBtn.GetComponent <Button>().interactable = (!p1SelectedBtn.GetComponent <Button>().interactable); p2SelectedBtn.SetActive(!p1SelectedBtn.GetComponent <Button>().interactable); p2SelectedBtn.GetComponent <Button>().onClick.AddListener(this.MultiPlayer); }
public override void BuildState() { main = BateController.Instance; main.IsPaused = false; main.IsSounding = true; main.PlayerNumber = 1; bgAssetUrl = main.AddPlatformAndQualityToUrl(bgAssetUrl); titleAssetUrl = main.AddPlatformAndQualityToUrl(titleAssetUrl); btJogarAssetUrl = main.AddPlatformAndQualityToUrl(btJogarAssetUrl); btVoltarAssetUrl = main.AddPlatformAndQualityToUrl(btVoltarAssetUrl); m_menuScene = AFAssetManager.Instance.Instantiate <GameObject>(AFAssetManager.GetDirectoryOwner("preFabs/PreFabMenuScene")); background = GameObject.Find("menuBg"); backgroundTitle = GameObject.Find("menuTitle"); btJogar = GameObject.Find("menuBtJogar"); btVoltar = GameObject.Find("menuBtVoltar"); background.transform.localScale = Vector3.one; backgroundTitle.transform.localScale = Vector3.one; btJogar.transform.localScale = Vector3.one; btVoltar.transform.localScale = Vector3.one; background.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(bgAssetUrl); background.GetComponent <Image>().preserveAspect = true; backgroundTitle.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(titleAssetUrl); backgroundTitle.GetComponent <Image>().preserveAspect = true; btJogar.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(btJogarAssetUrl); btJogar.GetComponent <Image>().preserveAspect = true; btVoltar.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(btVoltarAssetUrl); btVoltar.GetComponent <Image>().preserveAspect = true; btJogar.GetComponent <Button>().onClick.AddListener(OnBtJogarClick); btVoltar.GetComponent <Button>().onClick.AddListener(OnBtVoltarClick); Add(m_menuScene); AddSounds(); base.BuildState(); }
public override void BuildState() { main = BateController.Instance; gameScene = AFAssetManager.Instance.Instantiate <GameObject>(AFAssetManager.GetDirectoryOwner("preFabs/PreFabGameScene")); playerNumber = main.PlayerNumber; VerifyScreenRes(); CreateBackGround(); CreateWalls(); CreateUI(); CreateBall(); CreatePaddles(); CreateTouches(); touchLeft.GetComponent <PaddleBehaviour>().AwakenPaddle(); touchRight.GetComponent <PaddleBehaviour>().AwakenPaddle(); ball.GetComponent <BallBehaviour>().AwakeBall(); Add(gameScene); base.BuildState(); }