Exemplo n.º 1
0
        /// <summary>
        /// Converts to Pixel Coordinates(Not World Position)
        /// </summary>
        public Vector2 ToPixel()
        {
            float x = HexagonManager.GetEdgeLength() * (3 / 2f * Column);
            float y = HexagonManager.GetEdgeLength() * Mathf.Sqrt(3) * (Row - 0.5f * (Column & 1));

            return(new Vector2(x, y));
        }
Exemplo n.º 2
0
 void Awake()
 {
     if (hm == null)
     {
         hm = this;
     }
     else if (hm != this)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 3
0
    public List <Hexagon> ComputePathBetweenHexagons(Hexagon hexA, Hexagon hexB, HexagonManager map)
    {
        visitedHex.Clear();
        List <Hexagon> path = new List <Hexagon>();

        path.Add(hexA);
        RecursivePathComputing(ref path, hexA, hexA, hexB, map);


        return(path);
    }
Exemplo n.º 4
0
 // Use this for initialization
 private void Awake()
 {
     if (hm == null)
     {
         hm = this;
     }
     if (hm != this)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 5
0
 private void Awake()
 {
     instance    = GetComponent <HexagonManager>();
     tiles       = new GameObject[ROW, COLUMN];
     xPosition   = GRID_START_POSITION.x;
     yPosition   = GRID_START_POSITION.y;
     explodeList = new List <GameObject>();
     bombPool.Add(Instantiate(bombPrefab, OUT_OF_CAMERA, Quaternion.identity) as GameObject);
     bombPool[0].transform.parent = this.transform;
     bombPool[0].SetActive(false);
     touchAvailable = true;
     gameoverPanel.SetActive(false);
 }
Exemplo n.º 6
0
 void Start()
 {
     hexagonManager = GetComponent<HexagonManager>();
     hexagonManager.ConstructBoardTiles(); 
 }
Exemplo n.º 7
0
    // Hexagon'ların tutulduğu array ile ilgili metotlar burada yer alır.
    // Ayrıca explode olacak hexagonlar da burada listede tutulur.

    void Awake()
    {
        instance = this;
    }
Exemplo n.º 8
0
    private void RecursivePathComputing(ref List <Hexagon> path, Hexagon firtHex, Hexagon hexA, Hexagon hexB, HexagonManager map)
    {
        Vector3 start       = hexA.transform.position;
        Vector3 end         = hexB.transform.position;
        float   maxDistance = Vector3.Distance(start, end) + map.sizeHexagon;

        float   bestRatio     = 0;
        Hexagon chosenHexagon = null;

        for (int i = 0; i < (int)HexagonManager.EDirectionHexagon.eCount; ++i)
        {
            GameObject neighbor = map.GetNeighbor(hexA.gameObject, (HexagonManager.EDirectionHexagon)i);

            if (neighbor && neighbor.GetComponent <Hexagon>() == hexB)
            {
                chosenHexagon = hexB;
                path.Add(chosenHexagon);
                return;
            }
            if (neighbor)
            {
                float distance = Vector3.Distance(neighbor.transform.position, end);
                float ratio    = (maxDistance - distance) / maxDistance;
                ratio = Mathf.Abs(ratio);
                ratio = neighbor.GetComponent <Hexagon>().Weight *ratio;

                if (ratio > bestRatio && !visitedHex.Find(item => item == neighbor.GetComponent <Hexagon>()))
                {
                    bestRatio     = ratio;
                    chosenHexagon = neighbor.GetComponent <Hexagon>();
                }
            }
        }

        if (chosenHexagon == null)
        {
            if (path.Count == 1)
            {
                Debug.Log("NOT PATH FOUND :/");
                return;
            }
            if (path[path.Count - 1] == hexB)
            {
                return;
            }
            path.RemoveAt(path.Count - 1);
            RecursivePathComputing(ref path, firtHex, path[path.Count - 1], hexB, map);
        }

        if (chosenHexagon && chosenHexagon != hexB)
        {
            visitedHex.Add(chosenHexagon);
            path.Add(chosenHexagon);
            RecursivePathComputing(ref path, firtHex, chosenHexagon, hexB, map);
        }
    }
Exemplo n.º 9
0
 void Start()
 {
     instance       = GetComponent <TouchManager>();
     hexagonManager = GetComponent <HexagonManager>();
     hexagonManager.Deselect();
 }
 public void SetHexagonManager(HexagonManager inputManager)
 {
     hexagonManager = inputManager;
 }