Esempio n. 1
0
    public void Init()
    {
        //init starinfo
        for (int ct = 0; ct < Random.Range(6 - difficult, 8 - difficult); ct++)
        {
            starInfos.Add(new StarInfo(StarType.Check, ct < 3));
        }
        starInfos.Add(new StarInfo(StarType.End));

        //init log
        if (SYS_Logger.Direct.logging)
        {
            foreach (StarInfo starInfo in starInfos)
            {
                Debug.LogWarning("[Gen]BayerID : " + starInfo.sID + " , BayerName : " + starInfo.sName + " , Type : " + starInfo.sType.ToString() + " , Location : " + starInfo.sPos);
            }
        }

        //gen star
        foreach (StarInfo starInfo in starInfos)
        {
            StarObject    objGen  = Instantiate(starPfb).GetComponent <StarObject>();
            RectTransform objRect = objGen.GetComponent <RectTransform>();
            objGen.transform.SetParent(transform);
            objGen.Regist(starInfo);
            objRect.anchoredPosition3D = starInfo.sPos;
            if (starInfo.sType == StarType.End)
            {
                objGen.sRawImage.GetComponent <RectTransform>().sizeDelta = new Vector2(80, 80);
            }
            objGen.sRawImage.color = starInfo.sColor;
            objRect.localScale     = Vector3.one;
        }
    }
    public IEnumerator ProcessTwitchCommand(string command)
    {
        if (!activated)
        {
            yield return("sendtochat {0}, !{1} not activated");

            yield break;
        }
        command = command.Trim().ToLower();
        if (command == "outskirts")
        {
            IEnumerable <StarObject> stars = starByName.Values.Where(s => s.cell.adjacentStars.Count == 1 && s.cell.name != MapGenerator.SUN_NAME);
            yield return(null);

            if (stars.Count() > 3)
            {
                yield return("waiting music");
            }
            foreach (StarObject star in stars)
            {
                star.GetComponent <KMSelectable>().Highlight.transform.GetChild(0).gameObject.SetActive(true);
                star.Highlight();
                yield return(new WaitForSeconds(5f));

                star.GetComponent <KMSelectable>().Highlight.transform.GetChild(0).gameObject.SetActive(false);
                star.RemoveHighlight();
                yield return(null);

                if (TwitchShouldCancelCommand)
                {
                    yield return("cancelled");

                    yield break;
                }
            }
            yield break;
        }
        if (command.StartsWith("trace "))
        {
            string starName = command.Skip(6).Join("").Trim();
            if (starName == MapGenerator.SUN_NAME)
            {
                yield break;
            }
            if (
                !StarData.HasLowerCasedStarName(starName) ||
                !starByName.ContainsKey(StarData.LowerCasedStarNameToActual(starName))
                )
            {
                yield return("sendtochat {0}, !{1} " + string.Format("Star \"{0}\" not found", starName));

                yield break;
            }
            StarObject target = starByName[StarData.LowerCasedStarNameToActual(starName)];
            yield return(null);

            if (target.cell.path.Count > 3)
            {
                yield return("waiting music");
            }
            foreach (MapGenerator.CellStar cell in target.cell.path)
            {
                StarObject star = starByName[cell.name];
                star.GetComponent <KMSelectable>().Highlight.transform.GetChild(0).gameObject.SetActive(true);
                star.Highlight();
                yield return(new WaitForSeconds(5f));

                star.GetComponent <KMSelectable>().Highlight.transform.GetChild(0).gameObject.SetActive(false);
                star.RemoveHighlight();
                yield return(null);

                if (TwitchShouldCancelCommand)
                {
                    yield return("cancelled");

                    yield break;
                }
            }
            yield break;
        }
        if (command.StartsWith("send "))
        {
            string[] starsName    = command.Split(' ').Skip(1).Where((n) => n.Length > 0).ToArray();
            string[] unknownStars = starsName.Where((s) => (
                                                        !StarData.HasLowerCasedStarName(s) || !starByName.ContainsKey(StarData.LowerCasedStarNameToActual(s))
                                                        )).ToArray();
            if (unknownStars.Length > 0)
            {
                yield return("sendtochat {0}, !{1} " + string.Format(
                                 "Stars {0} not found",
                                 unknownStars.Select((s) => string.Format("\"{0}\"", s)).Join(", ")
                                 ));

                yield break;
            }
            foreach (StarObject star in starsName.Select((s) => starByName[StarData.LowerCasedStarNameToActual(s)]))
            {
                bool success = OnStarPressed(star);
                if (!success)
                {
                    break;
                }
            }
            yield return(new KMSelectable[] { });

            yield break;
        }
        if (command.StartsWith("look "))
        {
            string[] starsName    = command.Split(' ').Skip(1).Where((n) => n.Length > 0).ToArray();
            string[] unknownStars = starsName.Where((s) => (
                                                        !StarData.HasLowerCasedStarName(s) || !starByName.ContainsKey(StarData.LowerCasedStarNameToActual(s))
                                                        )).ToArray();
            if (unknownStars.Length > 0)
            {
                yield return("sendtochat {0}, !{1} " + string.Format(
                                 "Stars {0} not found",
                                 unknownStars.Select((s) => string.Format("\"{0}\"", s)).Join(", ")
                                 ));

                yield break;
            }
            yield return(null);

            if (starsName.Count() > 3)
            {
                yield return("waiting music");
            }
            foreach (string starName in starsName)
            {
                StarObject star = starByName[StarData.LowerCasedStarNameToActual(starName)];
                star.GetComponent <KMSelectable>().Highlight.transform.GetChild(0).gameObject.SetActive(true);
                star.Highlight();
                yield return(new WaitForSeconds(5f));

                star.GetComponent <KMSelectable>().Highlight.transform.GetChild(0).gameObject.SetActive(false);
                star.RemoveHighlight();
                yield return(null);

                if (TwitchShouldCancelCommand)
                {
                    yield return("cancelled");

                    yield break;
                }
            }
            yield break;
        }
        yield return(null);
    }