Exemple #1
0
    private void BuildRoad(int roadSize, Directions dir)
    {
        for (int i = 0; i < roadSize; i++)
        {
            if (dir == Directions.Right || dir == Directions.Left)
            {
                GameObject a = InstantiateBlock(_prefabs, Blocks.Road, dir);
                a.transform.Rotate(new Vector3(0, 90, 0));

                Ints.Add((int)Blocks.Road);
                Tiles.Add(a);
            }

            else
            {
                GameObject a = InstantiateBlock(_prefabs, Blocks.Road, dir);
                Ints.Add((int)Blocks.Road);
                Tiles.Add(a);
            }
        }

        buildCurve = true;
    }
Exemple #2
0
 public virtual void AddDetail(string key, object value)
 {
     if (value is Guid)
     {
         Ids.Add(key, (Guid)value);
     }
     else if (value is string)
     {
         Strings.Add(key, (string)value);
     }
     else if (value is int)
     {
         Ints.Add(key, (int)value);
     }
     else if (value is double)
     {
         Doubles.Add(key, (double)value);
     }
     else
     {
         Strings.Add(key, value.ToString());
     }
 }
Exemple #3
0
    private void BuildCurve(int __roadSize, Directions __from, Directions __to)
    {
        Quaternion __newRotation = Quaternion.identity;

        switch (__from)
        {
        case Directions.Up:
        {
            currentSpot.y++;

            __newRotation = __to == Directions.Right ?
                            Quaternion.Euler(new Vector3(0, 180, 0)) :
                            Quaternion.Euler(new Vector3(0, -90, 0));

            break;
        }

        case Directions.Down:
        {
            currentSpot.y--;

            if (__to == Directions.Right)
            {
                __newRotation = Quaternion.Euler(new Vector3(0, 90, 0));
            }

            break;
        }

        case Directions.Left:
        {
            currentSpot.x--;

            __newRotation = __to == Directions.Down ?
                            Quaternion.Euler(new Vector3(0, 180, 0)) :
                            Quaternion.Euler(new Vector3(0, 90, 0));

            break;
        }

        case Directions.Right:
        {
            currentSpot.x++;

            if (__to == Directions.Down)
            {
                __newRotation = Quaternion.Euler(new Vector3(0, 270, 0));
            }
            break;
        }
        }

        if (!Map[currentSpot.x, currentSpot.y].Value)
        {
            GameObject a = InstantiateBlock(_prefabs, Blocks.Curve);
            a.transform.rotation = __newRotation;

            Tiles.Add(a);
            Ints.Add((int)Blocks.Curve);
        }
        else
        {
            int index = 0;
            if (Tiles.Contains(Map[currentSpot.x, currentSpot.y].Value))
            {
                for (int i = 0; i < Tiles.Count; i++)
                {
                    if (Tiles[i] == Map[currentSpot.x, currentSpot.y].Value)
                    {
                        index = i;
                    }
                }
            }

            Ints.RemoveAt(index);
            Tiles.RemoveAt(index);

            Destroy(Map[currentSpot.x, currentSpot.y].Value);
            GameObject a = InstantiateBlock(_prefabs, Blocks.Intersection);

            Tiles.Insert(index, a);
            Ints.Insert(index, (int)Blocks.Intersection);
        }


        buildCurve = false;
    }