private void OnNewTargetKeyAdded(EvtNextBeatKeyAdded msg, TargetKeyAnimationConfig config)
        {
            GameObject targetKey = null;

            if (new[] { "w", "e", "r" }.Contains(msg.Key))
            {
                targetKey = Object.Instantiate(config.TargetKeyPinkPrefab, config.Line_Top.transform);
            }
            else if (new[] { "s", "d", "f" }.Contains(msg.Key))
            {
                targetKey = Object.Instantiate(config.TargetKeyPurplePrefab, config.Line_MIddle.transform);
            }
            else if (new[] { "x", "c", "v" }.Contains(msg.Key))
            {
                targetKey = Object.Instantiate(config.TargetKeyGreenPrefab, config.Line_Bottom.transform);
            }

            if (targetKey != null)
            {
                targetKey.transform.localPosition = new Vector3(800, 0);
                targetKey.GetComponentInChildren <Text>().text = msg.Key.ToUpper();

                var animationComponent = targetKey.GetComponent <TargetKeyAnimationComponent>();
                animationComponent.Key       = msg.Key;
                animationComponent.PressTime = msg.PlannedBeatTime;
                animationComponent.Backgrounds[1].gameObject.SetActive(false);
                animationComponent.Backgrounds[2].gameObject.SetActive(false);
                animationComponent.Backgrounds[3].gameObject.SetActive(false);
                animationComponent.AnimationDuration  = config.PreviewTime;
                animationComponent.AnimationStartTime = msg.PlannedBeatTime - config.PreviewTime;
                animationComponent.AnimationPerSecond = 800 / config.PreviewTime;
                animationComponent.Id = msg.Id;
            }
        }
Beispiel #2
0
 private void AddNextBeatKeyToQueue(EvtNextBeatKeyAdded obj)
 {
     _nextKeysToPress.Enqueue(new BeatKeyInfo
     {
         Id          = obj.Id,
         BeatNo      = obj.BeatNo,
         TimeToPress = obj.PlannedBeatTime,
         KeyToPress  = obj.Key,
         State       = BeatKeyState.None,
     });
 }