예제 #1
0
    private IEnumerator SpawnTreasure()
    {
        print("spawning treasure");
        GameController.treasureCount++;
        int x = Random.Range(0, 19);
        int z = Random.Range(0, 19);

        while (!Helpers.GetTile(x, z).CanHaveTreasure())
        {
            x = Random.Range(0, 19);
            z = Random.Range(0, 19);
        }

        int y = VoxelController.GetElevation(x, z);

        GameObject treasure = Instantiate(Resources.Load("Treasure"), Vector3.zero, Quaternion.identity) as GameObject;
        Cursor     cursor   = Helpers.GetTile(x, z);

        cursor.standingTreasure = treasure.GetComponent <Treasure>();
        print(treasure.GetComponent <Treasure>());
        treasure.GetComponent <Treasure>().cursor = cursor;

        Helpers.SetTransformPosition(treasure.transform, x, y, z);
        MainCamera.Lock();
        MainCamera.CenterOnWorldPoint(treasure.transform.position);
        yield return(new WaitForSeconds(3f));

        MainCamera.Unlock();
        instance.ContinueNextTurn();
    }