コード例 #1
0
ファイル: Graph.cs プロジェクト: voropserg/Graph-Editor
 public void ChangeOrientation(EdgeOrientation orientation = EdgeOrientation.Direct)
 {
     foreach (Edge e in edges)
     {
         e.Orientation = orientation;
     }
 }
コード例 #2
0
 protected void PlaceNextHexagon(int id, DegreeType degreeType, EdgeOrientation eo)
 {
     var pos = _lastPlacedHexagon.GetPositionNextTo(eo);
     Board.GetLimits(pos);
     var hex = Board.CreateHexagon(id, degreeType, pos);
     _lastPlacedHexagon = hex;
 }
コード例 #3
0
    public Edge(Vertex nNorthVertex, Vertex nSouthVertex, EdgeOrientation nOrientation, int num, BoardGraphics nGraphics, bool isInWestHalf, float mapX)
    {
        graphics = nGraphics;
        tileList = new List <Tile>();

        northVertex = nNorthVertex;
        southVertex = nSouthVertex;

        float northX = northVertex.getPosition().x;
        float northY = northVertex.getPosition().y;

        float southX = southVertex.getPosition().x;
        float southY = southVertex.getPosition().y;

        orientation = nOrientation;
        centre      = new Vector3((northX / 2f) + (southX / 2f), (northY / 2f) + (southY / 2f), 0f);
        if (isInWestHalf)
        {
            secondCentre = new Vector3(centre.x + mapX, centre.y, 0);
        }
        else
        {
            secondCentre = new Vector3(centre.x - mapX, centre.y, 0);
        }

        edgeNumber = num;

        biomeTransisition = BiomeTransistion.None;
    }
コード例 #4
0
ファイル: Edge.cs プロジェクト: MingStar/SimUniversity
 public Edge(Hexagon hex, EdgeOrientation so)
 {
     AdjacentForUpdate.Add(hex);
     _originalHexagon = hex;
     _originalOrientation = so;
     Position = new EdgePosition(_originalHexagon.Position, _originalOrientation);
     _cache = new EdgeCache(this);
 }
コード例 #5
0
ファイル: Graph.cs プロジェクト: voropserg/Graph-Editor
        //Edges
        public Edge AddEdge(Vertex firstVertex, Vertex secondVertex, EdgeOrientation orient = EdgeOrientation.None, int weight = 0)
        {
            edgeCount++;
            Edge edge = new Edge(firstVertex, secondVertex, orient, weight);

            edges.Add(edge);
            return(edge);
        }
コード例 #6
0
ファイル: Graph.cs プロジェクト: voropserg/Graph-Editor
        public Edge(Vertex vertex1, Vertex vertex2, EdgeOrientation orient = EdgeOrientation.None, int weight = 0)
        {
            firstVertex  = vertex1;
            secondVertex = vertex2;
            firstVertex.Adjacent.Add(secondVertex);
            secondVertex.Adjacent.Add(firstVertex);

            firstVertex.Edges.Add(this);
            secondVertex.Edges.Add(this);

            Weight      = weight;
            Orientation = orient;
            ChangeDirection();
        }
コード例 #7
0
 private Edge UseOtherOrCreateEdge(Board board, EdgeOrientation eo)
 {
     // only one adjacent hexagon
     var hex = board[_hex.GetPositionNextTo(eo)];
     if (hex != null)
     {
         var edge = hex[EdgeStaticInfo.Get(eo).OppositeEdge];
         if (edge != null)
         {
             return edge;
         }
     }
     return new Edge(_hex, eo);
 }
コード例 #8
0
 internal static EdgeStaticInfo Get(EdgeOrientation eo)
 {
     return _staticInfoDict[eo];
 }
コード例 #9
0
ファイル: Hexagon.cs プロジェクト: MingStar/SimUniversity
 internal Edge this[EdgeOrientation eo]
 {
     get { return _edges[(int) eo]; }
     set { _edges[(int) eo] = value; }
 }
コード例 #10
0
ファイル: Hexagon.cs プロジェクト: MingStar/SimUniversity
 IEdge IHexagon.this[EdgeOrientation eo]
 {
     get { return _edges[(int) eo]; }
 }
コード例 #11
0
 private void AtSideJoin(EdgeOrientation eo, Hexagon hex)
 {
     AddAdjacent(_hex, eo, hex);
     AddAdjacent(hex, EdgeStaticInfo.Get(eo).OppositeEdge, _hex);
 }
コード例 #12
0
 internal void AddAdjacent(Hexagon hex, EdgeOrientation eo, Hexagon otherHex)
 {
     hex.AdjacentForUpdate.Add(otherHex);
 }
コード例 #13
0
    public void changeEdgePieces(int edgeNum, BiomeTransistion transistion, Vector3 position, Vector3 secondPosition, EdgeOrientation orientate)
    {
        int     angle = 0;
        Vector3 z     = new Vector3(0, 0, 1);

        if (orientate == EdgeOrientation.NS)
        {
            angle = 0;
        }
        else if (orientate == EdgeOrientation.NWSE)
        {
            angle = 60;
        }
        else
        {
            angle = -60;
        }


        if (transistion.Equals(BiomeTransistion.Coast))
        {
            GameObject newEdgepiece = coastPiece;

            if (edgePieces[edgeNum] == null)
            {
                GameObject test = GameObject.Instantiate(newEdgepiece, position, Quaternion.AngleAxis(angle, z)) as GameObject;
                edgePieces[edgeNum]   = test;
                test.transform.parent = gameObject.transform;
                test.isStatic         = true;

                GameObject test1 = GameObject.Instantiate(newEdgepiece, secondPosition, Quaternion.AngleAxis(angle, z)) as GameObject;
                edgePieces[edgeNum + (edgePieces.Length / 2)] = test1;
                test1.transform.parent = gameObject.transform;
                test1.isStatic         = true;
            }
            else
            {
                Destroy(edgePieces[edgeNum]);
                GameObject test = GameObject.Instantiate(newEdgepiece, position, Quaternion.AngleAxis(angle, z)) as GameObject;
                edgePieces[edgeNum]   = test;
                test.transform.parent = gameObject.transform;
                test.isStatic         = true;

                Destroy(edgePieces[edgeNum + (edgePieces.Length / 2)]);
                GameObject test1 = GameObject.Instantiate(newEdgepiece, secondPosition, Quaternion.AngleAxis(angle, z)) as GameObject;
                edgePieces[edgeNum + (edgePieces.Length / 2)] = test1;
                test1.transform.parent = gameObject.transform;
                test1.isStatic         = true;
            }
        }

        if (transistion.Equals(BiomeTransistion.None))
        {
            if (edgePieces[edgeNum] != null)
            {
                Destroy(edgePieces[edgeNum]);
                Destroy(edgePieces[edgeNum + (edgePieces.Length / 2)]);
            }
        }
    }
コード例 #14
0
 public EdgePosition(int x, int y, EdgeOrientation eo)
     : this(new Position(x, y), eo)
 {
 }
コード例 #15
0
 public EdgePosition(Position position, EdgeOrientation eo)
 {
     HexPosition = position;
     Orientation = eo;
 }
コード例 #16
0
ファイル: Game.cs プロジェクト: MingStar/SimUniversity
 public void SetUpLink(int x, int y, EdgeOrientation eo)
 {
     BuildLink(new EdgePosition(x, y, eo));
 }
コード例 #17
0
    public void buildRiverEdge(int edgeNum, Vector3 position, Vector3 secondPosition, EdgeOrientation orientate)
    {
        int     angle = 0;
        Vector3 z     = new Vector3(0, 0, 1);

        if (orientate == EdgeOrientation.NS)
        {
            angle = 0;
        }
        else if (orientate == EdgeOrientation.NWSE)
        {
            angle = 60;
        }
        else
        {
            angle = -60;
        }



        GameObject newPiece = riverPiece;

        if (edgePieces[edgeNum] == null)
        {
            GameObject test = GameObject.Instantiate(newPiece, position, Quaternion.AngleAxis(angle, z)) as GameObject;
            edgePieces[edgeNum]   = test;
            test.transform.parent = gameObject.transform;
            test.isStatic         = true;

            GameObject test1 = GameObject.Instantiate(newPiece, secondPosition, Quaternion.AngleAxis(angle, z)) as GameObject;
            edgePieces[edgeNum + (edgePieces.Length / 2)] = test1;
            test1.transform.parent = gameObject.transform;
            test1.isStatic         = true;
        }
        else
        {
            Destroy(edgePieces[edgeNum]);
            GameObject test = GameObject.Instantiate(newPiece, position, Quaternion.AngleAxis(angle, z)) as GameObject;
            edgePieces[edgeNum]   = test;
            test.transform.parent = gameObject.transform;
            test.isStatic         = true;

            Destroy(edgePieces[edgeNum + (edgePieces.Length / 2)]);
            GameObject test1 = GameObject.Instantiate(newPiece, secondPosition, Quaternion.AngleAxis(angle, z)) as GameObject;
            edgePieces[edgeNum + (edgePieces.Length / 2)] = test1;
            test1.transform.parent = gameObject.transform;
            test1.isStatic         = true;
        }
    }