Ejemplo n.º 1
0
        private OpenDirections ValidateOpenDirections(MazeUnit u)
        {
            var children = u.transform.AllChildren().Where(
                go => !(go.Equals(MazeUnit.TOP) || go.Equals(MazeUnit.FLOOR)));

            OpenDirections waysOpen = OpenDirections.None;

            foreach (var item in children)
            {
                if (item.name.Equals(MazeUnit.NORTH) && !item.activeSelf)
                {
                    waysOpen |= OpenDirections.North;
                }

                if (item.name.Equals(MazeUnit.SOUTH) && !item.activeSelf)
                {
                    waysOpen |= OpenDirections.South;
                }

                if (item.name.Equals(MazeUnit.WEST) && !item.activeSelf)
                {
                    waysOpen |= OpenDirections.West;
                }

                if (item.name.Equals(MazeUnit.EAST) && !item.activeSelf)
                {
                    waysOpen |= OpenDirections.East;
                }
            }

            return(waysOpen);
        }
Ejemplo n.º 2
0
        public virtual void Close(OpenDirections direction)
        {
            var directionName = Enum.GetName(typeof(OpenDirections), direction);

            transform.FindChild(directionName).gameObject.SetActive(true);

            WaysOpen &= ~direction;
        }
Ejemplo n.º 3
0
        public override void Close(OpenDirections direction)
        {
            var directionName = Enum.GetName(typeof(OpenDirections), direction);

            FadingTarget = GetTargetMaterial(directionName);
            targetState  = 1;
            FadingStep  *= -1;
            StartCoroutine(Fade());
        }
Ejemplo n.º 4
0
 private void Toogle(ObjectHideOut hideOut, OpenDirections direction)
 {
     if (hideOut.IsOpen(Enum.GetName(typeof(OpenDirections), direction)))
     {
         hideOut.Close(direction);
     }
     else
     {
         hideOut.Open(direction);
     }
 }
Ejemplo n.º 5
0
        public void ToggleLightDirection(OpenDirections direction)
        {
            string directionName = Enum.GetName(typeof(OpenDirections), direction);

            var target = this.transform.FindChild(directionName);

            if (target == null)
            {
                Debug.Assert(target != null, string.Format("This component should have an child with the name: {0}", target));
                return;
            }

            bool state = target.gameObject.activeSelf;

            target.gameObject.SetActive(!state);
        }
Ejemplo n.º 6
0
        public virtual void Open(OpenDirections direction)
        {
            var directionName = Enum.GetName(typeof(OpenDirections), direction);

            var expectedChild = transform.FindChild(directionName);

            if (expectedChild != null)
            {
                expectedChild.gameObject.SetActive(false);
            }
            else
            {
                Debug.LogError(string.Format("Children with name {0} expected but not found!", directionName));
            }

            WaysOpen |= direction;
        }
Ejemplo n.º 7
0
        public FabButton SetOpenDirection(OpenDirections openDirection)
        {
            var mainButtonView = (UIView)_switchableUIView;

            _stackView.ClearConstraints();

            _stackView.TranslatesAutoresizingMaskIntoConstraints = false;
            _stackView.CenterXAnchor.ConstraintEqualTo(mainButtonView.CenterXAnchor).Active = true;

            switch (openDirection)
            {
            case OpenDirections.Top:
                _stackView.BottomAnchor.ConstraintEqualTo(mainButtonView.TopAnchor, -SpaceBetweenMainButtonAndActionItems).Active = true;
                break;

            case OpenDirections.Bottom:
                _stackView.TopAnchor.ConstraintEqualTo(mainButtonView.BottomAnchor, SpaceBetweenMainButtonAndActionItems).Active = true;
                break;
            }

            return(this);
        }
Ejemplo n.º 8
0
        private StringBuilder AppendMazeMatrix(beMobileMaze maze)
        {
            var traversal = new MazeGridTraversal(maze);

            StringBuilder mazeAsTextMatrix = new StringBuilder();

            var mazeID = string.Format("Maze: {0} matlab matrix:\t", maze.name);

            mazeAsTextMatrix.Append(mazeID);

            mazeAsTextMatrix.Append(" [ ");

            traversal.travers(
                s => {
                string content = "0";

                mazeAsTextMatrix.Append(content);

                if (s.ColumnsLeft > 0)
                {
                    mazeAsTextMatrix.Append(", ");
                }

                if (s.ColumnsLeft == 0)
                {
                    mazeAsTextMatrix.Append("; ");
                }
            },
                (u, s) => {
                OpenDirections openDirectionsCode = u.WaysOpen;

                OpenDirections directions = ValidateOpenDirections(u);

                if (openDirectionsCode != directions)
                {
                    Debug.Log(u.GridID + "Has wrong directions code - Correct during export!");
                }

                string content = ((int)openDirectionsCode).ToString();

                mazeAsTextMatrix.Append(content);

                if (s.ColumnsLeft > 0)
                {
                    mazeAsTextMatrix.Append(", ");
                }

                if (s.ColumnsLeft == 0)
                {
                    mazeAsTextMatrix.Append("; ");
                }
            });

            #region original
            //for (int y_i = maze.Rows - 1; y_i >= 0; y_i--)
            //{
            //    StringBuilder rowAsLine = new StringBuilder();

            //    for (int x_i = 0; x_i < maze.Columns; x_i++)
            //    {
            //        if (maze[x_i, y_i] == null)
            //        {
            //            rowAsLine.Append("0");
            //        }
            //        else
            //        {
            //            rowAsLine.Append("1");
            //        }

            //        if (x_i < maze.Columns - 1)
            //            rowAsLine.Append(", ");

            //    }

            //    if (y_i != 0)
            //    {
            //        rowAsLine.Append("; ");

            //    }


            //    mazeAsTextMatrix.Append(rowAsLine.ToString());
            //}
            #endregion

            mazeAsTextMatrix.Append(" ]");
            return(mazeAsTextMatrix);
        }
Ejemplo n.º 9
0
 public static bool IsSet(OpenDirections value, OpenDirections flag)
 {
     return((value & flag) == flag);
 }
Ejemplo n.º 10
0
 public void OpenTo(Direction direction)
 {
     OpenDirections = OpenDirections.And(direction).Intersect(ValidDirections);
 }
Ejemplo n.º 11
0
 public void CloseTo(Direction direction)
 {
     OpenDirections = OpenDirections.Except(direction);
 }
Ejemplo n.º 12
0
        public override void Close(OpenDirections direction)
        {
            base.Close(direction);

            ConfigureDoorElementRotation();
        }