Exemplo n.º 1
0
 public void CheckForSlicing(Vector2D start, Vector2D end)
 {
     if (!sideStatus.HasFlag(Sides.Top) && CheckIfLineIntersectsLine(start, end, DrawArea.TopLeft, DrawArea.TopRight))
     {
         sideStatus |= Sides.Top;
     }
     if (!sideStatus.HasFlag(Sides.Left) && CheckIfLineIntersectsLine(start, end, DrawArea.TopLeft, DrawArea.BottomLeft))
     {
         sideStatus |= Sides.Left;
     }
     if (!sideStatus.HasFlag(Sides.Bottom) && CheckIfLineIntersectsLine(start, end, DrawArea.BottomLeft, DrawArea.BottomRight))
     {
         sideStatus |= Sides.Bottom;
     }
     if (!sideStatus.HasFlag(Sides.Right) && CheckIfLineIntersectsLine(start, end, DrawArea.TopRight, DrawArea.BottomRight))
     {
         sideStatus |= Sides.Right;
     }
 }
Exemplo n.º 2
0
 public void StartAnimation(Sides availableMoves)
 {
     if (availableMoves == Sides.None)
     {
         return;
     }
     for (int i = 0; i < movesCount; i++)
     {
         if (availableMoves.HasFlag(movesSequence[i]))
         {
             ellipses[i] = new Ellipse()
             {
                 HorizontalAlignment = HorizontalAlignment.Left,
                 VerticalAlignment   = VerticalAlignment.Top,
                 Width           = ellipseSize, Height = ellipseSize,
                 Stroke          = new SolidColorBrush(ConstantColors.AvailableMovesEllipses),
                 StrokeThickness = _linesWidth / 2
             };
             _fieldGrid.Children.Add(ellipses[i]);
             ellipses[i].RenderTransform = new TranslateTransform();
             DoubleAnimation anim = new DoubleAnimation()
             {
                 From     = _x - halfEllipseSize,
                 To       = _x - halfEllipseSize + offsets[i].X,
                 Duration = TimeSpan.FromMilliseconds(Consts.EllipsesAnimationDuration)
             };
             Storyboard.SetTarget(anim, ellipses[i]);
             Storyboard.SetTargetProperty(anim, new PropertyPath("(UIElement.RenderTransform).X"));
             storyboard.Children.Add(anim);
             anim = new DoubleAnimation()
             {
                 From     = _y - halfEllipseSize,
                 To       = _y - halfEllipseSize + offsets[i].Y,
                 Duration = TimeSpan.FromMilliseconds(Consts.EllipsesAnimationDuration)
             };
             Storyboard.SetTarget(anim, ellipses[i]);
             Storyboard.SetTargetProperty(anim, new PropertyPath("(UIElement.RenderTransform).Y"));
             storyboard.Children.Add(anim);
         }
     }
     storyboard.Begin();
     storyboard.Completed += RaiseAnimationCompleted;
 }
Exemplo n.º 3
0
 private void RemoveExcessDetectionPoints()
 {
     if (!RequiredOpenSides.HasFlag(Sides.Top))
     {
         Destroy(TopPoint);
         TopPoint = null;
     }
     if (!RequiredOpenSides.HasFlag(Sides.Bot))
     {
         Destroy(BotPoint);
         BotPoint = null;
     }
     if (!RequiredOpenSides.HasFlag(Sides.Right))
     {
         Destroy(RightPoint);
         RightPoint = null;
     }
     if (!RequiredOpenSides.HasFlag(Sides.Left))
     {
         Destroy(LeftPoint);
         LeftPoint = null;
     }
 }
Exemplo n.º 4
0
        public static void CreateCube(SurfaceTool st, float size, Vector3 position, Sides sides)
        {
            if (sides.HasFlag(Sides.North) ||
                sides.HasFlag(Sides.East) ||
                sides.HasFlag(Sides.South) ||
                sides.HasFlag(Sides.West))
            {
                Color white = new Color(1f, 1f, 1f, 1f);

                Vector3[] vertices = GetVerticesForCell(size, position);

                if (sides.HasFlag(Sides.North))
                {
                    st.AddUv(new Vector2(1, 1));
                    st.AddNormal(North);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_NW]);
                    st.AddUv(new Vector2(0, 0));
                    st.AddNormal(North);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NE]);
                    st.AddUv(new Vector2(1, 0));
                    st.AddNormal(North);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NW]);

                    st.AddUv(new Vector2(1, 1));
                    st.AddNormal(North);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_NW]);
                    st.AddUv(new Vector2(0, 1));
                    st.AddNormal(North);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_NE]);
                    st.AddUv(new Vector2(0, 0));
                    st.AddNormal(North);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NE]);
                }

                if (sides.HasFlag(Sides.East))
                {
                    st.AddUv(new Vector2(0, 0));
                    st.AddNormal(East);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_SE]);
                    st.AddUv(new Vector2(1, 0));
                    st.AddNormal(East);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NE]);
                    st.AddUv(new Vector2(0, 1));
                    st.AddNormal(East);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SE]);

                    st.AddUv(new Vector2(1, 0));
                    st.AddNormal(East);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NE]);
                    st.AddUv(new Vector2(1, 1));
                    st.AddNormal(East);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_NE]);
                    st.AddUv(new Vector2(0, 1));
                    st.AddNormal(East);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SE]);
                }

                if (sides.HasFlag(Sides.South))
                {
                    st.AddUv(new Vector2(0, 0));
                    st.AddNormal(South);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_SW]);
                    st.AddUv(new Vector2(1, 0));
                    st.AddNormal(South);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_SE]);
                    st.AddUv(new Vector2(0, 1));
                    st.AddNormal(South);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SW]);

                    st.AddUv(new Vector2(1, 0));
                    st.AddNormal(South);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_SE]);
                    st.AddUv(new Vector2(1, 1));
                    st.AddNormal(South);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SE]);
                    st.AddUv(new Vector2(0, 1));
                    st.AddNormal(South);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SW]);
                }

                if (sides.HasFlag(Sides.West))
                {
                    st.AddUv(new Vector2(1, 1));
                    st.AddNormal(West);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SW]);
                    st.AddUv(new Vector2(0, 0));
                    st.AddNormal(West);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NW]);
                    st.AddUv(new Vector2(1, 0));
                    st.AddNormal(West);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_SW]);

                    st.AddUv(new Vector2(1, 1));
                    st.AddNormal(West);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SW]);
                    st.AddUv(new Vector2(0, 1));
                    st.AddNormal(West);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_NW]);
                    st.AddUv(new Vector2(0, 0));
                    st.AddNormal(West);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NW]);
                }
            }
        }
Exemplo n.º 5
0
    public void SpawnTile(TileScript tilescript, Sides requiredSides)
    {
        if (RandomInt(0, 100) < _chanceAtMonsterPercentage)
        {
            tilescript.ContainsMonster = true;
        }

        else if (RandomInt(0, 100) < _chanceAtTreasure)
        {
            tilescript.ContainsTreasure = true;
        }


        Transform modeltransform = tilescript.TileObject.transform;

        if (requiredSides.HasFlag(Sides.Top | Sides.Bot | Sides.Left | Sides.Right))
        {
            Instantiate(FourSplitTiles[RandomInt(0, FourSplitTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, 0, 0)), modeltransform);
        }

        else if (requiredSides.HasFlag(Sides.Top | Sides.Bot | Sides.Right))
        {
            Instantiate(TSplitTiles[RandomInt(0, TSplitTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, -90, 0)), modeltransform);
        }

        else if (requiredSides.HasFlag(Sides.Left | Sides.Bot | Sides.Right))
        {
            Instantiate(TSplitTiles[RandomInt(0, TSplitTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, 0, 0)), modeltransform);
        }
        else if (requiredSides.HasFlag(Sides.Top | Sides.Left | Sides.Right))
        {
            Instantiate(TSplitTiles[RandomInt(0, TSplitTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, 180, 0)), modeltransform);
        }
        else if (requiredSides.HasFlag(Sides.Top | Sides.Bot | Sides.Left))
        {
            Instantiate(TSplitTiles[RandomInt(0, TSplitTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, 90, 0)), modeltransform);
        }

        else if (requiredSides.HasFlag(Sides.Top | Sides.Bot))
        {
            Instantiate(StraightTiles[RandomInt(0, StraightTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, 90, 0)), modeltransform);
        }

        else if (requiredSides.HasFlag(Sides.Left | Sides.Right))
        {
            Instantiate(StraightTiles[RandomInt(0, StraightTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, 0, 0)), modeltransform);
        }

        else if (requiredSides.HasFlag(Sides.Top | Sides.Right))
        {
            Instantiate(CornerTiles[RandomInt(0, CornerTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, -90, 0)), modeltransform);
        }

        else if (requiredSides.HasFlag(Sides.Top | Sides.Left))
        {
            Instantiate(CornerTiles[RandomInt(0, CornerTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, 180, 0)), modeltransform);
        }

        else if (requiredSides.HasFlag(Sides.Bot | Sides.Right))
        {
            Instantiate(CornerTiles[RandomInt(0, CornerTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, 0, 0)), modeltransform);
        }

        else if (requiredSides.HasFlag(Sides.Bot | Sides.Left))
        {
            Instantiate(CornerTiles[RandomInt(0, CornerTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, 90, 0)), modeltransform);
        }

        else if (requiredSides.HasFlag(Sides.Left))
        {
            Instantiate(DeadEndTiles[RandomInt(0, DeadEndTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, -90, 0)), modeltransform);
        }

        else if (requiredSides.HasFlag(Sides.Top))
        {
            Instantiate(DeadEndTiles[RandomInt(0, DeadEndTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, 0, 0)), modeltransform);
        }

        else if (requiredSides.HasFlag(Sides.Right))
        {
            Instantiate(DeadEndTiles[RandomInt(0, DeadEndTiles.Count)], modeltransform.position, Quaternion.Euler(new Vector3(0, 90, 0)), modeltransform);
        }

        else if (requiredSides.HasFlag(Sides.Bot))
        {
            Instantiate(DeadEndTiles[RandomInt(0, DeadEndTiles.Count)], modeltransform.transform.position, Quaternion.Euler(new Vector3(0, 180, 0)), modeltransform);
        }
    }
 public static IEnumerable <Sides> ExtractSides(this Sides sides)
 {
     return(Enum.GetValues(typeof(Sides))
            .OfType <Sides>()
            .Where(position => !_excludedValues.Contains(position) && sides.HasFlag(position)));
 }