Example #1
0
    public bool CheckRoomSize(LastPoint _point, Dungeon _currentDungeon, Dungeon _nextDungeon)
    {
        RaycastHit[] hit;
        hit = Physics.BoxCastAll((_point.point.position + Vector3.up * _nextDungeon.size.y * 0.5f) + _point.ConvertVector3(), _nextDungeon.size * 0.5f, _point.ConvertVector3(),
                                 Quaternion.identity, _nextDungeon.GetSize(_point.direction) * 0.5f, LayerMask.GetMask("Room"));


        int cnt = 0;

        for (int i = 0; i < hit.Length; i++)
        {
            if (hit[i].collider.gameObject.GetComponent <Dungeon>() != _currentDungeon && hit[i].collider.gameObject.GetComponent <Dungeon>() != _nextDungeon)
            {
                ++cnt;
            }
        }


        //print("hit = " + cnt);

        if (cnt == 0)
        {
            return(false);
        }
        else
        {
            return(true);
        }

        //return Physics.BoxCast((_point.point.position + Vector3.up * _nextDungeon.size.y * 0.5f), _nextDungeon.size, _point.ConvertVector3(),
        //     Quaternion.identity, _currentDungeon.GetSize(_point.direction), LayerMask.GetMask("Room"));
    }
Example #2
0
 bool CheckLastPoint(int _index, LastPoint _point, Dungeon _currentDungeon, Dungeon _nextDungeon)
 {
     if (!FindIndex(_index))
     {
         if (!_point.CheckDir())
         {
             if (!FindDir(_point.direction))
             {
                 if (!currentDungeon.CheckRoomSize(_point, _currentDungeon, _nextDungeon))
                 {
                     return(false);
                 }
                 else
                 {
                     return(true);
                 }
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(true);
     }
 }
Example #3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Id != null ? Id.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (LastPoint != null ? LastPoint.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)State;
         return(hashCode);
     }
 }
Example #4
0
        /// <summary>
        /// Connect with flow edges to children points
        /// </summary>
        internal void Connect()
        {
            if (_isConnected)
            {
                throw new NotSupportedException("Cannot connect block twice");
            }

            _isConnected = true;

            foreach (var child in _childrenBlocks)
            {
                LastPoint.AddFlowChild(child.FirstPoint);
            }
        }
Example #5
0
    // Rewinds the positions uses LastPoint to store Vector3 and Quartion positions
    public void Rewind()
    {
        Debug.Log("Rewind Started");
        Time.timeScale = 4.5f;
        if (positionData.Count > 0)
        {
            LastPoint lastPosition = positionData[0];
            transform.position = lastPosition.position;
            transform.rotation = lastPosition.rotation;
            positionData.RemoveAt(0);
        }

        else
        {
            StopRewind();
        }
    }
Example #6
0
        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            if (mouse_button == 1)
            {
                StrokeColor = PintaCore.Palette.PrimaryColor;
                FillColor   = PintaCore.Palette.SecondaryColor;
            }
            else if (mouse_button == 3)
            {
                StrokeColor = PintaCore.Palette.SecondaryColor;
                FillColor   = PintaCore.Palette.PrimaryColor;
            }
            else
            {
                LastPoint = point_empty;
                return;
            }

            // TODO: also multiply by pressure
            StrokeColor = new Color(StrokeColor.R, StrokeColor.G, StrokeColor.B,
                                    StrokeColor.A * active_brush.StrokeAlphaMultiplier);

            int x = (int)point.X;
            int y = (int)point.Y;

            if (LastPoint.Equals(point_empty))
            {
                LastPoint = new Point(x, y);
            }

            if (doc.Workspace.PointInCanvas(point))
            {
                surface_modified = true;
            }

            var surf            = doc.CurrentUserLayer.Surface;
            var invalidate_rect = Gdk.Rectangle.Zero;
            var brush_width     = BrushWidth;

            Surface = surf;

            using (Drawable = new Context(surf)) {
                Drawable.AppendPath(doc.Selection.SelectionPath);
                Drawable.FillRule = FillRule.EvenOdd;
                Drawable.Clip();

                Drawable.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;
                Drawable.LineWidth = brush_width;
                Drawable.LineJoin  = LineJoin.Round;
                Drawable.LineCap   = BrushWidth == 1 ? LineCap.Butt : LineCap.Round;
                Drawable.SetSourceColor(StrokeColor);

                invalidate_rect = active_brush.DoMouseMove(Drawable, StrokeColor, Surface,
                                                           x, y, LastPoint.X, LastPoint.Y);
            }

            Surface  = null;
            Drawable = null;

            // If we draw partially offscreen, Cairo gives us a bogus
            // dirty rectangle, so redraw everything.
            if (doc.Workspace.IsPartiallyOffscreen(invalidate_rect))
            {
                doc.Workspace.Invalidate();
            }
            else
            {
                doc.Workspace.Invalidate(doc.ClampToImageSize(invalidate_rect));
            }

            LastPoint = new Point(x, y);
        }
Example #7
0
 public LastPoint(LastPoint _point)
 {
     point     = _point.point;
     direction = _point.direction;
 }
Example #8
0
        /// <summary>
        /// Append program point as last of contained points
        /// Is connected with flow edge to LastPoint
        /// </summary>
        /// <param name="programPoint">Appended point</param>
        internal void AppendFlow(ProgramPointBase programPoint)
        {
            LastPoint.AddFlowChild(programPoint);

            _containedPoints.Add(programPoint);
        }
Example #9
0
    IEnumerator MakeDungeon(bool isFirst)
    {
        isMakeRun = true;
        bool       isEnd = true;
        bool       isFail = false;
        int        cnt = 0, infinityLoopCheck = 0, totalCnt = 0;
        GameObject map;

        while (isEnd)
        {
RETRY:

            dungeonPointIndexList.Clear();
            ++infinityLoopCheck;

            if (infinityLoopCheck > 100)
            {
                isEnd = false;
                print("경우의 수가 존재하지 않습니다. 루프를 중지합니다.");
                if (totalCnt == 0)
                {
                    print("방이 하나도 생성되지 못합니다.");
                }
                break;
            }

            isFail   = false;
            map      = Instantiate(dungeonList[Random.Range(0, dungeonList.Count)]);
            map.name = "Room" + totalCnt;
            map.SetActive(false);

            if (currentDungeon != null)
            {
                int       index     = 0;
                int       loopCnt   = 0;
                LastPoint lastPoint = null;
                do
                {
                    if (loopCnt > 0)
                    {
                        dungeonPointIndexList.Add(index);
                    }

                    if (loopCnt > currentDungeon.lastPointList.Count)
                    {
                        if (stackDungeon.Count > 1)
                        {
                            stackDungeon.Remove(currentDungeon);
                            Destroy(currentDungeon.gameObject);
                            currentDungeon = stackDungeon[stackDungeon.Count - 1];
                            currentMap     = currentDungeon.gameObject;
                            dungeonPointIndexList.Clear();
                            --cnt;
                            loopCnt = 0;
                        }
                        else
                        {
                            isFail = true;
                            break;
                        }
                    }
                    index     = Random.Range(0, currentDungeon.lastPointList.Count);
                    lastPoint = currentDungeon.lastPointList[index];
                    ++loopCnt;
                } while (CheckLastPoint(index, lastPoint, currentDungeon, map.GetComponent <Dungeon>())); //


                if (!map.GetComponent <Dungeon>().isAlreadyDir(lastPoint.direction) || isFail)
                {
                    Destroy(map);
                    goto RETRY;
                }

                if (isEnd)
                {
                    map.transform.position = currentMap.transform.position + lastPoint.ConvertVector3() * (currentDungeon.GetSize(lastPoint.direction) * 0.5f + map.GetComponent <Dungeon>().GetSize(lastPoint.direction) * 0.5f);
                    map.GetComponent <Dungeon>().FindLastPointAndRemove(lastPoint.direction);
                    lastPoint.Remove();

                    queueDir.Add(lastPoint.direction);

                    if (queueDir.Count > 0)
                    {
                        queueDir.RemoveAt(0);
                    }
                }
            }

            if (isEnd)
            {
                currentDungeon = map.GetComponent <Dungeon>();
                currentMap     = map;
                stackDungeon.Add(currentDungeon);
            }

            ++cnt;
            ++totalCnt;
            infinityLoopCheck = 0;
            map.SetActive(true);

            if (cnt > maxRooms - 1)
            {
                isEnd = false;
                print("is all made");
            }

            yield return(new WaitForFixedUpdate());
        }

        stackDungeon.Clear();

        if (isFirst)
        {
            PlayGame();
        }


        isMakeRun = false;
    }