Example #1
0
 private void CreateDessertButtonList()
 {
     this.availableDessertsCount = 0;
     foreach (GameObject gameObject in this.m_gameData.m_desserts)
     {
         int num = GameProgress.DessertCount(gameObject.GetComponent <Dessert>().saveId);
         this.availableDessertsCount += num;
         if (num > 0)
         {
             GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(this.m_dessertButtonPrefab);
             GameObject gameObject3 = UnityEngine.Object.Instantiate <GameObject>(gameObject.GetComponent <Dessert>().prefabIcon);
             gameObject3.transform.parent        = gameObject2.transform;
             gameObject3.transform.localScale    = new Vector3(1.75f, 1.75f, 1f);
             gameObject3.transform.localPosition = new Vector3(0f, 0f, -0.1f);
             gameObject3.GetComponent <MeshRenderer>().sortingOrder      = 1;
             gameObject2.GetComponent <DraggableButton>().Icon           = gameObject3;
             gameObject2.GetComponent <DraggableButton>().DragIconPrefab = gameObject3;
             gameObject2.GetComponent <DraggableButton>().DragIconScale  = 1.75f;
             gameObject2.GetComponent <DraggableButton>().DragObject     = gameObject;
             Transform transform = gameObject2.transform.Find("PartCount");
             transform.GetComponent <TextMesh>().text             = num.ToString();
             transform.GetComponent <MeshRenderer>().sortingOrder = 3;
             gameObject2.transform.parent = this.m_scrollList.transform;
             this.m_scrollList.AddButton(gameObject2.GetComponent <Widget>());
         }
     }
 }
Example #2
0
    public static int CurrentDessertCount()
    {
        int num = 0;

        for (int i = 0; i < WPFMonoBehaviour.gameData.m_desserts.Count; i++)
        {
            num += GameProgress.DessertCount(WPFMonoBehaviour.gameData.m_desserts[i].name);
        }
        return(num);
    }
Example #3
0
 private bool HasDesserts()
 {
     for (int i = 0; i < WPFMonoBehaviour.gameData.m_desserts.Count; i++)
     {
         if (GameProgress.DessertCount(WPFMonoBehaviour.gameData.m_desserts[i].name) > 0)
         {
             return(true);
         }
     }
     return(false);
 }
Example #4
0
 public static void AddDesserts(string dessertName, int count)
 {
     if (count > 0)
     {
         if (!GameProgress.m_data.GetBool("ChiefPigExploded", false))
         {
             GameProgress.m_data.SetBool("ChiefPigExploded", true);
         }
         int num = GameProgress.DessertCount(dessertName);
         GameProgress.SetDessertCount(dessertName, num + count);
         GameProgress.m_data.SetInt("TotalDessertCount", GameProgress.m_data.GetInt("TotalDessertCount", 0) + count);
     }
 }
Example #5
0
 public static void EatDesserts(string dessertName, int count)
 {
     if (count > 0)
     {
         int num  = GameProgress.DessertCount(dessertName);
         int num2 = num - count;
         if (num2 < 0)
         {
             num2 = 0;
             GameProgress.AddEatenDesserts(num);
         }
         else
         {
             GameProgress.AddEatenDesserts(count);
         }
         GameProgress.SetDessertCount(dessertName, num2);
     }
 }
Example #6
0
    public void EatDessert(Widget widget)
    {
        if (this.IsEating() || widget == null)
        {
            return;
        }
        this.isEating = true;
        GameObject gameObject = (GameObject)widget.GetComponent <DraggableButton>().DragObject;

        GameProgress.EatDesserts(gameObject.GetComponent <Dessert>().saveId, 1);
        int num = GameProgress.DessertCount(gameObject.GetComponent <Dessert>().saveId);

        this.SetButtonCount(widget, num);
        this.CheckAchievements();
        this.availableDessertsCount--;
        base.StartCoroutine(this.PlayChewingAnim(1f));
        if (num <= 0)
        {
            if (widget.GetComponent <DraggableButton>().isDragging)
            {
                this.CancelDrag(widget, null);
            }
            this.m_scrollList.RemoveButton(widget);
        }
        FeedingPrize.PrizeType prizeType = this.GiveReward(gameObject);
        this.m_CurGrowScale = this.m_CurGrowScale * this.m_GrowStepMul + this.m_GrowStepAdd;
        if (this.m_CurGrowScale > this.m_GrowLimit || prizeType != FeedingPrize.PrizeType.None)
        {
            this.m_CurGrowScale = this.m_InitialScale;
            base.StartCoroutine(this.PlayChewThenShrinkAndBurpAnim(1f, this.m_GrowDuration, prizeType));
        }
        else
        {
            if (this.m_GrowSoundFx)
            {
                Singleton <AudioManager> .Instance.Play2dEffect(this.m_GrowSoundFx);
            }
            this.scaleAnimTime = 0f;
        }
        GameProgress.SetFloat("KingPigFeedScale", this.m_CurGrowScale, GameProgress.Location.Local);
        this.scaleStart = this.m_kingPig.transform.parent.localScale;
    }