Exemple #1
0
 internal void SetModel(BuildingModel model)
 {
     transform.position = new Vector3(HexMapHelper.GetXPosition(model.X, model.Y), model.Altitude, HexMapHelper.GetZPosition(model.Y));
     model._State.Subscribe(_ => SetState(_)).AddTo(disposables);
 }
    public void SetDestination(TileCoords tileCoords, TileCoords facingTile, int level)
    {
        destinationTile       = tileCoords;
        destinationFacingTile = facingTile;
        destinationLevel      = level;

        //Position the sprite within the Hex
        sprite.transform.position = HexMapHelper.GetWorldPointFromTile(tileCoords, level) + ((HexMapHelper.GetFacingVector(tileCoords, facingTile) * HexMapHelper.HexWidth * 0.3f));

        //Face the sprite the correct direction
        sprite.transform.rotation = HexMapHelper.GetRotationFromFacing(tileCoords, facingTile);

        //Color the sprite based on height
        sprite.GetComponentInChildren <SpriteRenderer>().color = HexMapUI.GetLevelColor(level);

        SetSpline(sourcePosition, sourceHeading,
                  HexMapHelper.GetWorldPointFromTile(tileCoords, level), HexMapHelper.GetFacingVector(tileCoords, facingTile));
    }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        if (isDirty && tileFootprintObject.GetFootprint() != null)
        {
            List <TileWithLevel> footParts = tileFootprintObject.GetFootprint().GetAllTilesInFootprint();

            if (polygons.Count == 0)
            {
                Initialize(footParts.Count);
            }
            Color meshColor = Color.white;

            for (int footPartIndex = 0; footPartIndex < footParts.Count; footPartIndex++)
            {
                TileWithLevel footPart = footParts[footPartIndex];
                Tile          footTile = HexMapUI.GetHexasphereTile(footPart.position, footPart.level);
                if (footTile != null)
                {
                    Vector3[] vertices = new Vector3[7];
                    vertices[0] = transform.InverseTransformPoint(footTile.center * 2f * HexMapHelper.GetRadialOffsetFromLevel(footPart.level));
                    for (int i = 0; i < footTile.vertices.Length; i++)
                    {
                        vertices[i + 1] = transform.InverseTransformPoint(footTile.vertices[i] * 2f * HexMapHelper.GetRadialOffsetFromLevel(footPart.level));
                    }

                    meshColor = HexMapUI.GetLevelColor(footPart.level);

                    polygons[footPartIndex].SetVertices(vertices);
                    polygons[footPartIndex].SetTriangles(
                        footTile.vertices.Length == 6 ? trianglesHex : trianglesPenta,
                        0);
                    polygons[footPartIndex].SetNormals(normals);
                    polygons[footPartIndex].SetUVs(0, uvs);

                    combineInstances[footPartIndex].mesh = polygons[footPartIndex];
                }
            }

            combinedMesh.CombineMeshes(combineInstances, true, false);
            combinedMesh.RecalculateBounds();

            transform.localPosition = Vector3.zero;
            transform.localRotation = Quaternion.identity;
            GetComponent <MeshRenderer>().material.color = meshColor;

            isDirty = false;
        }
    }
Exemple #4
0
 public override BaseGamePiece FindTarget()
 {
     //Player Ship
     if (currentTarget != null)
     {
         Debug.DrawLine(HexMapHelper.GetWorldPointFromTile(myGamePiece.currentTile), HexMapHelper.GetWorldPointFromTile(currentTarget.currentTile), Color.yellow, 5f);
     }
     return(currentTarget);
 }
 void ResetToGamePiecePosition()
 {
     worldBase.transform.position  = HexMapHelper.GetWorldPointFromTile(gamePiece.currentTile, gamePiece.currentLevel);
     worldModel.transform.rotation = HexMapHelper.GetRotationFromFacing(gamePiece.currentTile, gamePiece.currentTileFacing);
 }