Пример #1
0
    IEnumerator AttachTile(TileGroup tg)
    {
        //get ALL explored tilegroups in play
        var tilegroups = (from ch in chapterList
                          where ch.tileGroup.isExplored
                          select ch.tileGroup).ToList();

        bool success = false;

        if (previousGroup != null)
        {
            success = tg.AttachTo(previousGroup);
            //remove so not attempted again below
            tilegroups.Remove(previousGroup);
        }
        else
        {
            int       randIdx   = GlowEngine.GenerateRandomNumbers(tilegroups.Count)[0];
            TileGroup randGroup = tilegroups[randIdx];
            success = tg.AttachTo(randGroup);
            //remove so not attempted again below
            tilegroups.RemoveAt(randIdx);
        }

        if (!success)
        {
            Debug.Log("***SEARCHING for random tilegroup to attach to...");
            foreach (TileGroup _tg in tilegroups)
            {
                success = tg.AttachTo(_tg);
                if (success)
                {
                    break;
                }
            }
        }
        yield return(null);
    }
Пример #2
0
    public void BuildScenario()
    {
        ChapterManager   cm     = FindObjectOfType <ChapterManager>();
        List <TileGroup> TGList = new List <TileGroup>();

        //build ALL chapter tilegroups
        foreach (Chapter c in cm.chapterList)
        {
            //build the tiles in the tg
            TileGroup tg = c.tileGroup = CreateGroupFromChapter(c);
            if (tg == null)
            {
                Debug.Log("WARNING::BuildScenario::Chapter has no tiles: " + c.dataName);
                return;
            }

            TGList.Add(tg);
        }

        //all non-dynamic tiles excluding start
        foreach (TileGroup tg in TGList.Where(x => !x.GetChapter().isDynamic&& x.GetChapter().dataName != "Start"))
        {
            //try attaching tg to oldest tg already on board
            foreach (TileGroup tilegroup in TGList.Where(x => !x.GetChapter().isDynamic&& x.GUID != tg.GUID))                 //every non-dynamic
            {
                bool success = tg.AttachTo(tilegroup);
                if (success)
                {
                    Debug.Log("***ATTACHING " + tg.GetChapter().dataName + " to " + tilegroup.GetChapter().dataName);
                    GameObject fog = Instantiate(fogPrefab, transform);
                    FogData    fg  = fog.GetComponent <FogData>();
                    fg.chapterName         = tg.GetChapter().dataName;
                    fog.transform.position = tg.groupCenter.Y(.5f);
                    break;
                }
            }
        }
    }