Example #1
0
 void OnSelect(BeatObjectData beatObjectData)
 {
     if (_objectsUi.TryGetValue(beatObjectData.id, out var objectUi))
     {
         objectUi.OnSelectProperties();
     }
 }
Example #2
0
        void OnSelected(BeatObjectData beatObjectData)
        {
            GameObject gizmo = null;

            foreach (var modelInput in beatObjectData.modelInputsData)
            {
                if (modelInput is POSITION || modelInput is ROTATION)
                {
                    if (gizmo == null)
                    {
                        gizmo = Instantiate(instancePositionGizmo);
                        _gizmos.Add(gizmo);
                    }
                }

                if (modelInput is ROTATION rotation)
                {
                    RotationGizmo rotationGizmo = gizmo.GetComponentInChildren <RotationGizmo>();
                    rotationGizmo.enabled = true;
                    rotationGizmo.InitGizmo(beatObjectData.id, rotation);
                }

                if (modelInput is POSITION position)
                {
                    PositionGizmo positionGizmo = gizmo.GetComponent <PositionGizmo>();
                    positionGizmo.enabled = true;
                    positionGizmo.InitGizmo(beatObjectData.id, position);
                }
            }
        }
Example #3
0
        public void Init(BeatObjectData data, TimelineScroll timeline)
        {
            beatObjectData = data;
            _timeline      = timeline;

            if (beatObjectData.hasModel <APPEAR>())
            {
                _appearUI.onValueChanged.AddListener(OnSetAppear);
            }
            else
            {
                _appearUI.IsShown(false);
            }

            if (beatObjectData.hasModel <DURATION>())
            {
                _durationUI.onValueChanged.AddListener(OnSetDuration);
            }
            else
            {
                _durationUI.IsShown(false);
            }

            if (LevelEditor.instance.objectIcons.TryGetValue(data.objectTag, out Sprite sprite))
            {
                _image.sprite = sprite;
            }
            _image.color = MoveSyncData.instance.colorData.DefaultUIBeatObject;
        }
Example #4
0
        public override void Init(BeatObjectData beatObjectData)
        {
            base.Init(beatObjectData);

            _positionEnd    = beatObjectData.getModel <POSITION>().value;
            _positionOrigin = _positionEnd + new Vector3(0, -10.0f, 0);
            _speed          = beatObjectData.getModel <SPEED>().value;

            _appear   = beatObjectData.getModel <APPEAR>().value;
            _duration = beatObjectData.getModel <DURATION>().value;
            _size     = beatObjectData.getModel <SIZE>().value;

            transform.localScale *= _size;
            transform.position    = _positionOrigin;

            if (beatObjectData.tryGetModel <SHAPE>(out var shape))
            {
                _shape = shape.mesh;
                MeshFilter meshFilter = GetComponentInChildren <MeshFilter>();
                if (meshFilter)
                {
                    meshFilter.sharedMesh = _shape;
                }
            }

            _animator.speed = LevelSequencer.instance.toBPM;
        }
Example #5
0
        void Update()
        {
            // update on replaying
            if (playing != LevelSequencer.instance.songPlaying)
            {
                if (playing = LevelSequencer.instance.songPlaying)
                {
                    MoveBeatIndex();
                }
            }

            if (LevelSequencer.instance.songPlaying)
            {
                // update on moving playmarker
                float timeBPM = LevelSequencer.instance.timeBPM;
                if (lastTimeBPM > timeBPM || (timeBPM - lastTimeBPM) > 2.0f)
                {
                    MoveBeatIndex();
                }

                if (currentBeatIndex < LevelDataManager.instance.levelInfo.beatObjectDatas.Count)
                {
                    BeatObjectData nextBeatObject =
                        LevelDataManager.instance.levelInfo.beatObjectDatas[currentBeatIndex];

                    if (timeBPM > nextBeatObject.spawnTime)
                    {
                        TriggerBeatObject(nextBeatObject);
                        currentBeatIndex++;
                    }
                }

                lastTimeBPM = timeBPM;
            }
        }
Example #6
0
 void OnDeselect(BeatObjectData beatObjectData)
 {
     if (_objectsUi.TryGetValue(beatObjectData.id, out var objectUi))
     {
         objectUi.OnDeselectProperties(_selectedObjects.ContainsKey(objectUi.beatObjectData.id));
     }
 }
Example #7
0
 void OnDeselected(BeatObjectData beatObjectData)
 {
     foreach (var gizmo in _gizmos)
     {
         Destroy(gizmo);
     }
     _gizmos.Clear();
 }
Example #8
0
        public bool RemoveBeatObject(BeatObjectData beatObjectData, bool history = true)
        {
            if (history)
            {
                BackupInfo();
            }

            onRemoveObject.Invoke(beatObjectData.id);
            return(levelInfo.beatObjectDatas.Remove(beatObjectData));
        }
Example #9
0
 void OnNewElement(BeatObjectData beatObjectData)
 {
     if (beatObjectData.tryGetModel <POSITION>(out var position))
     {
         if (position.randomSpawnType != RandomSpawnType.None)
         {
             position.value           = GetRandomPoint(position);
             position.pivot           = Vector3.one;
             position.randomSpawnType = RandomSpawnType.None;
         }
     }
 }
Example #10
0
        public void CopyBeatObject(BeatObjectData beatObjectData, float time = 0.0f, int layer = 0, bool history = true)
        {
            BeatObjectData data = beatObjectData.Clone();

            data.time        = time;
            data.editorLayer = layer;

            if (history)
            {
                BackupInfo();
            }

            levelInfo.beatObjectDatas.Add(data);
            onNewObject.Invoke(data);
        }
Example #11
0
 void TriggerBeatObject(BeatObjectData beatObjectData)
 {
     if (beatObjectData.hasModel <EVENT>())
     {
         EventManager.instance.InvokeEvent(beatObjectData.getModel <EVENT>().value, beatObjectData.time);
     }
     else
     {
         BeatObject beatObject =
             Instantiate(ObjectManager.instance.objectModels[beatObjectData.objectTag].prefab)
             .GetComponent <BeatObject>();
         beatObject.Init(beatObjectData);
         beatObject.gameObject.SetActive(true);
     }
 }
Example #12
0
        public void AddObject(BeatObjectData data)
        {
            ObjectUI objectUi = Instantiate(_objectUiInstance, _rectObjectsList).GetComponent <ObjectUI>();

            objectUi.Init(data, _timeline);
            objectUi.onStartDrag.AddListener(OnStartDragObject);
            objectUi.onDrag.AddListener(OnDragObject);
            objectUi.onStopDrag.AddListener(OnStopDragObject);
            UpdateObject(objectUi);

            if (_drawOnlyBeatKeys)
            {
                objectUi.ShowOnlyKey(true);
            }

            _objectsUi.Add(objectUi.beatObjectData.id, objectUi);
        }
Example #13
0
        public override void Init(BeatObjectData beatObjectData)
        {
            base.Init(beatObjectData);

            _meshRenderer = GetComponentInChildren <MeshRenderer>();

            _appear   = beatObjectData.getModel <APPEAR>().value;
            _duration = beatObjectData.getModel <DURATION>().value;
            _size     = beatObjectData.getModel <SIZE>().value;

            if (MoveSyncData.instance.shapeData.shapes.TryGetValue(beatObjectData.getModel <SHAPE>().value, out Mesh mesh))
            {
                GetComponentInChildren <MeshFilter>().sharedMesh = mesh;
            }

            transform.localScale = Vector3.zero;
            transform.position   = beatObjectData.getModel <POSITION>().value;
        }
Example #14
0
        public override void Init(BeatObjectData beatObjectData)
        {
            base.Init(beatObjectData);

            _positionEnd    = beatObjectData.getModel <POSITION>().value;
            _positionOrigin = _positionEnd + new Vector3(0, -10.0f, 0);

            _appear   = beatObjectData.getModel <APPEAR>().value;
            _duration = beatObjectData.getModel <DURATION>().value;
            _size     = beatObjectData.getModel <SIZE>().value;
            _count    = beatObjectData.getModel <COUNT>().value;

            transform.localScale *= _size;
            transform.position    = _positionOrigin;
            _savedColor           = _meshRenderer.material.color;

            SpawnDisco();
        }
Example #15
0
        public BeatObjectData Clone()
        {
            BeatObjectData other = new BeatObjectData
            {
                objectTag       = objectTag,
                id              = SerializableGuid.NewGuid(),
                modelInputsData = ModelInput.CloneInputs(modelInputsData)
            };

            other.modelInputs = new Dictionary <Type, ModelInput>();
            for (int i = 0; i < other.modelInputsData.Length; i++)
            {
                ModelInput m = other.modelInputsData[i];
                other.modelInputs.Add(m.GetType(), m);
            }

            return(other);
        }
        public override void Init(BeatObjectData beatObjectData)
        {
            base.Init(beatObjectData);

            AnimatorStateInfo current = _animator.GetCurrentAnimatorStateInfo(0);

            _animator.Play(current.fullPathHash, 0, LevelSequencer.instance.timeBPM % 1.0f);

            _positionEnd    = beatObjectData.getModel <POSITION>().value;
            _positionOrigin = _positionEnd + new Vector3(0, -10.0f, 0);

            _appearDuration = beatObjectData.getModel <APPEAR>().value;
            _size           = beatObjectData.getModel <SIZE>().value;
            _shape          = beatObjectData.getModel <SHAPE>().mesh;

            transform.localScale *= _size;
            transform.position    = _positionOrigin;

            _animator.speed = LevelSequencer.instance.toBPM;
        }
Example #17
0
        public override void Init(BeatObjectData beatObjectData)
        {
            base.Init(beatObjectData);

            position = beatObjectData.getModel <POSITION>().value;

            appear     = beatObjectData.getModel <APPEAR>().value;
            duration   = beatObjectData.getModel <DURATION>().value;
            size       = beatObjectData.getModel <SIZE>().value;
            projectile = beatObjectData.getModel <PROJECTILE>().projectile;

            transform.position = GetSpawnPosition();
            transform.rotation = GetRotationByTargetState();

            Shoot();

            if (GetDestroyTime() < 0)
            {
                Destroy(gameObject);
            }
        }
Example #18
0
        /*
         * Object controll
         */

        public BeatObjectData NewBeatObject(ObjectModel objectModel, float time = 0.0f, int layer = 0, bool history = true)
        {
            BeatObjectData data = new BeatObjectData
            {
                objectTag       = objectModel.objectTag,
                id              = SerializableGuid.NewGuid(),
                time            = time,
                editorLayer     = layer,
                modelInputsData = ModelInput.CloneInputs(objectModel.modelInput),
            };

            if (history)
            {
                BackupInfo();
            }

            levelInfo.beatObjectDatas.Add(data);
            onNewObject.Invoke(data);
            SortBeatObjects();

            return(data);
        }
Example #19
0
        void OnDragObject(ObjectUI objectUi)
        {
            List <int> keys = new List <int>(_selectedObjects.Keys);

            foreach (var key in keys)
            {
                SelectedObjectData newSelectedObject = _selectedObjects[key];
                BeatObjectData     data = newSelectedObject.beatObjectData;

                // offsetting beat objects while moving
                if (!InputData.shouldOnlyLayer)
                {
                    data.time = Mathf.Max(0, mouseTime + newSelectedObject.offset);
                }
                data.editorLayer = Mathf.Max(0, mouseLayer + newSelectedObject.offsetLayer);
                if (InputData.shouldSnap)
                {
                    data.time = Mathf.Round(data.time);
                }

                UpdateObject(newSelectedObject.objectUi);
            }
        }
Example #20
0
 public virtual void Init(BeatObjectData beatObjectData)
 {
     _beatObjectData = beatObjectData;
     _spawnTimeBPM   = beatObjectData.spawnTime;
 }