Beispiel #1
0
 public virtual void ToLayer(LayerUI layer)
 {
     LayerUI = layer;
     if (Entity != null)
     {
         StartCoroutine(IEToLayer());
     }
 }
Beispiel #2
0
    void Awake()
    {
        layer1 = GetChild <LayerUI>("Layer1");
        layer2 = GetChild <LayerUI>("Layer2");
        layer3 = GetChild <LayerUI>("Layer3");

        pageMesText        = GetChild <Text>("PageMesText");
        newLayerButton     = GetChild <Button>("NewLayer");
        deleteLayerButton  = GetChild <Button>("DeleteLayer");
        persiousPageButton = GetChild <Button>("PreviousPage");
        nextPageButton     = GetChild <Button>("NextPage");

        newLayerButton.onClick.AddListener(NewLayerButton);
        deleteLayerButton.onClick.AddListener(DeleteLayerButton);
        persiousPageButton.onClick.AddListener(PersiousPageButton);
        nextPageButton.onClick.AddListener(NextPageButton);
        Init();
        Invoke("InitLayer", 1);
    }
Beispiel #3
0
    /// <summary>
    /// Update the note state.
    /// </summary>
    /// <param name="relativeTime">The time relative to the note start (the note should be played when its value is 0).</param>
    /// <param name="layerUI"></param>
    /// <param name="index"></param>
    public bool UpdateNote(float relativeTime, LayerUI layerUI, int index, float layerProgress, out KeyCode invalidKeyPressed, GameObject fx, GameObject fxError, float fillAmount, bool dontDisplayError)
    {
        invalidKeyPressed = KeyCode.None;
        bool validKeyPressed = false;
        if (Input.GetKeyDown(this.InputKey))
        {
            float fxPlacement = relativeTime / Tolerance;
            if (relativeTime >= -Tolerance && relativeTime <= Tolerance)
            {
                if (float.IsNaN(this.Accuracy) && relativeTime >= 0)
                {
                    this.Accuracy = Mathf.Clamp01(Tolerance - Mathf.Abs(relativeTime)) / Tolerance;
                    validKeyPressed = true;
                    if (layerUI != null)
                    {
                        layerUI.DisplayFx(index, fxPlacement, fx);
                    }
                }
                else if (float.IsNaN(this.NextAccuracy) && relativeTime < 0)
                {
                    this.NextAccuracy = Mathf.Clamp01(Tolerance - Mathf.Abs(relativeTime)) / Tolerance;
                    validKeyPressed = true;
                    if (layerUI != null)
                    {
                        layerUI.DisplayFx(index, fxPlacement, fx);
                    }
                }
                else
                {
                    invalidKeyPressed = this.InputKey;

                    if (!dontDisplayError && layerUI != null && invalidKeyPressed != KeyCode.None)
                    {
                        layerUI.DisplayFx(index, fxPlacement, fxError);
                    }
                }
            }
            else
            {
                invalidKeyPressed = this.InputKey;

                if (!dontDisplayError && layerUI != null && invalidKeyPressed != KeyCode.None)
                {
                    layerUI.DisplayFx(index, fxPlacement, fxError);
                }
            }
        }

        if (relativeTime >= 0 && !this.alreadyPlayed)
        {
            AudioManager.Instance.Play(this.AudioClipLite);
            AudioManager.Instance.Play(this.AudioClipFat, layerProgress);
            this.alreadyPlayed = true;

            switch (this.Action)
            {
                case Action.ChangeBackgroundColor:
                    GameManager.Instance.ChangeBackgroundColor();
                    break;

                case Action.PlaySmokeLeft:
                    GameManager.Instance.PlaySmokeLeft();
                    break;

                case Action.PlaySmokeRight:
                    GameManager.Instance.PlaySmokeRight();
                    break;

                case Action.EmitABassParticule1:
                    GameManager.Instance.EmitBassParticle(0);
                    break;

                case Action.EmitABassParticule2:
                    GameManager.Instance.EmitBassParticle(1);
                    break;

                case Action.EmitABassParticule3:
                    GameManager.Instance.EmitBassParticle(2);
                    break;

                case Action.EndGame:
                    GameManager.Instance.EndGame();
                    break;
            }
        }
        else if (relativeTime >= -this.AnimAdvance && !this.animAlreadyPlayed)
        {
            if (layerUI != null)
            {
                layerUI.DisplayInputKey(index);
            }

            this.animAlreadyPlayed = true;
        }

        if (layerUI != null)
        {
            layerUI.UpdateNote(index, fillAmount);
        }

        return validKeyPressed;
    }
Beispiel #4
0
    public void UpdateLayer(float time, LayerUI layerUI, GameObject fx, GameObject fxError)
    {
        float startTimeWithDelay = this.startTime + this.StartingDelay;

        float timeSinceLayerStart = time - startTimeWithDelay;
        float timeSinceCurrentLoopStart = timeSinceLayerStart > 0
            ? timeSinceLayerStart%this.TimesByLoop
            : timeSinceLayerStart;

        if ((int) timeSinceLayerStart/(int) this.TimesByLoop > this.loopCount)
        {
            this.loopCount++;
            for (int index = 0; index < this.Notes.Count; index++)
            {
                this.Notes[index].Reset();
            }
        }

        this.validKeyPressed.Clear();
        this.invalidKeyPressed.Clear();
        for (int index = 0; index < this.Notes.Count; index++)
        {
            Note note = this.Notes[index];

            float relativeTime = timeSinceCurrentLoopStart - note.StartTime;
            
            if (Mathf.Abs(timeSinceCurrentLoopStart - this.TimesByLoop) < relativeTime)
            {
                relativeTime = timeSinceCurrentLoopStart - this.TimesByLoop;
            }

            // Try to know if some other note override my need for error feedback.
            bool dontDisplayError = false;
            for (int j = 0; j < index; j++)
            {
                if (relativeTime <= this.Notes[j].StartTime + Note.Tolerance && this.Notes[j].InputKey == note.InputKey)
                {
                    dontDisplayError = true;
                }
            }

            for (int j = index + 1; j < this.Notes.Count; j++)
            {
                if (relativeTime > note.StartTime + Note.Tolerance && this.Notes[j].InputKey == note.InputKey)
                {
                    dontDisplayError = true;
                }
            }

            // Test the note.
            KeyCode invalidKeyPressed;
            if (note.UpdateNote(relativeTime, layerUI, index, this.Progress, out invalidKeyPressed, fx, fxError, this.Progress, dontDisplayError))
            {
                this.validKeyPressed.Add(note.InputKey);
                
                if (relativeTime >= 0f)
                {
                    this.Score += note.Accuracy;
                }
                else
                {
                    this.Score += note.NextAccuracy;
                }
            }
            else
            {
                if (relativeTime >= 0f)
                {
                    if (float.IsNaN(note.Accuracy) && float.IsNaN(note.NextAccuracy) && !note.AlreadyFailed &&
                        timeSinceCurrentLoopStart > note.StartTime + Note.Tolerance)
                    {
                       // Debug.Log(string.Format("Fail: acc: {0} next acc: {1} loop: {2}", note.Accuracy,
                                //note.NextAccuracy, this.loopCount));

                        this.Score--;
                        note.AlreadyFailed = true;
                    }
                }
            }

            if (invalidKeyPressed != KeyCode.None)
            {
                this.invalidKeyPressed.Add(invalidKeyPressed);
            }
        }

        // If keys have been pressed outside range of any note, decrease the score.
        for (int index = 0; index < this.validKeyPressed.Count; index++)
        {
            this.invalidKeyPressed.RemoveAll(match => match == this.validKeyPressed[index]);
        }

        if (this.invalidKeyPressed.Count > 0)
        {
            this.OnErrorAppend(this.invalidKeyPressed.Count);
        }
    }