Example #1
0
        private void SwitchMovement(bool isCrouching, bool isRunning)
        {
            AnimationController contr = Owner.GetComponent <AnimationController>();
            string mov1 = (this.isCrouching ? "crouch" : (this.isRunning ? "run" : "walk"));

            this.isCrouching = isCrouching; this.isRunning = isRunning;
            string mov2 = (isCrouching ? "crouch" : (isRunning ? "run" : "walk"));

            if (contr.StopAnimation(mov1 + "Forward", 0.2f))
            {
                contr.PlayAnimation(mov2 + "Forward", 1, 0.2f);
            }
            if (contr.StopAnimation(mov1 + "Backward", 0.2f))
            {
                contr.PlayAnimation(mov2 + "Backward", 1, 0.2f);
            }
            if (contr.StopAnimation(mov1 + "Left", 0.2f))
            {
                contr.PlayAnimation(mov2 + "Left", 1, 0.2f);
            }
            if (contr.StopAnimation(mov1 + "Right", 0.2f))
            {
                contr.PlayAnimation(mov2 + "Right", 1, 0.2f);
            }
            if (isCrouching)
            {
                contr.SetBindPose("crouchForward", 0.2f);
            }
            else
            {
                contr.SetBindPose("death", 0.2f);
            }
        }
Example #2
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;
            }
        }
Example #3
0
        protected override void HandleDeath()
        {
            decisionTree.InterruptCurrentDecision();
            StopMoving(null);
            Minimap.Enemies.Remove(Owner);
            if (weapon != null)
            {
                weapon.Destroy();
            }
            AnimationController contr = Owner.GetComponent <AnimationController>();

            if (contr != null)
            {
                contr.StopAllAnimations(0.2f);
                contr.PlayAnimation("death", 100, 0f);
                contr.SetBindPose("death", 0.2f, 1);
            }
            List <Component> comps = Owner.GetComponents <Component>();

            foreach (Component comp in comps)
            {
                if (!(comp is AnimationController) && !(comp is MeshInstance))
                {
                    comp.Enabled = false;
                }
            }
        }
Example #4
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;
            }
        }