Exemple #1
0
    public Timer Create(Callback func, CallbackWithTime _funcWithTime)
    {
        var timer = new Timer(func, _funcWithTime);

        timerList.AddLast(timer);
        return(timer);
    }
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Apply Challenge Data File Info To Challenges
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    private void ApplyChallengeDataFileInfoToChallenges()
    {
        for (int i = 0; i < Target.m_arChallenges.Length; ++i)
        {
            if (Target.m_arChallenges[i] != null)
            {
                Target.CurrentChallengeID = i;
                string path = (Application.dataPath + "/DEBUG STUFF/Challenge Data/" + Target.CurrentChallengeIDAsString + ".txt");
                if (System.IO.File.Exists(path))
                {
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(path))
                    {
                        string[] challengeData = reader.ReadToEnd().Replace("\r", "").Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
                        Target.CurrentChallenge.m_oChallengeName.EnglishTranslation = challengeData[0].Replace("ChallengeName=", "");
                        Target.CurrentChallenge.BPM = (float)System.Convert.ToDouble(challengeData[1].Replace("ChallengeBPM=", ""));
                        Target.CurrentChallenge.backingTrackDelayTime = (float)System.Convert.ToDouble(challengeData[4].Replace("BackingDelay=", ""));
#if UNITY_EDITOR
                        Target.CurrentChallenge.iosBPM = Target.CurrentChallenge.BPM;
                        Target.CurrentChallenge.iosBackingTrackDelay = Target.CurrentChallenge.backingTrackDelayTime;
#endif
                        string vol = challengeData[5].Replace("BackingVolume=", "");
                        if (vol != "N/A")
                        {
                            Target.CurrentChallenge.m_oChallengeBackingTrackInfo.m_fMaxVolume = (float)System.Convert.ToDouble(vol);
                        }


                        System.Collections.Generic.LinkedList <GameObject> children = new System.Collections.Generic.LinkedList <GameObject>();
                        while (Target.CurrentChallenge.transform.childCount > 0)
                        {
                            Transform child = Target.CurrentChallenge.transform.GetChild(0);
                            child.parent = null;
                            children.AddLast(child.gameObject);
                        }
                        foreach (GameObject child in children)
                        {
                            DestroyImmediate(child);
                        }
                        for (int j = 7; j < challengeData.Length; ++j)
                        {
                            string[] noteData = challengeData[j].Replace("NoteData=", "").Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
                            TambourineSoundsManager.SoundTypes eSoundType = (TambourineSoundsManager.SoundTypes)System.Convert.ToInt32(noteData[0]);
                            float fBeatPos = (float)System.Convert.ToDouble(noteData[1]);
                            Target.CurrentChallenge.AddNewChallengeNote(eSoundType, fBeatPos);
                        }

                        EditorUtility.SetDirty(Target.CurrentChallenge);
                    }
                }
                Target.m_arChallenges[i].gameObject.SetActive(false);
            }
        }

        if (Target.m_arChallenges[0] != null)
        {
            Target.m_arChallenges[0].gameObject.SetActive(true);
        }
    }
    public static int Run(int[] nums, int limit)
    {
        if (nums == null)
        {
            return(0);
        }

        var maxDeque = new System.Collections.Generic.LinkedList <int>();
        var minDeque = new System.Collections.Generic.LinkedList <int>();

        int res = 1;

        int l = 0;

        // find the longest subarray for every right pointer by shrinking left pointer
        for (int r = 0; r < nums.Length; ++r)
        {
            // update maxDeque with new right pointer
            while (maxDeque.Count != 0 && maxDeque.Last.Value < nums[r])
            {
                maxDeque.RemoveLast();
            }
            maxDeque.AddLast(nums[r]);

            // update minDeque with new right pointer
            while (minDeque.Count != 0 && minDeque.Last.Value > nums[r])
            {
                minDeque.RemoveLast();
            }
            minDeque.AddLast(nums[r]);

            // shrink left pointer if exceed limit
            while (maxDeque.First.Value - minDeque.First.Value > limit)
            {
                if (maxDeque.First.Value == nums[l])
                {
                    maxDeque.RemoveFirst();
                }
                if (minDeque.First.Value == nums[l])
                {
                    minDeque.RemoveFirst();
                }
                ++l;  // shrink it!
            }

            // update res
            res = Math.Max(res, r - l + 1);
        }

        return(res);
    }
Exemple #4
0
    public static System.Collections.Generic.LinkedList <int> CreatePrint(int size)
    {
        System.Collections.Generic.LinkedList <int> linkedNumbers = new System.Collections.Generic.LinkedList <int>();

        if (size < 0)
        {
            return(linkedNumbers);
        }

        for (int i = 0; i < size; i++)
        {
            linkedNumbers.AddLast(i);
            Console.WriteLine(i);
        }
        return(linkedNumbers);
    }
    public void RandomizeSfx(params AudioClip [] clips)
    {
        int   randInt   = Random.Range(0, clips.Length);
        float randPitch = Random.Range(lowPitchRange, highPitchRange);

        AudioSource audioSource = gameObject.AddComponent <AudioSource>();

        audioSource.clip   = clips[randInt];
        audioSource.pitch  = randPitch;
        audioSource.volume = soundVolume;
        audioSource.Play();

        soundSources.AddLast(audioSource);

        StartCoroutine(WaitAndDestroySound(audioSource));
    }
Exemple #6
0
    public void CallDelay(Action callback, float delay)
    {
//        StartCoroutine (delayFunc (callback,delay));
        if (callback != null)
        {
            TimeCallback tc = new TimeCallback();
            tc.ac      = callback;
            tc.time    = Time.time + delay;
            tc.deleted = false;
            if (cdic == null)
            {
                cdic = new System.Collections.Generic.LinkedList <TimeCallback>();
            }
            cdic.AddLast(tc);
            StartCoroutine(delayFunc2(tc));
        }
    }
    // Update is called once per frame
    void Update()
    {
        // Update height PID
        float yy = m_yPID.Update(m_heightTarget, transform.position.y, Time.deltaTime);

        float angle = 0;

        // Update pitch PID
        angle = ClampAngle(transform.rotation.eulerAngles.x);
        float pitch = m_pitchPID.Update(m_pitchTarget, angle, Time.deltaTime);

        // Update roll PID
        angle = ClampAngle(transform.rotation.eulerAngles.z);
        float roll = m_rollPID.Update(m_rollTarget, angle, Time.deltaTime);

        // Update yaw PID
        float eyaw = ComputeYawError(m_yawTarget, transform.rotation.eulerAngles.y);
        float yaw  = m_yawPID.Update(eyaw, Time.deltaTime);

        // Set new throttles
        engine1.SetThrottle(yy + roll - yaw);
        engine2.SetThrottle(yy - pitch + yaw);
        engine3.SetThrottle(yy - roll - yaw);
        engine4.SetThrottle(yy + pitch + yaw);

        lrEngine1.SetPosition(1, engine1.GetForce());
        lrEngine2.SetPosition(1, engine2.GetForce());
        lrEngine3.SetPosition(1, engine3.GetForce());
        lrEngine4.SetPosition(1, engine4.GetForce());

        if (m_debugging)
        {
            m_debugTargetHeight.AddLast(m_heightTarget);
            m_debugCurrentHeight.AddLast(transform.position.y);
        }
    }
Exemple #8
0
 AddLast <TValue1, TValue2>(this LinkedList <Pair <TValue1, TValue2> > linkedList, TValue1 value1, TValue2 value2)
 {
     linkedList.AddLast(new Pair <TValue1, TValue2>(value1, value2));
     return(linkedList);
 }
Exemple #9
0
    void Awake()
    {
        left    = Left.transform.rotation;
        right   = Right.transform.rotation;
        towards = Towards.transform.rotation;
        back    = Back.transform.rotation;

        for (int i = 0; i < 10; i++)
        {
            tempPlane = Instantiate(pipe, new Vector3(X, Y, ++Z) * planeScale, towards);
            listPlane.AddLast(tempPlane);
        }

        for (int i = 0; i < FirstCreate; i++)
        {
            CreatePipe();
        }
    }