Beispiel #1
0
    /// <summary>
    /// Animate the tile with a scale and a bounce effect
    /// </summary>
    /// <param name="state">The visual state of the tile</param>
    public void AnimateScaleBounceIn(TileVisualState state)
    {
        SpriteRenderer renderer = GetRenderer(state);

        if (renderer != null)
        {
            renderer.transform.localScale = Vector2.zero;
            renderer.DOFade(1f, 0.2f).SetEase(Ease.InQuad);
            renderer.transform.DOScale(1f, 0.5f).SetEase(Ease.OutBounce);
        }
    }
Beispiel #2
0
    /// <summary>
    /// Animate the tile with a fade and scale
    /// </summary>
    /// <param name="state">The visual state of the tile</param>
    public void AnimateFadeScaleIn(TileVisualState state)
    {
        SpriteRenderer renderer = GetRenderer(state);

        if (renderer != null)
        {
            renderer.DOFade(1f, 0.2f);
            renderer.transform.localScale = new Vector2(1.4f, 1.4f);
            renderer.transform.DOScale(1, 0.5f).SetEase(Ease.OutExpo);
        }
    }
Beispiel #3
0
 /// <summary>
 /// Get the layer of the tile's art
 /// </summary>
 /// <param name="state">State of the tile</param>
 public int GetLayer(TileVisualState state)
 {
     for (int i = 0; i < m_TileArt.Count; i++)
     {
         switch (state)
         {
         case TileVisualState.PROP:
         case TileVisualState.HEADQUARTERS:
             return(m_TileArt[i].VisualStateRenderer.sortingOrder);
         }
     }
     return(0);
 }
Beispiel #4
0
 /// <summary>
 /// Set the layer of the tile's art
 /// </summary>
 /// <param name="state">State of the tile</param>
 /// <param name="layer">Layer index</param>
 public void SetLayer(TileVisualState state, int layer)
 {
     for (int i = 0; i < m_TileArt.Count; i++)
     {
         switch (state)
         {
         case TileVisualState.PROP:
         case TileVisualState.HEADQUARTERS:
             m_TileArt[i].VisualStateRenderer.sortingOrder = layer;
             break;
         }
     }
 }
Beispiel #5
0
    /// <summary>
    /// Sets the tile's visual state to the given state
    /// </summary>
    /// <param name="state">State of the tile</param>
    public void SetTileVisualsState(TileVisualState state, bool visible = true, string filePath = null)
    {
        ResetTileVisuals();

        if (state == TileVisualState.BASE)
        {
            return;
        }


        SpriteRenderer renderer = GetRenderer(state);

        if (renderer == null)
        {
            Debug.LogWarning("<color=orange>[Tile]</color> Could not find renderer of state: " + state.ToString());
            return;
        }

        renderer.enabled = true;

        if (!visible)
        {
            renderer.color = new Color(renderer.color.r, renderer.color.g, renderer.color.b, 0);
        }

        switch (state)
        {
        case TileVisualState.PROP:
            renderer.sprite = Resources.Load <Sprite>(filePath);
            SetLayer(TileVisualState.PROP, HexGrid.s_Instance.GridSize.y - PositionInGrid.y);
            break;

        case TileVisualState.HEADQUARTERS:
            SetLayer(TileVisualState.HEADQUARTERS, HexGrid.s_Instance.GridSize.y - PositionInGrid.y);
            break;
        }
    }
Beispiel #6
0
 /// <summary>
 /// Gets the tiles renderer
 /// </summary>
 /// <param name="state">The tiles visual state</param>
 /// <returns></returns>
 private SpriteRenderer GetRenderer(TileVisualState state)
 {
     return(m_TileArt.Find(x => x.VisualState == state).VisualStateRenderer);
 }