예제 #1
0
    private void CalculateTemperature()
    {
        int distanceUp    = 0;
        int distanceDown  = 0;
        int distanceRight = 0;
        int distanceLeft  = 0;

        int hexDistance1 = 13;
        int hexDistance2 = 20;
        int hexDistance3 = 35;

        EQUATOR_LINE equatorLine = EquatorGenerator.Instance.equatorLine;

        if (equatorLine == EQUATOR_LINE.HORIZONTAL)
        {
//			string[] splitted = EquatorGenerator.Instance.listEquator[0].name.Split(new char[]{','});
//			int[] split = {int.Parse(splitted[0]), int.Parse(splitted[1])};

            for (int i = 0; i < EquatorGenerator.Instance.listEquator.Count; i++)
            {
                float temperature = initialTemperature;

                string[] splittedName = EquatorGenerator.Instance.listEquator[i].name.Split(new char[] { ',' });
                int[]    xy           = { int.Parse(splittedName[0]), int.Parse(splittedName[1]) };

                for (int up = xy[1]; up < GridMap.Instance.height; up++)
                {
                    distanceUp = up - xy[1];
                    if (distanceUp >= 0 && distanceUp <= hexDistance1)
                    {
                        temperature = intervalTemperature * 1f;
                    }
                    else if (distanceUp > hexDistance1 && distanceUp <= hexDistance2)
                    {
                        temperature = intervalTemperature * 2f;
                    }
                    else if (distanceUp > hexDistance2 && distanceUp <= hexDistance3)
                    {
                        temperature = intervalTemperature * 3f;
                    }
                    else if (distanceUp > hexDistance3)
                    {
                        temperature = intervalTemperature * 4f;
                    }
                    else
                    {
                        temperature = intervalTemperature * 1f;
                    }
                    GridMap.Instance.GetHex(xy[0] + "," + up).GetComponent <HexTile>().temperature = temperature;
                }

                for (int down = xy[1]; down >= 0; down--)
                {
                    distanceDown = xy[1] - down;
                    if (distanceDown >= 0 && distanceDown <= hexDistance1)
                    {
                        temperature = intervalTemperature * 1f;
                    }
                    else if (distanceDown > hexDistance1 && distanceDown <= hexDistance2)
                    {
                        temperature = intervalTemperature * 2f;
                    }
                    else if (distanceDown > hexDistance2 && distanceDown <= hexDistance3)
                    {
                        temperature = intervalTemperature * 3f;
                    }
                    else if (distanceDown > hexDistance3)
                    {
                        temperature = intervalTemperature * 4f;
                    }
                    else
                    {
                        temperature = intervalTemperature * 1f;
                    }
                    GridMap.Instance.GetHex(xy[0] + "," + down).GetComponent <HexTile>().temperature = temperature;
                }
            }
        }

        if (equatorLine == EQUATOR_LINE.VERTICAL || equatorLine == EQUATOR_LINE.DIAGONAL_RIGHT || equatorLine == EQUATOR_LINE.DIAGONAL_LEFT)
        {
//			string[] splitted = EquatorGenerator.Instance.listEquator[0].name.Split(new char[]{','});
//			int[] split = {int.Parse(splitted[0]), int.Parse(splitted[1])};

            for (int i = 0; i < EquatorGenerator.Instance.listEquator.Count; i++)
            {
                float temperature = initialTemperature;

                string[] splittedName = EquatorGenerator.Instance.listEquator[i].name.Split(new char[] { ',' });
                int[]    xy           = { int.Parse(splittedName[0]), int.Parse(splittedName[1]) };

                for (int right = xy[0]; right < GridMap.Instance.height; right++)
                {
                    distanceRight = right - xy[0];
                    if (distanceRight >= 0 && distanceRight <= hexDistance1)
                    {
                        temperature = intervalTemperature * 1f;
                    }
                    else if (distanceRight > hexDistance1 && distanceRight <= hexDistance2)
                    {
                        temperature = intervalTemperature * 2f;
                    }
                    else if (distanceRight > hexDistance2 && distanceRight <= hexDistance3)
                    {
                        temperature = intervalTemperature * 3f;
                    }
                    else if (distanceRight > hexDistance3)
                    {
                        temperature = intervalTemperature * 4f;
                    }
                    else
                    {
                        temperature = intervalTemperature * 1f;
                    }
                    GridMap.Instance.GetHex(right + "," + xy[1]).GetComponent <HexTile>().temperature = temperature;
                }

                for (int left = xy[0]; left >= 0; left--)
                {
                    distanceLeft = xy[0] - left;
                    if (distanceLeft >= 0 && distanceLeft <= hexDistance1)
                    {
                        temperature = intervalTemperature * 1f;
                    }
                    else if (distanceLeft > hexDistance1 && distanceLeft <= hexDistance2)
                    {
                        temperature = intervalTemperature * 2f;
                    }
                    else if (distanceLeft > hexDistance2 && distanceLeft <= hexDistance3)
                    {
                        temperature = intervalTemperature * 3f;
                    }
                    else if (distanceLeft > hexDistance3)
                    {
                        temperature = intervalTemperature * 4f;
                    }
                    else
                    {
                        temperature = intervalTemperature * 1f;
                    }
                    GridMap.Instance.GetHex(left + "," + xy[1]).GetComponent <HexTile>().temperature = temperature;
                }
            }
        }
    }
예제 #2
0
 internal void GenerateEquator()
 {
     this.equatorLine    = GetEquatorLine();
     this.hexEquatorName = GetHexEquatorName();
     DrawEquator();
 }