// Start is called before the first frame update void Start() { theManager = GameObject.FindObjectOfType <Manager>(); Transform tf = GetComponent <Transform>(); Vector3 pos = current_tile1.GetTilePosition(); Vector3 pos2 = current_tile2.GetTilePosition(); Quaternion rot = Quaternion.Euler(-90, 0, 0); Instantiate(prefab1, pos, rot); Instantiate(prefab2, pos2, rot); current_tile1.has_store = true; current_tile2.has_store = true; }
/* * public IEnumerator Move(int numSpaces) * { * for (int x = 0; x < numSpaces; ++x) * { * Vector3 nextTile = current_tile.GetNextTilePosition(); * float n = 0.0f; * Vector3 currentPosition = current_tile.GetTilePosition(); * Vector3 nextPosition = current_tile.GetNextTilePosition(); * //Debug.Log(currentPosition); * //Debug.Log(nextPosition); * while (n < 1f) * { * Transform tf = GetComponent<Transform>(); * float journeyLength = Vector3.Distance(currentPosition, nextPosition); * tf.position = Vector3.Lerp(currentPosition, nextPosition, n); * n += 0.1f; * yield return null; * } * current_tile = current_tile.next_tile; * } * my_die.MakeDieAvailable(); * hasMoved = true; * yield return null; * } * * public IEnumerator Move(GameTile destination) // REVISED * { * while (current_tile != destination) * { * float n = 0.0f; * * Vector3 nextPosition = current_tile.GetNextTilePosition(); * while (n < 1f) * { * Transform tf = GetComponent<Transform>(); * float journeyLength = Vector3.Distance(currentPosition, nextPosition); * tf.position = Vector3.Lerp(currentPosition, nextPosition, n); * n += 0.1f; * yield return null; * } * current_tile = current_tile.next_tile; * } * my_die.MakeDieAvailable(); * hasMoved = true; * yield return null; * } */ public IEnumerator Move(Vector3 destination) { float n = 0.0f; Vector3 currentPosition = current_tile.GetTilePosition(); while (n < 1.1f) { Transform tf = GetComponent <Transform>(); Vector3 newPosition = destination; newPosition.y = tf.position.y; currentPosition.y = tf.position.y; //float journeyLength = Vector3.Distance(currentPosition, destination); tf.position = Vector3.Lerp(currentPosition, newPosition, n); n += 0.1f; yield return(null); } yield return(null); }