示例#1
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");
    }
示例#2
0
    public static void Initialize()
    {
        words.Add("CurrentLevel", () => { return(LevelProfile.main.level.ToString()); });
        words.Add("CurrentScore", () => { return(SessionAssistant.main.score.ToString()); });
        words.Add("FirstStarScore", () => { return(LevelProfile.main.firstStarScore.ToString()); });
        words.Add("SecondStarScore", () => { return(LevelProfile.main.secondStarScore.ToString()); });
        words.Add("ThirdStarScore", () => { return(LevelProfile.main.thirdStarScore.ToString()); });
        words.Add("BestScore", () => { return(ProfileAssistant.main.local_profile.GetScore(LevelProfile.main.level).ToString()); });
        words.Add("BlockCount", () => { return(GameObject.FindObjectsOfType <Block> ().Length.ToString()); });
        words.Add("BlockCountTotal", () => { return(SessionAssistant.main.blockCountTotal.ToString()); });
        words.Add("JellyCount", () => { return(Slot.all.Count(x => x.Value.jelly).ToString()); });
        words.Add("JellyCountTotal", () => { return(SessionAssistant.main.jellyCountTotal.ToString()); });
        words.Add("JamCount", () => { return(Slot.all.Count(x => Jam.GetType(x.Value) == "Jam A").ToString()); });
        words.Add("JamCountTotal", () => { return(Slot.all.Count.ToString()); });
        words.Add("SugarCount", () => { return(SessionAssistant.main.targetSugarDropsCount.ToString()); });
        words.Add("SugarCountTotal", () => { return(LevelProfile.main.targetSugarDropsCount.ToString()); });
        words.Add("CurrentMoves", () => { return(SessionAssistant.main.movesCount.ToString()); });
        words.Add("CurrentTime", () => { return(Utils.ToTimerFormat(SessionAssistant.main.timeLeft)); });
        words.Add("WaitingStatus", () => { return(Utils.waitingStatus); });
        words.Add("TargetModeName", () => { return(LocalizationAssistant.main["targetmodename_" + LevelProfile.main.target]); });
        words.Add("BoosterSelectedName", () => { return(BerryStoreAssistant.main.GetItemByID(BoosterButton.boosterSelectedId).name); });
        words.Add("BoosterSelectedPackDescription", () => { return(LocalizationAssistant.main[BerryStoreAssistant.main.GetItemByID(BoosterButton.boosterSelectedId).localization_description]); });
        words.Add("LifesCount", () => { return(ProfileAssistant.main.local_profile["life"].ToString()); });
        words.Add("SpinCost", () => { return(SpinWheel._spinCost.ToString()); });
        words.Add("LastReward", () => { return(SpinWheel.lastReward); });
        words.Add("ColorCollections", () => {
            string r = "";
            foreach (int i in SessionAssistant.main.countOfEachTargetCount)
            {
                r += (r.Length > 0 ? "," : "") + Mathf.Max(0, i).ToString();
            }
            return(r);
        });
        words.Add("NextLifeTimer", () => {
            if (ProfileAssistant.main.local_profile["life"] >= ProjectParameters.main.lifes_limit)
            {
                return(LocalizationAssistant.main["full"]);
            }
            System.TimeSpan span = ProfileAssistant.main.local_profile.next_life_time - System.DateTime.Now;
            if (span.TotalSeconds <= 0)
            {
                return("00:00");
            }
            return(string.Format("{0:00}:{1:00}", span.Minutes, span.Seconds));
        });

        initialized = true;
    }
示例#3
0
    IEnumerator DestroyChipRoutine()
    {
        if (jamType == "")
        {
            jamType = Jam.GetType(slot);
        }
        Jam.JamIt(slot, jamType);

        yield return(StartCoroutine(logic.Destroying()));

        if (!destroying)
        {
            yield break;
        }


        if (IsColored())
        {
            SessionAssistant.main.countOfEachTargetCount[id]--;
        }


        Destroy(gameObject);
    }
示例#4
0
    Slot FindTarget()
    {
        Slot result;

        switch (LevelProfile.main.target)
        {
        case FieldTarget.Block:
            Block[] blocks =
                Slot.all.Values.Where(x => x.block != null && x.block is Block && !targetStack.Contains(x))
                .Select(x => x.block as Block).ToArray();
            if (blocks.Length > 0)
            {
                result = blocks[Random.Range(0, blocks.Length)].slot;
                targetStack.Add(result);
                return(result);
            }
            break;

        case FieldTarget.Color:
        case FieldTarget.Jelly:
        case FieldTarget.None:
        case FieldTarget.Jam:
        case FieldTarget.SugarDrop: {
            List <Chip> chips = new List <Chip>(FindObjectsOfType <Chip>());
            chips = chips.FindAll(x => !x.busy).ToList();
            int         potential  = -1;
            int         z          = 0;
            List <Chip> resultChip = new List <Chip>();
            foreach (Chip c in chips)
            {
                if (c.chipType == "Ladybird" || !c.destroyable)
                {
                    continue;
                }
                if (c.destroying || !c.slot || targetStack.Contains(c.slot))
                {
                    continue;
                }
                z = c.GetPotencial();
                if (potential < z)
                {
                    resultChip.Clear();
                    potential = z;
                }
                if (potential == z)
                {
                    resultChip.Add(c);
                }
            }
            if (chip.jamType != "")
            {
                resultChip = resultChip.FindAll(x => Jam.GetType(x.slot) != chip.jamType).ToList();
            }
            if (resultChip.Count > 0)
            {
                result = resultChip[Random.Range(0, resultChip.Count)].slot;
                targetStack.Add(result);
                return(result);
            }
            break;
        }
        }

        Slot[] targets = Slot.all.Values.Where(x => !targetStack.Contains(x) && x != chip.slot && x.chip != null).ToArray();
        result = targets[Random.Range(0, targets.Length)];
        targetStack.Add(result);
        return(result);
    }