Beispiel #1
0
        private StateMachine VisibleAreaAnalysis(GameSession gameSession)
        {
            var          visibleArea = VisibleArea.Replace("\r\n", " ").Split();
            StateMachine resultState;

            if (visibleArea.Take(visibleArea.Length - 1).All(line => line == voidLine))
            {
                MoveInDirection(gameSession, 4, TypeMove.Down);
            }
            visibleArea = VisibleArea.Replace("\r\n", " ").Split();
            var leftPartArea  = visibleArea.Select(line => line.Substring(0, 4)).ToArray();
            var rightPartArea = visibleArea.Select(line => line.Substring(7)).ToArray();

            if (rightPartArea.All(line => line == "0000"))
            {
                resultState = StateMachine.MoveLeft;
            }
            else if (leftPartArea.All(line => line == "0000"))
            {
                resultState = StateMachine.MoveRight;
            }
            else
            {
                resultState = StateMachine.GoToTopPartOfWord;
            }
            return(resultState);
        }
Beispiel #2
0
        public void Print()
        {
            int offsetLeft = 2;
            int offsetTop  = 2 * BandNr + 2;

            string s  = VisibleArea.Replace('B', ' ');
            int    i  = (int)Math.Floor(Conf.VisibleBandSize / 2f);
            string s1 = s.Substring(0, i);
            string s2 = s.Substring(i, 1);
            string s3 = s.Substring(i + 1);

            ConsoleColor b = Console.BackgroundColor;
            ConsoleColor f = Console.ForegroundColor;

            Console.BackgroundColor = ConsoleColor.Blue;
            Console.ForegroundColor = ConsoleColor.White;

            Tools.Write(offsetLeft, offsetTop, s1);

            Console.BackgroundColor = ConsoleColor.Yellow;
            Console.ForegroundColor = ConsoleColor.Black;

            Tools.Write(offsetLeft + s1.Length, offsetTop, s2);

            Console.BackgroundColor = ConsoleColor.Blue;
            Console.ForegroundColor = ConsoleColor.White;

            Tools.Write(offsetLeft + s1.Length + s2.Length, offsetTop, s3);

            Console.BackgroundColor = b;
            Console.ForegroundColor = f;
        }
    public Rect VisibleRect(Camera camera)
    {
        VisibleArea va = MapLayout.CalcRelativeVisibleArea(camera);

        return(new Rect(camera.transform.localPosition.x - va.farHalfWidth,
                        camera.transform.localPosition.z + va.near,
                        va.farHalfWidth * 2f,
                        va.far - va.near));
    }
    public static VisibleArea CalcRelativeVisibleArea(Camera camera)
    {
        float halfViewHeight = Screen.height / 2f;
        float halfViewWidth  = halfViewHeight * camera.aspect;

        float   vFov            = camera.fieldOfView * Mathf.Deg2Rad;
        float   z               = halfViewHeight / Mathf.Tan(vFov / 2f);
        Vector3 localBottomLeft = new Vector3(-halfViewWidth, -halfViewHeight, z);
        Vector3 localTopLeft    = new Vector3(-halfViewWidth, halfViewHeight, z);

        Matrix4x4 matrCamera      = camera.transform.localToWorldMatrix.RS();
        Vector3   worldBottomLeft = matrCamera.MultiplyPoint(localBottomLeft);
        Vector3   worldTopLeft    = matrCamera.MultiplyPoint(localTopLeft);

        Ray rayBottomLeft = new Ray(Vector3.zero, worldBottomLeft);
        Ray rayTopLeft    = new Ray(Vector3.zero, worldTopLeft);

        Plane plane = new Plane(Vector3.up, new Vector3(0, -camera.transform.localPosition.y, 0));
        float dis   = 0;

        Vector3 plBottomLeft;
        Vector3 plTopLeft;

        if (plane.Raycast(rayBottomLeft, out dis))
        {
            plBottomLeft = rayBottomLeft.GetPoint(dis);
        }
        else
        {
            plBottomLeft = Vector3.zero;
            Debug.LogError("rayBottomLeft can't cast ");
        }

        if (plane.Raycast(rayTopLeft, out dis))
        {
            plTopLeft = rayTopLeft.GetPoint(dis);
        }
        else
        {
            plTopLeft = Vector3.zero;
            Debug.LogError("plTopLeft can't cast ");
        }

        VisibleArea re = new VisibleArea();

        re.near          = plBottomLeft.z;
        re.far           = plTopLeft.z;
        re.nearHalfWidth = -plBottomLeft.x;
        re.farHalfWidth  = -plTopLeft.x;

        return(re);
    }
Beispiel #5
0
    public void Initialize(AppConfig config)
    {
        if (map != null)
        {
            map.Dispose();
        }

        fileName      = config.MapFileName;
        userDragSpeed = config.UserDragSpeed;

        server = new TileServer(config.MapSize.x, config.MapSize.y, prefab.GetPrefabCount(), config.RefreshIntervalSeconds, networkLatency);

        ITileFactory factory;

        if (config.RefreshTiles)
        {
            factory = new TimedProxyTileFactory(server, config.RefreshIntervalSeconds);
        }
        else
        {
            factory = new ProxyTileFactory(server);
        }

        ITileLoadingStrategy tileLoadingStrategy;

        if (config.LoadPotentialTiles)
        {
            tileLoadingStrategy = new EagerLoadingStrategy();
        }
        else
        {
            tileLoadingStrategy = new LazyLoadingStrategy();
        }

        storage = new TileStorage(factory);

        Map simpleMap = new Map(storage.Load(fileName), factory, tileLoadingStrategy, prefab, config.MapSize.x, config.MapSize.y);

        if (config.LimitTilesCount)
        {
            map = new LimitedMap(simpleMap, config.MaxTilesCount);
        }
        else
        {
            map = simpleMap;
        }

        area = new VisibleArea(map);

        initialized = true;
    }
Beispiel #6
0
        private void MoveToStart(GameSession gameSession)
        {
            var visibleArea = VisibleArea.Replace("\r\n", " ").Split()
                              .Select(line => line.Substring(0, 4))
                              .Take(4)
                              .ToArray();

            while (!visibleArea.All(line => line == "0000"))
            {
                VisibleArea = gameSession.Move(TypeMove.Left);
                NumberMoveOnLeft++;
                visibleArea = VisibleArea.Replace("\r\n", " ").Split()
                              .Select(line => line.Substring(0, 4))
                              .Take(4)
                              .ToArray();
            }
        }
Beispiel #7
0
        private Tuple <TypeMove, int> RecognizePosition()
        {
            var      visibleArea   = VisibleArea.Replace("\r\n", " ").Split();
            var      countVoidLine = 0;
            TypeMove typeMove;

            if (visibleArea[0] == voidLine)
            {
                typeMove = TypeMove.Down;
                countVoidLine++;
                for (int i = 1; i < visibleArea.Length; i++)
                {
                    if (visibleArea[i] == voidLine)
                    {
                        countVoidLine++;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else if (visibleArea[visibleArea.Length - 1] == voidLine)
            {
                typeMove = TypeMove.Up;
                countVoidLine++;
                for (int i = visibleArea.Length - 2; i > 0; i--)
                {
                    if (visibleArea[i] == voidLine)
                    {
                        countVoidLine++;
                    }
                    else
                    {
                        break;
                    }
                }
                countVoidLine += 2;
            }
            else
            {
                typeMove = TypeMove.Up;
            }
            return(Tuple.Create(typeMove, countVoidLine));
        }
Beispiel #8
0
        private static void Person_PropertyChanged(object sender, PropertyChangedEventArgs e, Game game,
                                                   ScrollViewer scrollView)
        {
            for (var i = 1; i <= game.VisibleArea.BlockSize.Width; i++)
            {
                Canvas.SetLeft(game.Person.Control, game.Person.Position.Point.X * i);
            }

            for (var i = 1; i <= game.VisibleArea.BlockSize.Height; i++)
            {
                Canvas.SetTop(game.Person.Control, game.Person.Position.Point.Y * i);
            }

            game.Person.Control.Width  = game.VisibleArea.BlockSize.Height * game.Person.Position.Size.Width;
            game.Person.Control.Height = game.VisibleArea.BlockSize.Width * game.Person.Position.Size.Height;

            VisibleArea.ScrollToPlayer(game, scrollView);
        }
Beispiel #9
0
        private void UpdatePainting()
        {
            if (childrenRequireUpdate)
            {
                foreach (var child in children)
                {
                    child.UpdatePainting();
                }
            }

            if (requiresPaintingUpdate)
            {
                requiresPaintingUpdate = false;

                if (PaintedArea != Area || PaintedVisibleArea != VisibleArea)
                {
                    if (RepaintMode == ControlRepaintMode.Never)
                    {
                        // nothing to do
                    }
                    else if (RepaintMode == ControlRepaintMode.IncrementalGrowth && PaintedArea.Location == Area.Location)
                    {
                        foreach (var rect in PaintedVisibleArea.Exclude(VisibleArea))
                        {
                            Window?.Invalidate(rect);
                        }

                        foreach (var rect in VisibleArea.Exclude(PaintedVisibleArea))
                        {
                            Window?.Invalidate(rect);
                        }
                    }
                    else
                    {
                        Window?.Invalidate(PaintedVisibleArea);
                        Window?.Invalidate(VisibleArea);
                    }

                    PaintedArea        = Area;
                    PaintedVisibleArea = VisibleArea;
                }
            }
        }
Beispiel #10
0
        private void MoveToTopPartWord(GameSession gameSession)
        {
            var resultRec     = RecognizePosition();
            var typeMove      = resultRec.Item1;
            var countVoidLine = resultRec.Item2;

            if (countVoidLine == 0)
            {
                var visibleArea = VisibleArea.Replace("\r\n", " ").Split();
                while (visibleArea[0] != voidLine)
                {
                    MoveInDirection(gameSession, 1, TypeMove.Up);
                    visibleArea = VisibleArea.Replace("\r\n", " ").Split();
                }
                MoveInDirection(gameSession, 1, TypeMove.Down);
            }
            else
            {
                MoveInDirection(gameSession, countVoidLine, typeMove);
            }
        }
Beispiel #11
0
    public void Initialize(AppConfig config)
    {
        if (map != null) {
            map.Dispose ();
        }

        fileName = config.MapFileName;
        userDragSpeed = config.UserDragSpeed;

        server = new TileServer (config.MapSize.x, config.MapSize.y, prefab.GetPrefabCount (), config.RefreshIntervalSeconds, networkLatency);

        ITileFactory factory;
        if (config.RefreshTiles) {
            factory = new TimedProxyTileFactory (server, config.RefreshIntervalSeconds);
        } else {
            factory = new ProxyTileFactory (server);
        }

        ITileLoadingStrategy tileLoadingStrategy;
        if (config.LoadPotentialTiles) {
            tileLoadingStrategy = new EagerLoadingStrategy ();
        } else {
            tileLoadingStrategy = new LazyLoadingStrategy ();
        }

        storage = new TileStorage (factory);

        Map simpleMap = new Map (storage.Load (fileName), factory, tileLoadingStrategy, prefab, config.MapSize.x, config.MapSize.y);

        if (config.LimitTilesCount) {
            map = new LimitedMap (simpleMap, config.MaxTilesCount);
        } else {
            map = simpleMap;
        }

        area = new VisibleArea (map);

        initialized = true;
    }
Beispiel #12
0
        private string RecognizeLetter(GameSession gameSession, TypeMove typeMove)
        {
            var letter             = "";
            var visiblePartLetter1 = VisibleArea.Replace("\r\n", " ").Split()
                                     .Select(line => line.Substring(4))
                                     .ToArray();

            MoveInDirection(gameSession, 2, typeMove);
            var visiblePartLetter2 = VisibleArea.Replace("\r\n", " ").Split()
                                     .Select(line => line.Substring(4));

            visiblePartLetter2 = typeMove == TypeMove.Down ? visiblePartLetter2.Skip(3).ToArray():
                                 visiblePartLetter2.Take(2).ToArray();
            var visibleLetter = typeMove == TypeMove.Down ? visiblePartLetter1.Concat(visiblePartLetter2).ToArray():
                                visiblePartLetter2.Concat(visiblePartLetter1).ToArray();

            letter += visibleLetter[0];
            for (int i = 1; i < visibleLetter.Length; i++)
            {
                letter += ' ' + visibleLetter[i];
            }
            return(letter);
        }
Beispiel #13
0
 public MoveDirection GetMoveDirection(VisibleArea visibleArea)
 {
     throw new System.NotImplementedException();
 }
Beispiel #14
0
 public MoveDirection GetMoveDirection(VisibleArea visibleArea)
 {
     return MoveDirection.Forward;
 }
Beispiel #15
0
 public bool IsVisible(Rectangle position)
 {
     return(VisibleArea.Intersects(position));
 }
Beispiel #16
0
 public bool IsVisible(Vector2 position)
 {
     return(VisibleArea.Contains(position));
 }
Beispiel #17
0
 public TooltipManager(LeasingChart chart)
 {
     m_chart     = chart;
     VisibleArea = new VisibleArea();
 }
        private void ContentGUI()
        {
            GUILayout.BeginArea(HierarchyArea);
            {
                if (UnityEngine.Event.current.type == EventType.ScrollWheel)
                {
                    ScrollInfo.currentScroll.x += UnityEngine.Event.current.delta.x;
                    ScrollInfo.currentScroll.y += 2 * UnityEngine.Event.current.delta.y;
                    float widthOfContent = ScrubArea.x + (CurrentSequence.Duration / ZoomInfo.meaningOfEveryMarker * ZoomInfo.currentXMarkerDist);
                    ScrollInfo.currentScroll.x = Mathf.Clamp(ScrollInfo.currentScroll.x, 0, widthOfContent);
                    UpdateCachedMarkerInformation();
                    UnityEngine.Event.current.Use();
                }
                GUILayout.BeginVertical();

                GUILayout.Box("", USEditorUtility.ContentBackground, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                if (UnityEngine.Event.current.type == EventType.Repaint)
                {
                    if (VisibleArea != GUILayoutUtility.GetLastRect())
                    {
                        VisibleArea = GUILayoutUtility.GetLastRect();
                        SequenceWindow.Repaint();
                    }
                }
                GUILayout.BeginArea(VisibleArea);

                GUILayout.BeginScrollView(ScrollInfo.currentScroll, GUIStyle.none, GUIStyle.none);

                GUILayout.BeginVertical();

                DrawSideBarAndTimeLines();

                GUILayout.EndVertical();
                if (UnityEngine.Event.current.type == EventType.Repaint)
                {
                    if (TotalArea != GUILayoutUtility.GetLastRect())
                    {
                        TotalArea = GUILayoutUtility.GetLastRect();
                        SequenceWindow.Repaint();
                    }
                }
                GUILayout.EndScrollView();

                GUILayout.EndArea();

                //  SelectionArea = VisibleArea;
                if (VisibleArea.Contains(UnityEngine.Event.current.mousePosition) || UnityEngine.Event.current.rawType == EventType.MouseUp || UnityEngine.Event.current.rawType == EventType.MouseDrag)
                {
                    HandleEvent(UnityEngine.Event.current.rawType == EventType.MouseUp ? UnityEngine.Event.current.rawType : UnityEngine.Event.current.type, UnityEngine.Event.current.button, UnityEngine.Event.current.mousePosition);
                }

                // Render our mouse drag box.
                if (IsBoxSelecting && HasStartedDrag)
                {
                    Vector2 mousePosition = UnityEngine.Event.current.mousePosition;
                    Vector2 origin        = DragStartPosition;
                    Vector2 destination   = mousePosition;

                    if (mousePosition.x < DragStartPosition.x)
                    {
                        origin.x      = mousePosition.x;
                        destination.x = DragStartPosition.x;
                    }

                    if (mousePosition.y < DragStartPosition.y)
                    {
                        origin.y      = mousePosition.y;
                        destination.y = DragStartPosition.y;
                    }

                    Vector2 mouseDelta = destination - origin;
                    SelectionArea = new Rect(origin.x, origin.y, mouseDelta.x, mouseDelta.y);
                    if (!EditorGUIUtility.isProSkin)
                    {
                        GUI.Box(SelectionArea, "", USEditorUtility.USeqSkin.box);
                    }
                    else
                    {
                        GUI.Box(SelectionArea, "");
                    }

                    SequenceWindow.Repaint();
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndArea();
        }