PlayScheduled() приватный Метод

private PlayScheduled ( double time ) : void
time double
Результат void
Пример #1
0
	void SetupLoop() {
		sourceTwo = gameObject.AddComponent<AudioSource> ();
		sourceTwo.playOnAwake = false;
		sourceTwo.clip = songClip;
		sourceTwo.timeSamples = introEndInSamples;
		sourceTwo.PlayScheduled (introEndTime);
		sourceTwo.SetScheduledEndTime (nextLoopSwap);
		InvokeRepeating ("SwapLoop", (float) ((introEndInSamples * oneSampleInSeconds) + 1.0f), (float) loopTime);
	}
Пример #2
0
	// Use this for initialization
	void Awake() {
		sourceOne = gameObject.AddComponent<AudioSource> ();
		sourceOne.clip = songClip;
		oneSampleInSeconds = 1.0 / songClip.frequency;
		loopTime = loopInSamples * oneSampleInSeconds;
		introEndTime = AudioSettings.dspTime + (introEndInSamples * oneSampleInSeconds);
		nextLoopSwap = introEndTime + loopTime;
		sourceOne.PlayScheduled(AudioSettings.dspTime);
		sourceOne.SetScheduledEndTime (introEndTime);
		Invoke ("SetupLoop", 2.0f);
	}
    void OnLevelWasLoaded()
    {
        GameObject.Find("Canica").GetComponent<Rigidbody>().useGravity = false;
        time = 4;
        count = true;
        var match = Regex.Match(Application.loadedLevelName, @"^([^0-9]+)([0-9]+)$");
        levelNum = int.Parse(match.Groups[2].Value);

        music = GameObject.Find("music").GetComponent<AudioSource>();
        music.Stop();
        music.volume = 0f;
        music.PlayScheduled(time);  // This gives time for the AudioSource to load properly.
    }
Пример #4
0
 static public int PlayScheduled(IntPtr l)
 {
     try {
         UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l);
         System.Double           a1;
         checkType(l, 2, out a1);
         self.PlayScheduled(a1);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static int PlayScheduled(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.AudioSource obj = (UnityEngine.AudioSource)ToLua.CheckObject <UnityEngine.AudioSource>(L, 1);
         double arg0 = (double)LuaDLL.luaL_checknumber(L, 2);
         obj.PlayScheduled(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #6
0
    public void Play(int songID, int difficultyLevel)
    {
        Debug.Log ("PLAYING THE SOOOONG");
        initializeDifficulty (difficultyLevel);
        TrackManager.loadMidi (Songs [songID]);
        if(OnLoadTrack != null) {
            trackStartTime = GetTime() + 1.0f;
            OnLoadTrack(this, new OnLoadTrackEventArgs(trackStartTime + magicNumberfix));
            //Debug.Log("TrackManager: "+trackManager);
            //Debug.Log("Track: "+trackManager.Track);

            audioSource = gameObject.AddComponent<AudioSource>();
            audioSource.clip = BackgroundAudio [songID];
            audioSource.clip.LoadAudioData();
            audioSource.PlayScheduled(trackStartTime);

            Invoke("SendPlayEvent",1.0f);
        }
    }
Пример #7
0
    void Start()
    {
        Random.seed = 123;

        filejson = (TextAsset)Resources.Load (fileNamejson + songName);
        testData = JSON.Parse (filejson.text);

        Debug.Log ("there are " + testData.Count + " tracks for this song - you need params for each!");

        // make an index for each track (for incrementing through the notes while playing the song)
        for (int i = 0; i < testData.Count; i++) {
            track_idxs.Add (0);
        }

        // let's figure out the max and min world coords currently visible with our screen dimensions
        //Debug.Log (Screen.height + " " + Screen.width);
        float camera_distance = main_camera.transform.position.z;
        Vector3 upper_right = main_camera.ScreenToWorldPoint (new Vector3 (0f, 0f, camera_distance));
        //Vector3 bottom_left = main_camera.ScreenToWorldPoint(new Vector3(Screen.width,Screen.height,camera_distance));

        bounds = new Vector2 (upper_right.x, upper_right.y);
        Debug.Log ("world coordinates boundaries " + bounds);

        audio_source = gameObject.AddComponent<AudioSource> ();
        audio_source.clip = song_audio;
        audio_source.volume = 0.1f;
        audio_source.PlayScheduled (AudioSettings.dspTime + initial_delay); // 2 second delay

        bg_container.transform.localScale = new Vector3 (bounds.x / 5.6f, bounds.y / 5.6f, 1.0f); // set background size to fill screen

        current_enemy_color = enemy_colors [0];
    }
Пример #8
0
    // Use this for initialization
    void Start()
    {
        Random.seed = 123;

        QualitySettings.antiAliasing = 2;
        Application.targetFrameRate = 120;

        int num_outlines = 7;
        float max_alpha = 0.2f;
        float zoom_factor = 1.1f;
        for (int i = 0; i < num_outlines; i++) {
            GameObject level_clone = Instantiate (level_outline, new Vector3 (0f, 0f, i * zoom_factor), Quaternion.identity) as GameObject;
            //GameObject obstacle_clone = Instantiate (level_obstacle, new Vector3 (-1.5f, -1.5f, i * zoom_factor), Quaternion.identity) as GameObject;

            Color c = level_color;
            if (i == 0) {
                level_clone.GetComponent<SpriteRenderer> ().color = new Color (c.r, c.g, c.b, 1f);
                //obstacle_clone.GetComponent<SpriteRenderer> ().color = new Color (c.r, c.g, c.b, 1f);
            } else {
                level_clone.GetComponent<SpriteRenderer> ().color = new Color (c.r, c.g, c.b, max_alpha * (1f - (i * 1.0f / num_outlines * 1.0f)));
                //obstacle_clone.GetComponent<SpriteRenderer> ().color = new Color (c.r, c.g, c.b, max_alpha * (1f - (i * 1.0f / num_outlines * 1.0f)));
            }
        }

        // read in level from file
        TextAsset l = Resources.Load ("2") as TextAsset;
        string[] lines = l.text.Split ("\n" [0]);
        grid_dimensions = lines.Length;
        int[] block_types = { 0,1,2 };
        for (int i = 0; i < lines.Length; i++) {
            for (int j = 0; j < lines[0].Length; j++) {
                double this_block = char.GetNumericValue (lines [i] [j]);
                int x = j - grid_dimensions / 2;
                int y = (i - grid_dimensions / 2) * -1;
                if (this_block >= 0f) {
                    blocks.Add (new Vector3 (x, y, (float)this_block));
                }
            }
        }

        // create init blocks
        foreach (Vector3 b_position in blocks) {
            int z = (int)b_position.z;
            if (z == 0) { // fixed block type
                GameObject clone = Instantiate (fixed_block, new Vector2 (b_position.x, b_position.y), Quaternion.identity) as GameObject;
            } else { //moveable block type
                GameObject clone = Instantiate (block, new Vector2 (b_position.x, b_position.y), Quaternion.identity) as GameObject;
                clone.GetComponent<SpriteRenderer> ().color = block_colors [z - 1];
                clone.transform.parent = c_holder.transform;
                //blocks_obs.Add (clone);
            }
        }

        // build level bounding box
        string[] names = new string[]{"bottom","top","left","right"};

        float wall_w = 1f;
        float line_w = 0.3f;

        Vector3[] positions = new Vector3[]{
            new Vector3 (0f, (-1f * grid_dimensions - wall_w + line_w) / 2f, 0f),
            new Vector3 (0f, (grid_dimensions + wall_w - line_w) / 2f, 0f),
            new Vector3 ((-1f * grid_dimensions - wall_w + line_w) / 2f, 0f, 0f),
            new Vector3 ((grid_dimensions + wall_w - line_w) / 2f, 0f, 0f)
        };
        Vector3[] scales = new Vector3[]{
            new Vector3 (grid_dimensions + wall_w * 2, wall_w, 0f),
            new Vector3 (grid_dimensions + wall_w * 2, wall_w, 0f),
            new Vector3 (wall_w, grid_dimensions, 0f),
            new Vector3 (wall_w, grid_dimensions, 0f)
        };

        for (int i = 0; i < names.Length; i++) {
            GameObject o = new GameObject (names [i]);
            o.transform.localScale = scales [i];
            o.transform.parent = gameObject.transform;
            o.AddComponent<BoxCollider2D> ();
            o.GetComponent<BoxCollider2D> ().sharedMaterial = default_physics_mat;
            o.transform.position = positions [i];
        }

        Physics2D.gravity = new Vector2 (0f, 0f);
        Physics.gravity = new Vector3 (0f, 0f, 0f);

        //InvokeRepeating ("ChangeGravity", 3f, 3f);
        //Invoke ("CreateEnemy", 2f);

        file_json = (TextAsset)Resources.Load (file_path + song_name);
        testData = JSON.Parse (file_json.text);
        Debug.Log ("there are " + testData.Count + " tracks for this song - you need params for each!");

        /// starts song!
        audio_source = gameObject.AddComponent<AudioSource> ();
        audio_source.clip = song_audio;
        audio_source.volume = 1f;
        audio_source.PlayScheduled (AudioSettings.dspTime + init_song_delay); // 2 second delay

        // make an index for each track (for incrementing through the notes while playing the song)
        for (int i = 0; i < testData.Count; i++) {
            track_player_idxs.Add (0);
        }
    }