コード例 #1
0
 // Update is called once per frame
 void Update()
 {
     transform.position = HexMapHelper.GetWorldPointFromTile(
         tilePositionObject.GetPivotTilePosition(), tilePositionObject.GetPivotTileLevel())
                          + (HexMapHelper.GetFacingVector(tilePositionObject.GetPivotTilePosition(), hexDirectionObject.GetTileFacing()) * centerOffset);
     triangle.color     = HexMapUI.GetLevelColor(tilePositionObject.GetPivotTileLevel());
     transform.rotation = HexMapHelper.GetRotationFromFacing(tilePositionObject.GetPivotTilePosition(), hexDirectionObject.GetTileFacing());
 }
コード例 #2
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;
        }
    }
コード例 #3
0
    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));
    }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        float objectRelativeAltitude = attachedObject.position.y - HexMapUI.currentUIMapAltitude;

        //normal
        Vector3 normal             = (attachedObject.position - centerPoint).normalized;
        Vector3 gridIntercectPoint = centerPoint + (normal * HexMapHelper.GetRadialOffsetFromLevel(HexMapUI.currentUIMapLevel));

        //Set the cylinder position to midway between object and grid
        heightCylinder.transform.position   = (attachedObject.position + gridIntercectPoint) / 2f;
        heightCylinder.transform.localScale = new Vector3(xzScale, xzScale, Vector3.Distance(attachedObject.position, gridIntercectPoint));
        heightCylinder.transform.rotation   = Quaternion.LookRotation(normal);

        //Set the little target sprite to grid height
        baseSprite.transform.position = gridIntercectPoint;
        baseSprite.transform.rotation = Quaternion.LookRotation(normal);
        baseSprite.GetComponent <SpriteRenderer>().color = HexMapUI.GetLevelColor(HexMapUI.currentUIMapLevel);
    }
コード例 #5
0
 // Update is called once per frame
 void Update()
 {
     //Swap Color between (Cyan selected color and level color)
     swapCountdown -= TimeManager.UIDeltaTime;
     if (swapCountdown < 0)
     {
         ParentFsm.sprite.GetComponentInChildren <SpriteRenderer>().color = isBaseColor ? Color.cyan : HexMapUI.GetLevelColor(ParentFsm.destinationLevel);
         swapCountdown += colorSwapRate;
         isBaseColor    = !isBaseColor;
     }
 }
コード例 #6
0
        protected override void ExitState()
        {
            base.ExitState();

            ParentFsm.sprite.GetComponentInChildren <SpriteRenderer>().color = HexMapUI.GetLevelColor(ParentFsm.destinationLevel);
        }
コード例 #7
0
 void Awake()
 {
     instance    = this;
     _UIMapLevel = startingUIMapLevel;
 }