protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); WelcomeAnimation.Begin(); }
void Start() { //PlayerPrefs.SetInt("Profit", 0); //PlayerPrefs.SetInt("AllScore",0); //PlayerPrefs.SetInt("GameCounter", 0); //PlayerPrefs.SetInt("BestScore", Random.Range(500,1000)); audio = gameObject.AddComponent <AudioSource>(); profit = PlayerPrefs.GetInt("Profit"); bestScore = PlayerPrefs.GetInt("BestScore"); allScore = PlayerPrefs.GetInt("AllScore"); gameCounter = PlayerPrefs.GetInt("GameCounter"); if (allScore < 1000) { allScore = 1000; } if (gameCounter < 10) { gameCounter = 10; } if (JavaInterface.Java()) { if (bestScore < 500) { bestScore = Random.Range(500, 1000); } playerText = Instantiate(texts[5]).GetComponent <CustomText>(); playerText.transform.parent = transform; playerText.transform.position = new Vector3(-1.125f, 0.5f); playerText.transform.localScale = new Vector3(0.15f, 0.15f); scoreText = Instantiate(texts[7]).GetComponent <CustomText>(); scoreText.transform.parent = transform; scoreText.transform.position = new Vector3(-1.125f, 0.40f); scoreText.transform.localScale = new Vector3(0.075f, 0.075f); //scoreText.Init(); //scoreText.Display(0); //playerText.gameObject.SetActive(false); } else { mAuidoOption = Instantiate(audioOption).GetComponent <OptionAnimation>(); mAuidoOption.transform.parent = transform; mAuidoOption.transform.localScale = new Vector3(1.5f, 1.5f, 1f); mAuidoOption.transform.position = new Vector3(1.15f, 0.575f); //Debug.Log(mAuidoOption); EventListener.Get(mAuidoOption.gameObject).onClick += (GameObject obj) => { mAuidoOption.OnClick(); }; EventListener.Get(mAuidoOption.gameObject).onPress += (GameObject obj) => { mAuidoOption.OnPress(); }; EventListener.Get(mAuidoOption.gameObject).onFree += (GameObject obj) => { mAuidoOption.OnFree(); }; } mChopLeft = Instantiate(chopLeft).GetComponent <ChopAnimation>(); mChopRight = Instantiate(chopRight).GetComponent <ChopAnimation>(); mChopLeft.transform.parent = transform; mChopRight.transform.parent = transform; mChopLeft.transform.position = new Vector3(-0.75f, -0.125f); mChopRight.transform.position = new Vector3(0.75f, -0.125f); mChopLeft.Hide(); mChopRight.Hide(); gameText = Instantiate(texts[4]).GetComponent <CustomText>(); gameText.transform.parent = transform; gameText.transform.position = new Vector3(0, 0.25f); gameText.transform.localScale = new Vector3(0.25f, 0.25f, 1); gameText.gameObject.SetActive(false); mMainPanel = Instantiate(mainPanel).GetComponent <PanelAnimation>(); lastScoreText = Instantiate(texts[6]).GetComponent <CustomText>(); lastScoreText.transform.parent = mMainPanel.transform; lastScoreText.transform.localScale = new Vector3(0.1f, 0.2f); lastScoreText.transform.position = mMainPanel.transform.position + new Vector3(0, -0.675f); bestText = Instantiate(texts[6]).GetComponent <CustomText>(); bestText.transform.parent = mMainPanel.transform; bestText.transform.position = mMainPanel.transform.position + new Vector3(0, -0.425f); bestText.Display(bestScore); mScroll = Instantiate(scroll).GetComponent <ScrollAnimation>(); mScroll.transform.position = new Vector3(0, 0.65f); mScroll.transform.parent = transform; mScroll.gameObject.SetActive(false); mScrollMain = Instantiate(scrollMain).GetComponent <ScrollAnimation>(); mScrollMain.transform.position = new Vector3(1.2f, -0.15f); mScrollMain.transform.parent = transform; mScrollMain.GetComponent <Renderer>().material.color = new Color(1, 1, 1, 0); for (int i = 0; i < mScrollMain.transform.childCount; i++) { mScrollMain.transform.GetChild(i).GetComponent <Renderer>().material.color = new Color(1, 1, 1, 0); } mAwards = mScrollMain.GetComponent <AwardsAnimation>(); mScrollMain.gameObject.SetActive(false); if (JavaInterface.Java() == true) { mWelcome = Instantiate(welcomeArcade).GetComponent <WelcomeAnimation>(); } else { mWelcome = Instantiate(welcomeMobile).GetComponent <WelcomeAnimation>(); } mWelcome.transform.position = transform.position; mWelcome.transform.parent = transform; //mWelcome.transform.localScale = new Vector3(2, 2); mWelcome.Hide(); mWelcome.gameObject.GetComponent <Collider>().enabled = false; GameEvent.onGetScore += OnGetScore; GameEvent.onDeath += OnDeath; GameEvent.onFinishGame += OnFinishGame; GameEvent.onReset += OnReset; GameEvent.startReset += StartReset; GameEvent.finishReset += FinishReset; GameEvent.onHealth += OnHealth; GameEvent.onStartGame += OnStartGame; GameEvent.onWelcome += OnWelcome; GameEvent.offWelcome += OffWelcome; GameEvent.waitStartGame += WaitStartGame; GameEvent.onLaunchGame += OnLaunchGame; EventListener.Get(mWelcome.gameObject).onClick += (GameObject obj) => { GameController.isLaunchGame = true; }; EventListener.Get(mChopLeft.gameObject).onPress += (GameObject obj) => { GameController.isLaunchGame = true; GameEvent.OnAttackLeft(PlayerController.players[0]); }; EventListener.Get(mChopRight.gameObject).onPress += (GameObject obj) => { GameController.isLaunchGame = true; GameEvent.OnAttackRight(PlayerController.players[0]); }; InputPort.onChangeScoreEvent += (int value) => { playerText.Display(value / 10, 0.1f); scoreText.Display(value % 10, 0.1f); }; }