コード例 #1
0
 private void shuffleDeck(Section.AdjDirection[] deck, int times)
 {
     for (int i = 0; i < times; i++)
     {
         for (int j = 0; j < deck.Length; j++)
         {
             int swapIndex             = (int)(Random.value * deck.Length);
             Section.AdjDirection temp = deck[swapIndex];
             deck[swapIndex] = deck[j];
             deck[j]         = temp;
         }
     }
 }
コード例 #2
0
        private Section TryMakeSection(Region set, Section parent, Section.AdjDirection dir, Section.Archetype type = Section.Archetype.normal)
        {
            //check for overlap
            Collider2D col = Physics2D.OverlapPoint(Section.CalcDirection(dir, parent.IsFlipped()) + (Vector2)parent.transform.position, Physics2D.AllLayers);

            if (col != null)
            {
                //found overlap, set link to overlap
                Section r = col.GetComponent <Section> ();
                if (r.CheckSet(set))
                {
                    parent.SetAdjRoom(dir, r);
                }
                return(null);
            }

            //no overlap, make a new room
            Section child = parent.AddAdjRoom(dir);

            child.gameObject.name += " " + set.GetSectionCount();
            set.AddSection(child);
            return(child);
        }
コード例 #3
0
        private Section makeRoom(Section parent, Section.AdjDirection dir, Section.Archetype type = Section.Archetype.normal)
        {
            //check for overlap
            Collider2D col = Physics2D.OverlapPoint(Section.getDirection(dir) + (Vector2)parent.transform.position, Physics2D.AllLayers);

            if (col != null)
            {
                //found overlap, set link to overlap
                Section r = col.GetComponent <Section> ();
                if (r.checkSet(this))
                {
                    parent.setAdjRoom(dir, r);
                }
                return(null);
            }

            //no overlap, make a new room
            Section child = parent.addAdjRoom(dir);

            child.gameObject.name += " " + sections.Count;
            child.assignSet(this);
            sections.Add(child);
            return(child);
        }