Exemplo n.º 1
0
        // Update data: move shot
        public void OnMoveShot(int offset)
        {
            ShotManager sm = ShotManager.Instance;

            int shotIndex = shotList.CurrentIndex;

            if (offset < 0 && shotIndex <= 0)
            {
                return;
            }
            if (offset > 0 && shotIndex >= (sm.shots.Count - 1))
            {
                return;
            }

            // Send network message
            ShotManagerActionInfo info = new ShotManagerActionInfo
            {
                action     = ShotManagerAction.MoveShot,
                shotIndex  = shotIndex,
                moveOffset = offset
            };

            new CommandShotManager(info).Submit();
            shotList.CurrentIndex = shotIndex + offset;
            // Rebuild UI
            OnShotManagerChanged();
        }
Exemplo n.º 2
0
        public void OnSetCamera(Shot shot)
        {
            ShotManager           sm        = ShotManager.Instance;
            int                   shotIndex = sm.GetShotIndex(shot);
            ShotManagerActionInfo oldInfo   = new ShotManagerActionInfo
            {
                action    = ShotManagerAction.UpdateShot,
                shotIndex = shotIndex,
                camera    = shot.camera,
            };

            ShotManagerActionInfo info = oldInfo.Copy();

            info.camera = CameraManager.Instance.ActiveCamera;

            new CommandShotManager(oldInfo, info).Submit();

            // Update Camera UI Button
            ShotItem uiItem = GetShotItem(shotIndex);

            if (null != info.camera)
            {
                uiItem.cameraNameLabel.Text = info.camera.name;
            }
            else
            {
                uiItem.cameraNameLabel.Text = "";
            }
        }
Exemplo n.º 3
0
        public void OnUpdateShotEnd(Shot shot, float value)
        {
            ShotManager sm = ShotManager.Instance;

            int intValue   = Mathf.FloorToInt(value);
            int startValue = shot.start;

            if (intValue < startValue)
            {
                intValue = startValue;
            }

            // Send network message
            ShotManagerActionInfo oldInfo = new ShotManagerActionInfo
            {
                action    = ShotManagerAction.UpdateShot,
                shotIndex = sm.GetShotIndex(shot),
                shotEnd   = shot.end,
            };

            ShotManagerActionInfo info = oldInfo.Copy();

            info.shotEnd = intValue;
            shot.end     = intValue;

            new CommandShotManager(oldInfo, info).Submit();

            UpdateShotItemsColors(GlobalState.Animation.CurrentFrame);
        }
Exemplo n.º 4
0
        // Update data: delete shot
        public void OnDeleteShot()
        {
            ShotManager sm = ShotManager.Instance;

            if (shotList.CurrentIndex == -1)
            {
                return;
            }

            // Delete the current shot
            int  shotIndex = shotList.CurrentIndex;
            Shot shot      = sm.shots[shotIndex];

            // Send network message
            ShotManagerActionInfo info = new ShotManagerActionInfo
            {
                action      = ShotManagerAction.DeleteShot,
                shotName    = shot.name,
                camera      = shot.camera,
                shotStart   = shot.start,
                shotEnd     = shot.end,
                shotColor   = shot.color,
                shotEnabled = shot.enabled ? 1 : 0,
                shotIndex   = shotIndex
            };

            new CommandShotManager(info).Submit();
            // Rebuild UI
            OnShotManagerChanged();
        }
Exemplo n.º 5
0
        // Update data: add a shot
        public void OnAddShot()
        {
            ShotManager sm = ShotManager.Instance;

            // Take the current shot to find the start frame of the new shot
            // Keep same camera as the current shot if anyone
            int        start = GlobalState.Animation.CurrentFrame;
            GameObject camera;

            if (shotList.CurrentIndex != -1)
            {
                Shot selectedShot = sm.shots[shotList.CurrentIndex];
                start  = selectedShot.end + 1;
                camera = CameraManager.Instance.ActiveCamera != null ? CameraManager.Instance.ActiveCamera : selectedShot.camera;
            }
            else
            {
                camera = CameraManager.Instance.ActiveCamera;
            }
            int end = start + 50;  // arbitrary duration

            end = Mathf.Min(end, GlobalState.Animation.EndFrame);

            // Look at all the shots to find a name for the new shot
            string name = sm.GetUniqueShotName();

            Shot shot = new Shot {
                name = name, camera = camera, enabled = true, end = end, start = start
            };
            int shotIndex = shotList.CurrentIndex;

            // Send network message
            ShotManagerActionInfo info = new ShotManagerActionInfo
            {
                action      = ShotManagerAction.AddShot,
                camera      = camera,
                shotIndex   = shotIndex,
                shotName    = shot.name,
                shotStart   = start,
                shotEnd     = end,
                shotEnabled = 1,
                shotColor   = Color.blue // TODO: find a unique color
            };

            new CommandShotManager(info).Submit();
            // Add the shot to ShotManager singleton
            shotIndex++;
            sm.SetCurrentShotIndex(shotIndex);

            // Rebuild UI
            OnShotManagerChanged();
        }
Exemplo n.º 6
0
        public void OnUpdateShotColor(Shot shot, Color value)
        {
            ShotManager sm = ShotManager.Instance;

            // Send network message
            ShotManagerActionInfo oldInfo = new ShotManagerActionInfo
            {
                action    = ShotManagerAction.UpdateShot,
                shotIndex = sm.GetShotIndex(shot),
                shotColor = shot.color
            };

            ShotManagerActionInfo info = oldInfo.Copy();

            info.shotColor = value;
            shot.color     = value;

            new CommandShotManager(oldInfo, info).Submit();
        }
Exemplo n.º 7
0
        public void OnUpdateShotName(Shot shot, string value)
        {
            ShotManager sm = ShotManager.Instance;

            // Send network message
            ShotManagerActionInfo oldInfo = new ShotManagerActionInfo
            {
                action    = ShotManagerAction.UpdateShot,
                shotIndex = sm.GetShotIndex(shot),
                shotName  = shot.name
            };

            ShotManagerActionInfo info = oldInfo.Copy();

            info.shotName = value;
            shot.name     = value;

            new CommandShotManager(oldInfo, info).Submit();
            OnShotManagerChanged();
        }
Exemplo n.º 8
0
        public void OnUpdateShotEnabled(Shot shot, bool value)
        {
            Assert.IsTrue(ShotManager.Instance.ActiveShotIndex >= 0); // TODO: voir si le probleme persiste une fois que le rayon fonctionne.

            ShotManager sm = ShotManager.Instance;

            // Send network message
            ShotManagerActionInfo oldInfo = new ShotManagerActionInfo
            {
                action      = ShotManagerAction.UpdateShot,
                shotIndex   = sm.GetShotIndex(shot),
                shotEnabled = shot.enabled ? 1 : 0
            };

            ShotManagerActionInfo info = oldInfo.Copy();

            info.shotEnabled = value ? 1 : 0;
            shot.enabled     = value;

            new CommandShotManager(oldInfo, info).Submit();
        }
Exemplo n.º 9
0
        // Duplicate Shot
        public void OnDuplicateShot()
        {
            ShotManager sm = ShotManager.Instance;

            // Take the current shot to find the start frame of the new shot
            // Keep same camera as the current shot if anyone
            if (shotList.CurrentIndex == -1)
            {
                return;
            }

            Shot shot = sm.shots[shotList.CurrentIndex].Copy();

            shot.name = sm.GetUniqueShotName();
            int shotIndex = shotList.CurrentIndex;

            // Send network message
            ShotManagerActionInfo info = new ShotManagerActionInfo
            {
                action      = ShotManagerAction.AddShot,
                camera      = shot.camera,
                shotIndex   = shotIndex,
                shotName    = shot.name,
                shotStart   = shot.start,
                shotEnd     = shot.end,
                shotEnabled = shot.enabled ? 1 : 0,
                shotColor   = Color.blue // TODO: find a unique color
            };

            new CommandShotManager(info).Submit();

            // Add the shot to ShotManager singleton
            shotIndex++;
            sm.SetCurrentShotIndex(shotIndex);

            // Rebuild UI
            OnShotManagerChanged();
        }
Exemplo n.º 10
0
        // Shot Manager
        public static void ApplyShotManagegrAction(ShotManagerActionInfo info)
        {
            switch (info.action)
            {
            case ShotManagerAction.AddShot:
            {
                GameObject cam  = info.camera;
                Shot       shot = new Shot()
                {
                    name    = info.shotName,
                    camera  = cam,
                    color   = info.shotColor,
                    start   = info.shotStart,
                    end     = info.shotEnd,
                    enabled = info.shotEnabled == 1
                };
                ShotManager.Instance.InsertShot(info.shotIndex + 1, shot);
            }
            break;

            case ShotManagerAction.DeleteShot:
            {
                ShotManager.Instance.RemoveShot(info.shotIndex);
            }
            break;

            case ShotManagerAction.DuplicateShot:
            {
                ShotManager.Instance.DuplicateShot(info.shotIndex);
            }
            break;

            case ShotManagerAction.MoveShot:
            {
                ShotManager.Instance.SetCurrentShotIndex(info.shotIndex);
                ShotManager.Instance.MoveShot(info.shotIndex, info.moveOffset);
            }
            break;

            case ShotManagerAction.UpdateShot:
            {
                Shot shot = ShotManager.Instance.shots[info.shotIndex];
                if (info.shotName.Length > 0)
                {
                    shot.name = info.shotName;
                }
                if (null != info.camera)
                {
                    shot.camera = info.camera;
                }
                if (info.shotColor.r != -1)
                {
                    shot.color = info.shotColor;
                }
                if (info.shotStart != -1)
                {
                    shot.start = info.shotStart;
                }
                if (info.shotEnd != -1)
                {
                    shot.end = info.shotEnd;
                }
                if (info.shotEnabled != -1)
                {
                    shot.enabled = info.shotEnabled == 1;
                }
            }
            break;
            }
            ShotManager.Instance.FireChanged();
            Instance.scene.ApplyShotManagerAction(info);
        }
Exemplo n.º 11
0
 public void ApplyShotManagerAction(ShotManagerActionInfo info)
 {
 }