Ejemplo n.º 1
0
        public static UIGameOverFormOpenParam Create(LevelData levelData, EnumGameOverType enumGameOverType, int starCount)
        {
            UIGameOverFormOpenParam uIGameOverFormOpenParam = ReferencePool.Acquire <UIGameOverFormOpenParam>();

            uIGameOverFormOpenParam.LevelData        = levelData;
            uIGameOverFormOpenParam.EnumGameOverType = enumGameOverType;
            uIGameOverFormOpenParam.StarCount        = starCount;
            return(uIGameOverFormOpenParam);
        }
        protected override void OnOpen(object userData)
        {
            base.OnOpen(userData);

            UIGameOverFormOpenParam uIGameOverFormOpenParam = userData as UIGameOverFormOpenParam;

            if (uIGameOverFormOpenParam == null)
            {
                Log.Error("UIGameOverForm open param tyoe invaild");
                return;
            }

            switch (uIGameOverFormOpenParam.EnumGameOverType)
            {
            case EnumGameOverType.Success:
                title.text = string.Format(GameEntry.Localization.GetString("Level Complete"), uIGameOverFormOpenParam.LevelData.Name);
                GameEntry.Sound.PlaySound(EnumSound.TDVictory);
                break;

            case EnumGameOverType.Fail:
                title.text = string.Format(GameEntry.Localization.GetString("Level Failed"), uIGameOverFormOpenParam.LevelData.Name);
                GameEntry.Sound.PlaySound(EnumSound.TDDefeat);
                break;
            }

            for (int i = 0; i < starImages.Length; i++)
            {
                if (i < uIGameOverFormOpenParam.StarCount)
                {
                    starImages[i].sprite = starSprite;
                }
                else
                {
                    starImages[i].sprite = starBgSprite;
                }
            }

            nextLevelButton.gameObject.SetActive(uIGameOverFormOpenParam.EnumGameOverType == EnumGameOverType.Success);
            DataLevel dataLevel = GameEntry.Data.GetData <DataLevel>();
            int       nextLevel = dataLevel.CurrentLevelIndex + 1;

            nextLevelButton.interactable = nextLevel <= dataLevel.MaxLevel;

            ReferencePool.Release(uIGameOverFormOpenParam);
        }
 public void Gameover(EnumGameOverType enumGameOverType, int starCount)
 {
     HidePreviewTower();
     Pause();
     GameEntry.UI.OpenUIForm(EnumUIForm.UIGameOverForm, UIGameOverFormOpenParam.Create(level.LevelData, enumGameOverType, starCount));
 }