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; } }
private void SelectHologramPath(PressedActionArgs args) { if (hologramRecording) { return; } if (hologramPreview) { StopPreview(); } switch (args.action) { case GameAction.SELECT_FIRST_HOLOGRAM: selectedPath = 0; break; case GameAction.SELECT_SECOND_HOLOGRAM: selectedPath = 1; break; case GameAction.SELECT_THIRD_HOLOGRAM: selectedPath = 2; break; } if (!hologramPlaying) { if (recordedPaths[selectedPath].First.HasValue) { Minimap.Hologram = recordedPaths[selectedPath].First.Value.StartGlobalPosition; } else { Minimap.Hologram = null; } } }
private void dropWeapon(PressedActionArgs args) { if (getWeapon() != null) { removeWeapon(getWeapon().Owner); } }
private void Crouch(PressedActionArgs args) { isCrouching = true; movement = Movement.CROUCH; Owner.Scene.Camera.LocalPosition = Owner.Scene.Camera.LocalPosition - new Vector3(0, 9, 0); playerCameraPosition -= 9 * Vector3.Up; }
private void Jump(PressedActionArgs args) { float timer = path.LocalPositions.Count * sampleTime + time; path.Actions.Add(new Pair <Pair <float, float?>, Pair <GameAction, bool> >(new Pair <float, float?>(timer, null), new Pair <GameAction, bool>(args.action, false))); }
private void Run(PressedActionArgs args) { isRunning = true; if (movement == Movement.WALK || movement == Movement.IDLE) { movement = Movement.RUN; } }
public void StopPlayback(PressedActionArgs args) { if (handler != null) { handler(); } Owner.Scene.Destroy(Owner); }
private void Jump(PressedActionArgs args) { // TODO: Needs logic for jumping and movement. // Movement state will be the base for animation (possibly plus actual speed of the character). Rigidbody rigidbody = Owner.GetComponent <Rigidbody>(); if (rigidbody != null && rigidbody.IsGrounded) { rigidbody.AddImpulseForce(rigidbody.Mass * 40 * Vector3.Up); } }
private void Reload(PressedActionArgs args) { if (hologramRecording) { return; } Weapon weapon = getWeapon(); if (weapon == null) { return; } weapon.reload(); }
private void StopRecording(PressedActionArgs args) { foreach (Pair <Pair <float, float?>, Pair <GameAction, bool> > action in path.Actions) { if (action.First.Second == null) { action.First.Second = sampleTime * path.LocalPositions.Count + time; } } if (handler != null) { handler(path); } Owner.Scene.Destroy(Owner); }
private void Interact(PressedActionArgs args) { if (closestObject != null) { Interaction interact = closestObject.GetComponent <Interaction>(); if (canInteract()) { interact.Interact(Owner); } System.Console.WriteLine(closestObject.Name + " " + closestObjectDistance); } else { System.Console.WriteLine("No object found in radius."); } }
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; } }
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; } }
private void StartMoving(PressedActionArgs args) { isMoving++; }