Exemplo n.º 1
0
        private void RecordingButton(PressedActionArgs args)
        {
            Rigidbody rig = Owner.GetComponent <Rigidbody>();

            if (!hologramRecording && !hologramPlaying && (rig == null || rig.IsGrounded || !rig.GravityEnabled))
            {
                GameObject hologramRecording = new GameObject("HologramRecorder", Owner.LocalPosition,
                                                              Owner.LocalQuaternionRotation, Owner.LocalScale, Owner.Scene, Owner.Parent);
                hologramRecording.AddComponent(new HologramRecorder(5.0f, 100, StopRecording));
                hologramRecording.AddComponent(new Rigidbody(Owner.GetComponent <Rigidbody>()));
                Collider holCol = hologramRecording.AddNewComponent <Collider>();
                Bounding_Volumes.BoundingBox bound = (Owner.GetComponent <Collider>().bound as Bounding_Volumes.BoundingBox);
                holCol.bound = new Bounding_Volumes.BoundingBox(holCol, bound.Center, new Vector3(bound.HalfLength, bound.HalfHeight, bound.HalfWidth));
                MeshInstance mesh = Owner.GetComponent <MeshInstance>();
                if (mesh != null)
                {
                    hologramRecording.AddComponent(new MeshInstance(mesh));
                }
                if (PlayerMesh != null)
                {
                    Owner.AddComponent(PlayerMesh);
                    AnimationController contr = Owner.AddNewComponent <AnimationController>();
                    contr.BindAnimation("idle", isCrouching ? 7 : 6, true);
                    contr.PlayAnimation("idle");
                }
                Stay(null);
                if (getWeapon() != null)
                {
                    getWeapon().Owner.IsVisible = false;
                }
                player         = Owner;
                playerRotation = Owner.LocalQuaternionRotation;
                Vector3 rotation = Owner.LocalEulerRotation;
                Owner.RemoveComponent(this);
                hologramRecording.AddComponent(this);
                Owner.Scene.Camera.Parent = hologramRecording;
                rotation.Y = 0; rotation.Z = 0;
                player.LocalEulerRotation = rotation;
                this.hologramRecording    = true;
            }
        }
Exemplo n.º 2
0
        private void PreviewHologram(PressedActionArgs args)
        {
            if (hologramPreview)
            {
                StopPreview();
                return;
            }

            if (!hologramRecording && !hologramPlaying && recordedPaths[selectedPath].First.HasValue)
            {
                preview = new GameObject("HologramPreview", Owner.LocalPosition, Owner.LocalQuaternionRotation,
                                         Owner.LocalScale, Owner.Scene, Owner.Parent);
                Minimap.Hologram = preview;
                preview.AddComponent(new HologramPlayback(recordedPaths[selectedPath].First.Value, StopPreview));
                if (PreviewMesh != null)
                {
                    preview.AddComponent(PreviewMesh);
                    AnimationController anim = preview.AddNewComponent <AnimationController>();
                    anim.BindAnimation("runForward", 1, true);
                    anim.BindAnimation("runBackward", 1, true);
                    anim.BindAnimation("runLeft", 1, true);
                    anim.BindAnimation("runRight", 1, true);
                    anim.BindAnimation("walkForward", 2, true);
                    anim.BindAnimation("walkBackward", 2, true);
                    anim.BindAnimation("walkLeft", 2, true);
                    anim.BindAnimation("walkRight", 2, true);
                    anim.BindAnimation("death", 3);
                    anim.BindAnimation("jump", 4);
                    anim.BindAnimation("crouchForward", 5, true);
                    anim.BindAnimation("crouchBackward", 5, true);
                    anim.BindAnimation("crouchLeft", 5, true);
                    anim.BindAnimation("crouchRight", 5, true);
                    anim.SetBindPose(isCrouching ? PreviewMesh.Model.Clips[5] : PreviewMesh.Model.Clips[3]);
                }
                hologramPreview = true;
            }
        }
Exemplo n.º 3
0
        private void PlaybackButton(PressedActionArgs args)
        {
            if (!hologramRecording && !hologramPlaying && recordedPaths[selectedPath].First.HasValue && !(recordedPaths[selectedPath].Second > 0.0f))
            {
                StopPreview();

                hologramPlayback = new GameObject("HologramPlayback", Owner.LocalPosition, Owner.LocalQuaternionRotation,
                                                  Owner.LocalScale, Owner.Scene, Owner.Parent);
                Minimap.Hologram = hologramPlayback;
                hologramPlayback.AddComponent(new HologramPlayback(recordedPaths[selectedPath].First.Value, StopPlayback));
                recordedPaths[selectedPath].Second = recordedPaths[selectedPath].First.Value.Duration;
                if (HologramMesh != null)
                {
                    hologramPlayback.AddComponent(HologramMesh);
                    AnimationController anim = hologramPlayback.AddNewComponent <AnimationController>();
                    anim.BindAnimation("runForward", 1, true);
                    anim.BindAnimation("runBackward", 1, true);
                    anim.BindAnimation("runLeft", 1, true);
                    anim.BindAnimation("runRight", 1, true);
                    anim.BindAnimation("walkForward", 2, true);
                    anim.BindAnimation("walkBackward", 2, true);
                    anim.BindAnimation("walkLeft", 2, true);
                    anim.BindAnimation("walkRight", 2, true);
                    anim.BindAnimation("death", 3);
                    anim.BindAnimation("jump", 4);
                    anim.BindAnimation("crouchForward", 5, true);
                    anim.BindAnimation("crouchBackward", 5, true);
                    anim.BindAnimation("crouchLeft", 5, true);
                    anim.BindAnimation("crouchRight", 5, true);
                    anim.SetBindPose(isCrouching ? HologramMesh.Model.Clips[5] : HologramMesh.Model.Clips[3]);
                }
                this.hologramPlaying = true;
                playingPath          = selectedPath;
            }
        }