Пример #1
0
	// Use this for initialization
	//	public void init(int i, int j, Vector2 start_dir, int num_tiles_w, int num_tiles_h){
	public void init(int i, int j, int start_dir, TrainManager owner) {
		this.owner = owner;
		this.num_tiles_w = owner.num_tiles_w;
		this.num_tiles_h = owner.num_tiles_h;
		this.n = owner.owner.n;
		this.direction = start_dir;
		tile_width = Screen.width / num_tiles_w;

		this.transform.rotation = Quaternion.Euler(0f, 0f, (90f * direction)%360f);
		this.transform.Rotate (Vector2.right * direction);

		float[] pos = position (i, j);
		location = new Vector2 (pos [0], pos [1]);
		current_tile = owner.owner.board.tiles [i] [j];
		this.transform.position = Camera.main.ScreenToWorldPoint (
			new Vector3 (location.x, location.y, 8));

		GameObject modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad);	// Create a quad object for holding the gem texture.
		model = modelObject.AddComponent<TrainModel>();						// Add a gemModel script to control visuals of the gem.
		model.init(this);
	}
Пример #2
0
    // Use this for initialization
    //	public void init(int i, int j, Vector2 start_dir, int num_tiles_w, int num_tiles_h){
    public void init(int i, int j, int start_dir, TrainManager owner)
    {
        this.owner       = owner;
        this.num_tiles_w = owner.num_tiles_w;
        this.num_tiles_h = owner.num_tiles_h;
        this.n           = owner.owner.n;
        this.direction   = start_dir;
        tile_width       = Screen.width / num_tiles_w;

        this.transform.rotation = Quaternion.Euler(0f, 0f, (90f * direction) % 360f);
        this.transform.Rotate(Vector2.right * direction);

        float[] pos = position(i, j);
        location                = new Vector2(pos [0], pos [1]);
        current_tile            = owner.owner.board.tiles [i] [j];
        this.transform.position = Camera.main.ScreenToWorldPoint(
            new Vector3(location.x, location.y, 8));

        GameObject modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad);                // Create a quad object for holding the gem texture.

        model = modelObject.AddComponent <TrainModel>();                                        // Add a gemModel script to control visuals of the gem.
        model.init(this);
    }