Beispiel #1
0
    //Coroutine of booster working
    IEnumerator CreatingBombs()
    {
        busy = true;
        yield return(StartCoroutine(Utils.WaitFor(SessionAssistant.main.CanIWait, 0.1f)));

        yield return(StartCoroutine(SessionAssistant.main.Shuffle(true)));

        ProfileAssistant.main.local_profile["shaker"]--;
        ItemCounter.RefreshAll();
        busy = false;
    }
Beispiel #2
0
    // Coroutine of special control mode
    public override IEnumerator Logic()
    {
        spoon.gameObject.SetActive(false);

        yield return(StartCoroutine(Utils.WaitFor(SessionAssistant.main.CanIWait, 0.1f)));

        Slot target = null;

        while (true)
        {
            if (Input.GetMouseButtonDown(0) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended))
            {
                target = ControlAssistant.main.GetSlotFromTouch();
            }
            if (target != null && (!target.chip || target.chip.chipType != "Sugar"))
            {
                spoon.transform.position = target.transform.position;
                spoon.gameObject.SetActive(true);
                spoon.Play();

                CPanel.uiAnimation++;

                yield return(new WaitForSeconds(0.91f));

                ProfileAssistant.main.local_profile["spoon"]--;
                ItemCounter.RefreshAll();

                FieldAssistant.main.BlockCrush(target.coord, false);
                FieldAssistant.main.JellyCrush(target.coord);

                SessionAssistant.main.EventCounter();

                if (target.chip)
                {
                    target.chip.jamType = Jam.GetType(target);
                    target.chip.DestroyChip();
                }

                while (spoon.isPlaying)
                {
                    yield return(0);
                }

                spoon.gameObject.SetActive(false);

                CPanel.uiAnimation--;

                break;
            }
            yield return(0);
        }

        UIAssistant.main.ShowPage("Field");
    }
Beispiel #3
0
 // Function item purchase
 public void Purchase(int seedsCount, string goodId, int goodCount)
 {
     if (ProfileAssistant.main.local_profile["seed"] < seedsCount)
     {
         UIAssistant.main.ShowPage("Store");
         return;
     }
     ProfileAssistant.main.local_profile["seed"] -= seedsCount;
     ProfileAssistant.main.local_profile[goodId] += goodCount;
     ProfileAssistant.main.SaveUserInventory();
     ItemCounter.RefreshAll();
     AudioAssistant.Shot("Buy");
 }
 public void ClearData()
 {
     local_profile = new UserProfile();
     PlayerPrefs.DeleteAll();
     UserProfileUtils.WriteProfileOnDevice(local_profile);
     if (LevelMap.main)
     {
         LevelMap.main.UpdateMapParameters();
     }
     if (Application.isPlaying)
     {
         ItemCounter.RefreshAll();
     }
 }
    IEnumerator LifeSystemRoutine()
    {
        while (local_profile == null)
        {
            yield return(0);
        }

        TimeSpan refilling_time = new TimeSpan(0, ProjectParameters.main.refilling_time, 0);

        while (true)
        {
            while (local_profile["life"] < ProjectParameters.main.lifes_limit && local_profile.next_life_time <= DateTime.Now)
            {
                local_profile["life"]++;
                local_profile.next_life_time += refilling_time;
                ItemCounter.RefreshAll();
            }
            if (local_profile["life"] >= ProjectParameters.main.lifes_limit)
            {
                local_profile.next_life_time = DateTime.Now + refilling_time;
            }
            yield return(new WaitForSeconds(1));
        }
    }
Beispiel #6
0
 // updating counters, when balance of goods changed
 void onGoodBalanceChanged(VirtualGood good, int balance, int amountAdded)
 {
     ItemCounter.RefreshAll();
 }
Beispiel #7
0
 // updating counters, when balance of currency changed
 void onCurrencyBalanceChanged(VirtualCurrency virtualCurrency, int balance, int amountAdded)
 {
     ItemCounter.RefreshAll();
 }
Beispiel #8
0
    // Update is called once per frame
    IEnumerator WheelRoutine()
    {
        if (ProfileAssistant.main.local_profile.daily_raward < System.DateTime.Now)
        {
            System.DateTime next_reward = System.DateTime.Now;
            if (next_reward.Hour > ProfileAssistant.main.local_profile.daily_raward.Hour)
            {
                next_reward = next_reward.AddDays(1);
            }

            ProfileAssistant.main.local_profile.daily_raward = new System.DateTime(
                next_reward.Year, next_reward.Month, next_reward.Day,
                ProjectParameters.main.dailyreward_hour, 0, 0);
        }
        else if (ProfileAssistant.main.local_profile["spin"] >= 1)
        {
            ProfileAssistant.main.local_profile["spin"]--;
            ItemCounter.RefreshAll();
        }
        else if (ProfileAssistant.main.local_profile["seed"] >= spinCost)
        {
            ProfileAssistant.main.local_profile["seed"] -= spinCost;
            ItemCounter.RefreshAll();
        }
        else
        {
            UIAssistant.main.ShowPage("Store");
            yield break;
        }

        ProfileAssistant.main.SaveUserInventory();

        UpdateCounters();

        Animation anim;

        locker.SetActive(true);

        anim = spinButton.GetComponent <Animation>();
        anim.Play("SWButtonHide");
        while (anim.isPlaying)
        {
            yield return(0);
        }
        spinButton.gameObject.SetActive(false);

        speed = 0;
        while (speed < 200)
        {
            speed = Mathf.MoveTowards(speed, 200, Time.deltaTime * 90);
            wheel.Rotate(0, 0, -speed * Time.deltaTime);
            yield return(0);
        }

        stopButton.gameObject.SetActive(true);
        anim = stopButton.GetComponent <Animation>();
        anim.Play("SWButtonShow");

        stopButton.onClick.RemoveAllListeners();

        bool        stoped = false;
        UnityAction stop   = () => {
            stoped = true;
        };

        stopButton.onClick.AddListener(stop);

        while (!stoped)
        {
            wheel.Rotate(0, 0, -speed * Time.deltaTime);
            yield return(0);
        }

        stopButton.onClick.RemoveAllListeners();
        anim.Play("SWButtonHide");

        int total_probability = 0;

        foreach (SpinWheelReward reward in ProjectParameters.main.spinWheelRewards)
        {
            total_probability += reward.probability;
        }
        target = Random.Range(0, total_probability);
        for (int i = 0; i < 8; i++)
        {
            target -= ProjectParameters.main.spinWheelRewards[i].probability;
            if (target <= 0)
            {
                target = i;
                break;
            }
        }

        target_angle  = target * 45 - 360;
        intrigue      = -10f + (Random.value > 0.5f ? 22.5f : -22.5f);
        target_angle -= 360 * 3;

        current_angle = wheel.eulerAngles.z;

        while (intrigue != 0 || current_angle != target_angle + intrigue)
        {
            speed         = Mathf.MoveTowards(speed, Mathf.Min(200, Mathf.Abs(current_angle - intrigue - target_angle) / 3 + 2), Time.deltaTime * 2f * (Mathf.Abs(speed) + 5f));
            current_angle = Mathf.MoveTowards(current_angle, target_angle + intrigue, speed * Time.deltaTime);
            wheel.transform.eulerAngles = Vector3.forward * current_angle;
            if (current_angle == target_angle + intrigue)
            {
                intrigue = 0;
            }
            yield return(0);
        }

        stopButton.gameObject.SetActive(false);
        locker.SetActive(false);

        rewardIcon.sprite = ProjectParameters.main.spinWheelRewards[target].icon;

        List <string> report = new List <string>();

        foreach (string reward in ProjectParameters.main.spinWheelRewards[target].items)
        {
            string[] args  = reward.Split(':');
            int      count = int.Parse(args[1]);
            ProfileAssistant.main.local_profile[args[0]] += count;
            report.Add(LocalizationAssistant.main[BerryStoreAssistant.main.items.Find(x => x.id == args[0]).localization_name] + (count > 1 ? "(x" + count.ToString() + ")" : ""));
        }

        lastReward = string.Join(", ", report.ToArray());

        ProfileAssistant.main.SaveUserInventory();

        UpdateCounters();

        ItemCounter.RefreshAll();

        UIAssistant.main.ShowPage("SpinWheelReward");
    }
Beispiel #9
0
 // Update is called once per frame
 void OnValueChanged(int value)
 {
     LocalizationAssistant.main.LearnLanguage(LocalizationAssistant.main.languages[value]);
     ItemCounter.RefreshAll();
 }