コード例 #1
0
    // Use this for initialization
    void Start()
    {
        //Get the player, enemy and mushroom scripts in order to use them later
        playerScript   = gameObject.GetComponent <MainPlayerScript>();
        charName       = playerScript.playerName;
        enemyScript    = GameObject.Find("EnemyPlayer").GetComponent <EnemyPlayerScript>();
        mushroomScript = gameObject.GetComponent <Mushroom>();


        //A string which holds the path to the database, which will be called in a function later on
        string conn = "URI=file:" + Application.dataPath + "/kristiyan_nenov_cw.db";

        IDbConnection dbconn;                                //creates a db connection entity

        dbconn = (IDbConnection) new SqliteConnection(conn); //opens the sqlite connection through the connection entity
        dbconn.Open();                                       //Open connection to the database.

        dbcmd = dbconn.CreateCommand();                      //Uses the create command functionality, which enables script-like queries to the database



        PlayerTable();
        EnemyTable();
        CountMushrooms();
        SpawnMushrooms();


        //Closes everything and makes sure all values are set to null
        dbcmd.Dispose();
        dbcmd = null;
        dbconn.Close();
        dbconn = null;
    }
コード例 #2
0
 // Use this for initialization
 void Start()
 {
     rigidBody             = this.GetComponent <Rigidbody>();
     rigidBody.constraints = RigidbodyConstraints.FreezePositionY;
     groundRenderer        = ground.GetComponent <Renderer>();
     terrainX           = groundRenderer.bounds.size.x / 2;
     terrainZ           = groundRenderer.bounds.size.z / 2;
     playerRenderer     = gameObject.GetComponent <Renderer>();
     enemyPlayerScript  = GameObject.Find("EnemyPlayer").GetComponent <EnemyPlayerScript>();
     rigidBody.velocity = new Vector3(0, 0, 0);
 }