void Update()
    {
        // The player is grounded if a linecast to the groundcheck position hits anything on the ground layer.
        grounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"));

        // If the jump button is pressed and the player is grounded then the player should jump.
        if (Input.GetButtonDown("Jump"))
        {
            jump = true;
        }

        //restart
        if (restart == true)
        {
            transform.position = start;
            restart            = false;
        }
        //win or lose
        if (totalHeart <= 0)
        {
            Time.timeScale = 0f;
            Lose.SetActive(true);
        }
        else if (totalFinish >= 1)
        {
            Time.timeScale = 0f;
            Win.SetActive(true);
        }
    }
Example #2
0
 void Start()
 {
     AleatoryAnimal  = Random.Range(0, 4);
     AleatorySpawner = Random.Range(0, 4);
     Instantiate(Animals[AleatoryAnimal], Spawners[AleatorySpawner].transform);
     Instantiate(AnimalsInstantiate[AleatoryAnimal], QuestionAnimal.transform);
     Win.SetActive(false);
     Lose.SetActive(false);
 }
Example #3
0
 public void SumarAi()
 {
     scoreAi++;
     if (scoreAi >= 7)
     {
         Lose.SetActive(true);
         Time.timeScale = 0;
     }
 }
Example #4
0
 public void WinOrLose(bool win)     // выграл или проиграл
 {
     if (win)
     {
         Win.SetActive(true);
     }
     else
     {
         Time.timeScale = 0;
         Lose.SetActive(true);
     }
     Restart.SetActive(true);
 }
Example #5
0
    void Update()
    {
        score = PlayerPrefs.GetInt("CheckScore");

        if (score == 1)
        {
            Win.SetActive(true);
        }
        if (score == 2)
        {
            Lose.SetActive(true);
        }
    }
Example #6
0
        public void EndGame(bool win = false)
        {
            Win.SetActive(win);
            Lose.SetActive(!win);

            OnGameOver?.Invoke();

            MainMenu.Hide();
            GameOver.Hide();
            ScoreScreen.Show();

            _gameover = true;
        }
Example #7
0
    // Update is called once per frame
    void Update()
    {
        time       -= Time.deltaTime;
        UIText.text = time.ToString("f0");


        if (time <= 0)
        {
            Time.timeScale = 0;
            time           = 0;
            Lose.SetActive(true);
            SfxManager.sfxInstance.Audio.PlayOneShot(SfxManager.sfxInstance.Error);
        }
    }
Example #8
0
    // Update is called once per frame
    void Update()
    {
        spawnTime = SPEEDUP.spawnTime;


        if (wave == 4 && cnt == -1 && Hp.HP >= 1)
        {
            Page.SetActive(true);
            Win.SetActive(true);
        }
        else if (Hp.HP <= 0)
        {
            Page.SetActive(true);
            Lose.SetActive(true);
        }
    }
Example #9
0
    public void End(bool isWin)
    {
        EndPanel.SetActive(true);

        if (isWin)
        {
            Win.SetActive(true);
            Lose.SetActive(false);
        }
        else
        {
            Win.SetActive(false);
            Lose.SetActive(true);
        }
        Time.timeScale = 0f;
    }
Example #10
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public void BttnCheck()
    {
        if (Score == 9)
        {
            Win.SetActive(true);
            Lose.SetActive(false);
            SfxManager.sfxInstance.Audio.PlayOneShot(SfxManager.sfxInstance.Confirm);
        }
        else
        {
            Win.SetActive(false);
            Lose.SetActive(true);
            StartCoroutine("Wait");
            SfxManager.sfxInstance.Audio.PlayOneShot(SfxManager.sfxInstance.Error);
        }
    }
Example #11
0
    void Start()
    {
        Win.SetActive(false);
        Lose.SetActive(false);


        HairInitialPos      = Hair.transform.position;
        NoseInitialPos      = Nose.transform.position;
        CejaLeftInitialPos  = CejaLeft.transform.position;
        CejaRightInitialPos = CejaRight.transform.position;
        EyeLeftInitialPos   = EyeLeft.transform.position;
        EyeRightInitialPos  = EyeRigh.transform.position;
        OrejaRInitialPos    = OrejaR.transform.position;
        OrejaIInitialPos    = OrejaI.transform.position;
        MouthInitialPos     = Mouth.transform.position;
    }
Example #12
0
    void Update()
    {
        time       -= Time.deltaTime;
        UIText.text = time.ToString("f0");
        Score1      = trigg.puntuacion;
        Score2      = trigg2.puntuacion2;
        Score3      = trigg3.puntuacion3;
        Score4      = trigg4.puntuacion4;
        scoreCheck  = Score1 + Score2 + Score3 + Score4;

        if (time <= 0 && scoreCheck != 4)
        {
            Lose.SetActive(true);
            SfxManager.sfxInstance.Audio.PlayOneShot(SfxManager.sfxInstance.Error);
        }
        else if (time <= 0 && scoreCheck == 4)
        {
            Win.SetActive(true);
        }
    }
Example #13
0
    void Start()
    {
        CheckNameI = PlayerPrefs.GetInt("CheckName");
        if (CheckNameI == 1)
        {
            Game.SetActive(true);
        }
        else
        {
            Game.SetActive(false);
        }
        instantiateAnimals();
        trigg  = Collider1.GetComponent <Trigg>();
        trigg2 = Collider2.GetComponent <Trigg2>();
        trigg3 = Collider3.GetComponent <Trigg3>();
        trigg4 = Collider4.GetComponent <Trigg4>();

        Win.SetActive(false);
        Lose.SetActive(false);
        TryAgainT.SetActive(false);
    }
Example #14
0
 void Death()
 {
     xDistance = gameObject.transform.position.x - Player.transform.position.x;
     yDistance = gameObject.transform.position.y - Player.transform.position.y;
     if (Mathf.Abs(xDistance) < 2.5f && yDistance < 2)
     {
         Player.GetComponent <PlayerScript>().lives--;
         if (Player.GetComponent <PlayerScript>().lives == 2)
         {
             Heart3.localScale = Vector3.zero;
         }
         if (Player.GetComponent <PlayerScript>().lives == 1)
         {
             Heart2.localScale = Vector3.zero;
         }
         if (Player.GetComponent <PlayerScript>().lives == 0)
         {
             Heart1.localScale = Vector3.zero;
             Player.GetComponent <Animator>().SetInteger("animate", 6);
             Lose.SetActive(true);
             GetComponent <Collider2D>().enabled = false;
         }
     }
 }
Example #15
0
        private IEnumerator EndRoundCoroutine()
        {
            //=====================共用控件=====================
            if (GameData.LastRoundWin)
            {
                Win.SetActive(true);
                Lose.SetActive(false);
                AudioManager.PlayOneShot(WinSound);
            }
            else
            {
                Win.SetActive(false);
                Lose.SetActive(true);
                AudioManager.PlayOneShot(LoseSound);
            }
            for (int i = 0; i < Stars.Length; i++)
            {
                Stars[i].SetActive(i < _starCount);//星星数量
            }
            BtnLevelUpReward.SetActive(false);
            BtnNext.SetActive(true);
            BadgeShadow.SetActive(false);

            WinLosePanel.SetActive(false);
            SettlementPanel.SetActive(false);
            SkillUnlockPanel.SetActive(false);
            VegetableUnlockPanel.SetActive(false);
            //=====================胜负面板=====================
            _gotoNext = false;
            EnterStage(WinLosePanel);
            BtnNext.SetActive(false);

            MyCharacter.CharacterCode = CommonData.MyUser.CharacterCode;
            MyCharacter.Refresh();
            var userCharacter = CommonData.CurUserCharacter;

            if (userCharacter == null)
            {
                MyCharacter.TakeOffAllEquip();
            }
            else
            {
                MyCharacter.WearEquip(userCharacter.WearEquipList);
            }

            if (GameData.LastRoundWin)
            {
                //WinLight.SetActive(true);
                LblOnButton.text = "查看战利品";
                MyCharacter.Cheer();
            }
            else
            {
                //WinLight.SetActive(false);
                LblOnButton.text = "再接再厉";
                MyCharacter.Cry();
            }
            yield return(new WaitForSeconds(DurationWinLose));

            BtnNext.SetActive(true);
            PlayTween.Play(true);

            while (!_gotoNext)
            {
                yield return(new WaitForEndOfFrame());
            }
            ExitStage(WinLosePanel);
            PlayTween.Play(false);

            //======================结算面板=====================
            if (GameData.LastRoundWin)
            {
                _gotoNext = false;
                EnterStage(SettlementPanel);
                BadgeShadow.SetActive(true);
                BtnLevelUpReward.SetActive(false);
                //BtnNext.SetActive(false);
                LblLevel.text   = CommonData.MyUser.Level.ToString(CultureInfo.InvariantCulture);
                LblExpRate.text = string.Format("{0}%",
                                                Mathf.RoundToInt(Mathf.InverseLerp(CommonData.MyUser.ExpFloor,
                                                                                   CommonData.MyUser.ExpCeil,
                                                                                   CommonData.MyUser.Exp)));
                var addExp       = _roundRewardList.Find(x => x.Type == (int)CurrencyType.Exp);
                var addExpAmount = addExp == null ? 0 : addExp.Amount;
                LblAddExp.text = "+" + addExpAmount;

                if (_unlockElement != null && _unlockElement.HasLevelUp)
                {
                    var energyCapUp = _unlockElement.HasEnergyCapacityUp
                                          ? (_unlockElement.EnergyCapacityUp.ToCapacity -
                                             _unlockElement.EnergyCapacityUp.FromCapacity)
                                          : 0;
                    if (energyCapUp == 0)
                    {
                        LblSettlementDescription.text = "恭喜您升级了!";
                    }
                    else
                    {
                        LblSettlementDescription.text = string.Format("恭喜您升级了!蓄力值上限增加[FFA000]{0}[-]点!", energyCapUp);
                    }
                    //LblAddDiamond.text = "+" + unlockElement.LevelUp.TODO:升级奖励的钻石在哪呢
                }
                else
                {
                    switch (_starCount)
                    {
                    case 0:
                        LblSettlementDescription.text = "下次一定能赢的!";
                        break;

                    case 1:
                        LblSettlementDescription.text = "表现不错哦!";
                        break;

                    case 2:
                        LblSettlementDescription.text = "干得漂亮!";
                        break;

                    case 3:
                        LblSettlementDescription.text = "精彩绝伦的战斗!";
                        break;

                    default:
                        LblSettlementDescription.text = "继续努力!";
                        break;
                    }
                }

                yield return(new WaitForSeconds(1.6f)); //1.6

                //经验条显示
                var maxValue1 = Mathf.InverseLerp(CommonData.MyUser.ExpFloor, CommonData.MyUser.ExpCeil,
                                                  CommonData.MyUser.Exp - addExpAmount);
                var maxValue2 = Mathf.InverseLerp(CommonData.MyUser.ExpFloor, CommonData.MyUser.ExpCeil,
                                                  CommonData.MyUser.Exp);
                var duration = 0.7f;
                for (float t = 0;;)
                {
                    if (t >= duration)
                    {
                        SldExp.value = maxValue1;
                        break;
                    }
                    SldExp.value = t / duration * maxValue1;
                    yield return(new WaitForEndOfFrame());

                    t += Time.deltaTime;
                }
                //2.3
                //经验Add增长
                duration = 1f;
                for (float t = 0;;)
                {
                    if (t >= duration)
                    {
                        LblAddExp.text = "+" + addExpAmount;
                        break;
                    }
                    LblAddExp.text = "+" + Mathf.RoundToInt(addExpAmount * t / duration);
                    yield return(new WaitForEndOfFrame());

                    t += Time.deltaTime;
                }
                //3.3
                //经验条增长
                duration = 0.8f;
                for (float t = 0;;)
                {
                    if (t >= duration)
                    {
                        t            = duration;
                        SldExp.value = maxValue2;
                        break;
                    }
                    SldExp.value = Mathf.Lerp(maxValue1, maxValue2, t / duration);
                    yield return(new WaitForEndOfFrame());

                    t += Time.deltaTime;
                }
                //4.1
                //奖励显现
                RewardTemplate.SetActive(true);
                yield return(new WaitForSeconds(0.8f));

                //4.9
                var addCoin       = _roundRewardList.Find(x => x.Type == (int)CurrencyType.Coin);
                var addCoinAmount = addCoin == null ? 0 : addCoin.Amount;
                duration = 1.6f;
                for (float t = 0;;)
                {
                    if (t >= duration)
                    {
                        LblAddCoin.text = "+" + addCoinAmount;
                        break;
                    }
                    LblAddCoin.text = "+" + Mathf.RoundToInt(addCoinAmount * t / duration);
                    yield return(new WaitForEndOfFrame());

                    t += Time.deltaTime;
                }
                AudioManager.PlayOneShot(AddCoinSound);
                //6.5

                yield return(new WaitForSeconds(DurationSettlement));

                if (_unlockElement != null && _unlockElement.HasLevelUp)
                {
                    BtnLevelUpReward.SetActive(true);
                    BtnNext.SetActive(false);
                }
                else
                {
                    BtnLevelUpReward.SetActive(false);
                    BtnNext.SetActive(true);
                }
                LblOnButton.text = "下一步";
                PlayTween.Play(true);

                while (!_gotoNext)
                {
                    yield return(new WaitForEndOfFrame());
                }
                ExitStage(SettlementPanel);
                PlayTween.Play(false);
            }
            //======================技能解锁面板=====================
            if (_unlockElement != null && _unlockElement.SkillUnlockList.Count > 0)
            {
                _gotoNext = false;
                EnterStage(SkillUnlockPanel);

                for (int i = 0; i < _unlockElement.SkillUnlockList.Count; i++)
                {
                    var go = PrefabHelper.InstantiateAndReset(UnlockSkillTemplate, GridUnlockSkill.transform);
                    go.name = i.ToString(CultureInfo.InvariantCulture);
                    go.SetActive(true);
                    var spriteName = string.Format("skillicon-{0}", (SkillEnum)_unlockElement.SkillUnlockList[i].SkillCode);
                    var spr        = go.GetComponentInChildren <UISprite>();
                    spr.spriteName = spriteName;
                    var skillDisplayName = SkillUtil.GetSkillDisplayName((SkillEnum)_unlockElement.SkillUnlockList[i].SkillCode);
                    var lbl = go.GetComponentInChildren <UILabel>();
                    if (lbl)
                    {
                        lbl.text = skillDisplayName;
                    }
                }
                GridUnlockSkill.repositionNow           = true;
                GridUnlockSkill.transform.localPosition =
                    GridUnlockSkill.transform.localPosition.SetV3X(-GridUnlockSkill.cellWidth *
                                                                   (_unlockElement.SkillUnlockList.Count - 1) * 0.5f);
                UnlockSkillTemplate.SetActive(false);

                yield return(new WaitForSeconds(DurationSkillUnlock));

                BtnNext.SetActive(true);
                PlayTween.Play(true);
                while (!_gotoNext)
                {
                    yield return(new WaitForEndOfFrame());
                }
                ExitStage(SkillUnlockPanel);
                PlayTween.Play(false);
            }

            //======================蔬菜解锁面板=====================
            if (_unlockElement != null && _unlockElement.VegetableUnlockList.Count > 0)
            {
                _gotoNext = false;
                EnterStage(VegetableUnlockPanel);

                for (int i = 0; i < _unlockElement.VegetableUnlockList.Count; i++)
                {
                    var go = PrefabHelper.InstantiateAndReset(UnlockVegetableTemplate, GridUnlockVegetable.transform);
                    go.name = i.ToString(CultureInfo.InvariantCulture);
                    go.SetActive(true);
                    var cs            = go.GetComponentInChildren <VegetableSlot>();
                    var userVegetable =
                        CommonData.MyVegetableList.Find(
                            x => x.VegetableCode == _unlockElement.VegetableUnlockList[i].VegetableCode);
                    if (userVegetable != null)
                    {
                        userVegetable.CurrentUpgradeLimit = _unlockElement.VegetableUnlockList[i].NewUpgradeLimit;
                        if (cs)
                        {
                            cs.SetAndRefresh(userVegetable);
                        }
                    }
                    else
                    {
                        Debug.LogError("竟然找不到UserVegetable.Code:" + _unlockElement.VegetableUnlockList[i].VegetableCode);
                    }
                }
                GridUnlockVegetable.repositionNow           = true;
                GridUnlockVegetable.transform.localPosition =
                    GridUnlockVegetable.transform.localPosition.SetV3X(-GridUnlockVegetable.cellWidth *
                                                                       (_unlockElement.VegetableUnlockList.Count - 1) * 0.5f);
                UnlockVegetableTemplate.SetActive(false);

                yield return(new WaitForSeconds(DurationVegetableUnlock));

                BtnNext.SetActive(true);
                PlayTween.Play(true);
                while (!_gotoNext)
                {
                    yield return(new WaitForEndOfFrame());
                }
                _gotoNext = false;
                PlayTween.Play(false);
            }

            //======================退出结局UI=====================
            MusicManager.Instance.CrossFadeIn();
            if (_gotoPushLevelWhenEnd)
            {
                MainRoot.Goto(MainRoot.UIStateName.PushLevel);
                while (!PushLevelUI.Instance)
                {
                    yield return(new WaitForEndOfFrame());
                }
                if (CommonData.JustUnlockedMajorLevelId == null)//未解锁大关
                {
                    var majorLevel =
                        CommonData.ChallengeUnlockInfoList.Find(
                            x => x.MajorLevelId == GameData.LastChallengeMajorLevelID);
                    if (majorLevel != null)
                    {
                        PushLevelUI.Instance.EnterMajorLevel(majorLevel);
                    }
                }
                else//解锁大关
                {
                    var majorLevel =
                        CommonData.ChallengeUnlockInfoList.Find(
                            x => x.MajorLevelId == CommonData.JustUnlockedMajorLevelId);
                    print("justunlock ml:" + majorLevel);
                    if (majorLevel != null)
                    {
                        PushLevelUI.Instance.EnterMajorLevel(majorLevel);
                    }
                }
            }
            else
            {
                MainRoot.Goto(MainRoot.UIStateName.Menu);
            }
        }
Example #16
0
    IEnumerator Wait()
    {
        yield return(new WaitForSeconds(4));

        Lose.SetActive(false);
    }
Example #17
0
 void Start()
 {
     Win.SetActive(false);
     Lose.SetActive(false);
 }