Esempio n. 1
0
    private void Awake()
    {
        // load map
        if (MapName.Length == 0)
        {
            MapName = (string)PhotonNetwork.CurrentRoom.CustomProperties[PhotonLobby.MapNamePropertyName];
        }
        TextAsset mapContents = Resources.Load <TextAsset>(Path.Combine("Maps", MapName));

        string[] strs = mapContents.text.Split(
            new char[] { ' ', '\t', '\n', '\r', ',', ';', '|' },
            StringSplitOptions.RemoveEmptyEntries
            );
        List <List <float> > heights = _ParseMap(((IEnumerable <string>)strs).GetEnumerator());

        bool flip = false;

        for (int x = 0; x < NumPrismsX; ++x)
        {
            bool innerFlip = flip;
            for (int z = 0; z < NumPrismsZ; ++z)
            {
                GameObject prism = Instantiate(PrismObject);

                Transform t = prism.transform;
                t.localPosition = new Vector3(HalfSqrt3 * x * PrismScale, 0.0f, 0.5f * z * PrismScale);
                if (innerFlip)
                {
                    t.localEulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
                }
                t.localScale = new Vector3(PrismScale, t.localScale.y, PrismScale);

                PrismMover mover = prism.GetComponent <PrismMover>();
                mover.MaxHeight         = MaxHeight;
                mover.MinHeight         = MinHeight;
                mover.MinHeightCapColor = MinHeightColor;
                mover.MaxHeightCapColor = MaxHeightColor;
                mover.ChangeHeightImmediate(heights[z][x]);

                innerFlip = !innerFlip;
            }
            flip = !flip;
        }
        StartCoroutine(_WaitForPrismReady());
    }
Esempio n. 2
0
 /// <summary>
 /// Alters all given prisms.
 /// </summary>
 /// <param name="cols">The prisms.</param>
 /// <param name="delta">The change in height.</param>
 /// <param name="immediate">Whether this change is immediate.</param>
 public static void AlterTerrain(Collider[] cols, float delta, bool immediate)
 {
     foreach (Collider c in cols)
     {
         PrismMover mover = c.GetComponent <PrismMover>();
         if (mover != null)
         {
             if (immediate)
             {
                 mover.ChangeHeightImmediate(delta);
             }
             else
             {
                 mover.ChangeHeight(delta);
             }
         }
     }
 }