// Update is called once per frame
        void Update()
        {
            if (!_viewMap._solving && (0 <= Input.mousePosition.x && Input.mousePosition.x < _ScreenSize.x) && (0 <= Input.mousePosition.y && Input.mousePosition.y < _ScreenSize.y))
            {
                MapPosition mousePose = GetMapPostionOfScreenPoint(Input.mousePosition);

                if (Input.GetMouseButtonDown(2))
                {
                    if (_map._livingCells.Contains(mousePose))
                    {
                        addLivingCells = false;
                    }
                    else
                    {
                        addLivingCells = true;
                    }
                }
                else if (Input.GetMouseButton(2))
                {
                    bool contains = _map._livingCells.Contains(mousePose);
                    if (!addLivingCells && contains)
                    {
                        _map._livingCells.Remove(mousePose);
                    }
                    else if (addLivingCells && !contains)
                    {
                        _map._livingCells.Add(mousePose);
                    }
                    _viewMap.Reset();
                }
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                if (_viewMap._solving)
                {
                    Debug.Log("StopSolving");
                    _viewMap.StopSolving();
                }
                else
                {
                    Debug.Log("StartSolving");
                    _viewMap.StartSolving();
                }
            }
            else if (Input.GetKeyDown(KeyCode.R))
            {
                if (_viewMap._solving)
                {
                    Debug.Log("StopSolving");
                    _viewMap.StopSolving();
                }
                Debug.Log("Reset");
                _viewMap.Reset();
            }
        }
Exemplo n.º 2
0
        public override bool Equals(System.Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            MapPosition c = obj as MapPosition;

            if ((System.Object)c == null)
            {
                return(false);
            }

            return(_x == c._x && _y == c._y);
        }