예제 #1
0
 public void Init(Game game)
 {
     this._game = game;
     base.gameObject.SetActive(true);
     base.gameObject.SetActive(false);
     this._mainMenu.Text = (App.GameType != GameType.Single) ? Sl.GetValue("MAIN MENU") : Sl.GetValue("TO LEVELS");
 }
예제 #2
0
    private void Start()
    {
        Campaign campaign = !this.IsCoop ? App.Campaigns[this.CampaignIndex] : App.CoopCampaigns[this.CampaignIndex];

        this._name.text = Sl.GetValue(campaign.Name);
        Sprite sprite = Resources.Load <Sprite>((!this.IsCoop ? "Campaigns/" : "CoopCampaigns/") + this.CampaignIndex);

        if (sprite != null)
        {
            this._image.sprite = sprite;
        }
        this._locked.SetActive(false);
        if (this.CampaignIndex == -1)
        {
            this._stars.gameObject.SetActive(false);
            this._locked.SetActive(!this.IsCoop ? (PlayerSettings.OpenedCampaign.Value <= 0) : (PlayerSettings.OpenedCoopCampaign.Value <= 0));
            base.IsEnabled = !this._locked.activeSelf;
            if (!base.IsEnabled)
            {
                this._image.color = new Color(0.25f, 0.25f, 0.25f);
            }
            this._unlock.SetActive(false);
        }
        else
        {
            this._stars.gameObject.SetActive(true);
            int num  = campaign.Levels.Count * 3;
            int num2 = 0;
            for (int i = 0; i < campaign.Levels.Count; i++)
            {
                num2 += !this.IsCoop ? PlayerSettings.GetLevelStarsCount(this.CampaignIndex, i) : PlayerSettings.GetCoopLevelStarsCount(this.CampaignIndex, i);
            }
            this._stars.text = num2 + "/" + num;
            this._unlock.SetActive(this.CanBeBought);
            if (this.CanBeBought)
            {
                int num4 = !this.IsCoop ? App.CampaignUnlockCost : App.CoopCampaignUnlockCost;
                this._image.color          = new Color(0.25f, 0.25f, 0.25f);
                this._unlockCoinsText.text = num4.ToString();
                this._stars.gameObject.SetActive(false);
                if (PlayerSettings.Money.Value < num4)
                {
                    Color color = new Color(0.5f, 0.5f, 0.5f);
                    this._unlockCoinsText.color = color;
                    this._unlockCoinsIcon.color = color;
                    base.IsEnabled = false;
                }
            }
            if (!base.IsEnabled)
            {
                if (!this.CanBeBought)
                {
                    this._locked.SetActive(true);
                    this._image.color = new Color(0.25f, 0.25f, 0.25f);
                }
                this._stars.gameObject.SetActive(false);
            }
        }
    }
예제 #3
0
    public override void Init()
    {
        for (int i = 0; i < this._levelIcons.Count; i++)
        {
            UnityEngine.Object.Destroy(this._levelIcons[i].gameObject);
        }
        Campaign campaign = App.CoopCampaigns[App.CurrentCampaign];

        this._levelIcons.Clear();
        this._campaignName.text = Sl.GetValue(campaign.Name).ToUpper();
        if (App.CurrentCampaign == -1)
        {
            this._random.SetActive(true);
        }
        else
        {
            this._random.SetActive(false);
            float num2 = (-this._elementSize * this._columns) * 0.5f;
            float num3 = (this._elementSize * this._rows) * 0.5f;
            for (int j = 0; j < this._rows; j++)
            {
                for (int k = 0; k < this._columns; k++)
                {
                    int level = (this._columns * j) + k;
                    if (level > (campaign.Levels.Count - 1))
                    {
                        break;
                    }
                    LevelIcon item = (LevelIcon)UnityEngine.Object.Instantiate(this._levelIconPrefab);
                    item.transform.parent        = base.transform;
                    item.transform.localPosition = new Vector3(num2 + (this._elementSize * (k + 0.5f)), num3 - (this._elementSize * (j + 0.5f)));
                    item.Number = level;
                    item.Stars  = PlayerSettings.GetCoopLevelStars(App.CurrentCampaign, level);
                    if (App.CurrentCampaign < PlayerSettings.OpenedCoopCampaign.Value)
                    {
                        item.IsEnabled = true;
                    }
                    else
                    {
                        item.IsEnabled = level <= PlayerSettings.OpenedCoopLevel.Value;
                    }
                    object[] args = new object[] { "scale", Vector3.zero, "time", 0.5f, "delay", 0.1f + UnityEngine.Random.Range((float)0f, (float)0.15f), "easetype", iTween.EaseType.easeOutElastic };
                    iTween.ScaleFrom(item.gameObject, iTween.Hash(args));
                    this._levelIcons.Add(item);
                }
            }
        }
    }
예제 #4
0
 protected override void OnMouseUp()
 {
     if (base.IsEnabled && base._hold)
     {
         if (this.CanBeBought)
         {
             MessageBox.Show(Sl.GetValue("Unlock Campaign"), string.Format(Sl.GetValue("UnlockDesc"), this._name.text), delegate {
                 if (this.IsCoop)
                 {
                     PlayerSettings.OpenedCoopCampaign.SetAndSave(this.CampaignIndex);
                     PlayerSettings.OpenedCoopLevel.SetAndSave(0);
                     PlayerSettings.Money.SetAndSave(PlayerSettings.Money.Value - App.CoopCampaignUnlockCost);
                 }
                 else
                 {
                     PlayerSettings.OpenedCampaign.SetAndSave(this.CampaignIndex);
                     PlayerSettings.OpenedLevel.SetAndSave(0);
                     PlayerSettings.Money.SetAndSave(PlayerSettings.Money.Value - App.CampaignUnlockCost);
                 }
                 UnityEngine.Object.FindObjectOfType <CoopCampaignMenu>().UpdateCampaigns();
                 UnityEngine.Object.FindObjectOfType <CampaignMenu>().UpdateCampaigns();
             }, null, true, 0.15f, null);
         }
         else
         {
             App.CurrentCampaign = this.CampaignIndex;
             if (this.IsCoop)
             {
                 PlayerSettings.LastCoopCampaign.SetAndSave(this.CampaignIndex);
             }
             else
             {
                 PlayerSettings.LastCampaign.SetAndSave(this.CampaignIndex);
             }
             base.OnMouseUp();
         }
     }
 }