Ejemplo n.º 1
0
 void ToggleBomb(Hexagon[] destroyedHexagons)
 {
     if (UIManager.ins.IsBombCount)
     {
         if (bombHexagon == null)
         {
             bombHexagon = destroyedHexagons[0];
             bombHexagon.transform.rotation = Quaternion.Euler(Vector3.zero);
             UIManager.ins.bombHexagonT     = bombHexagon.transform;
             bombHexagon.render.sprite      = bombSprite;
         }
         else
         {
             if (Array.IndexOf(destroyedHexagons, bombHexagon) > -1 && skipOneTime)
             {
                 bombHexagon.render.sprite = gridManager.DefaultSprite;
                 UIManager.ins.IsBombCount = false;
             }
             skipOneTime = true;
         }
     }
     else
     {
         bombHexagon = null;
         UIManager.ins.bombHexagonT = null;
     }
 }
Ejemplo n.º 2
0
    public IEnumerator CreatingAnim(AbstractHexagon absHex, Vector3 finalScale)
    {
        float percent = 0;
        float easedPercent;

        while (percent <= 1)
        {
            percent     += hexCreatingSpeed * Time.deltaTime;
            percent      = Mathf.Clamp01(percent);
            easedPercent = Utility.Ease(percent, easeAmountCreating);
            absHex.transform.localScale = Vector3.Lerp(Vector3.zero, finalScale, easedPercent);
            yield return(null);
        }
    }
Ejemplo n.º 3
0
    public void CreateMap()
    {
#if UNITY_EDITOR
        foreach (Transform child in transform)
        {
            StartCoroutine(Destroy(child.gameObject));
        }
#endif
        List <AbstractHexagon> tempAbstractHexagons = new List <AbstractHexagon>();

        float startPosX    = ((width - 1) * 2f * HexInfo.outerRadius * .75f) / -2f;
        float startPosY    = ((height - 1) * 2f * HexInfo.innerRadius + HexInfo.innerRadius) / -2f;
        float newStartPosY = startPosY;

        Vector2 position = Vector2.zero;
        for (int x = 0; x < width; x++)
        {
            position.x = startPosX + 2 * HexInfo.outerRadius * x * .75f;
            for (int y = 0; y < height; y++)
            {
                newStartPosY = x % 2 == 1 ? startPosY + HexInfo.innerRadius : startPosY;
                position.y   = newStartPosY + HexInfo.innerRadius * 2f * y;
                AbstractHexagon abshexagon = Instantiate(hexagonPrefab).GetComponent <AbstractHexagon>();
                abshexagon.transform.position = position;
                abshexagon.transform.SetParent(transform);
                abshexagon.transform.localScale = Vector2.one * hexagonScale;
                tempAbstractHexagons.Add(abshexagon);
                abshexagon.name = "Hexagon " + (tempAbstractHexagons.Count - 1);
                abshexagon.Register(machine);
                machine.AddDictionary((Hexagon)abshexagon);
            }
        }
        DefaultSprite = tempAbstractHexagons[0].render.sprite;
        Utility.SetHexagonRandomColor(tempAbstractHexagons, hexColors, colorSeed);

        boundsMap.size = new Vector2(-startPosX, -startPosY) * 2f;
        boundsMap.Expand(.6f);
        Camera.main.orthographicSize = (boundsMap.size.x + .8f) / (2f * Camera.main.aspect);
#if UNITY_ANDROID
        StartCoroutine(MakeGridAnim(tempAbstractHexagons.ToArray()));
#endif
    }
Ejemplo n.º 4
0
 public void MakeCreatingAnim(AbstractHexagon absHex, Vector2 finalScale)
 {
     StartCoroutine(CreatingAnim(absHex, finalScale));
 }