private void _AttachToSnooper(bool isHumanSnooper) { if (isHumanSnooper) { m_taker = Snooper.humanSnooper; } else { m_taker = Snooper.robotSnooper; } m_taker.PickFlag(); GalaxyAudioPlayer.PlaySnooperCatchesFlagSound(); }
override protected void Awake() { base.Awake(); m_animator = GetComponent <Animator>(); m_audioSource = GetComponent <AudioSource>(); m_capsuleCollider = GetComponent <CapsuleCollider>(); if (isHuman) { s_humanSnooper = this; } else { s_robotSnooper = this; } }
private void OnTriggerEnter(Collider other) { if ((m_taker != null) || !isServer) { return; } Snooper snooper = other.GetComponent <Snooper>(); if (snooper == null) { return; } AttachToSnooper(snooper.isHuman); }
private void OnTriggerExit(Collider other) { Snooper snooper = other.gameObject.GetComponent <Snooper>(); if (snooper == null) { return; } snooper.rigidbody.velocity = Vector3.zero; if (snooper.isHuman) { snooper.transform.position = m_humanReplacePoint.transform.position; } else { snooper.transform.position = m_robotReplacePoint.transform.position; } }
private void OnTriggerEnter(Collider other) { Snooper snooper = other.GetComponent<Snooper>(); if (snooper == null) return; if((snooper == Flag.singleton.taker) && (snooper.isHuman == m_isHuman)) { if (snooper.isHuman) { Team.humanTeam.MarkFlag(); } else { Team.robotTeam.MarkFlag(); } FlagManager.singleton.ResetFlag(); } }
private void OnTriggerEnter(Collider other) { Snooper trapedSnooper = other.GetComponent <Snooper>(); if (trapedSnooper == null) { return; } if (trapedSnooper.isJumping) { return; } m_audioSource.PlayOneShot(m_triggerSound); m_particuleOnTrigger.gameObject.SetActive(true); m_particuleOnTrigger.Play(); if (NetworkServer.active) { TrapManager.RemoveTrap(this); if (trapedSnooper.isHuman) { Team.humanTeam.IncreaseTrapsTakenCount(); } else { Team.robotTeam.IncreaseTrapsTakenCount(); } } if (!trapedSnooper.hasAuthority) { return; } OnTrapTriggered(other, trapedSnooper); }
protected override void OnTrapTriggered(Collider other, Snooper trapedSnooper) { trapedSnooper.EjectSnooper(transform); }
protected override void OnTrapTriggered(Collider other, Snooper trapedSnooper) { trapedSnooper.InvertControls(); }
public override void Update() { //Sync the noclip var with the physics engine EnablePhysics = !noClip; var lookUnits = LookVelocity; // * Time.DeltaTime; var moveUnits = MoveSpeed; // * Time.DeltaTime; if (GameClient.isPaused == false) { if (InputManager.IsPressed("move.sprint")) { MoveSpeed = SprintSpeed; } else { MoveSpeed = MoveVelocity; } } // get our movement basis vectors Vector3 forward, up, right; TransformBasisVector(Vector3.Forward, out forward); TransformBasisVector(Vector3.Right, out right); if (camera.rotation.X >= 0.0f) { TransformBasisVector(Vector3.Down, out up); } else { TransformBasisVector(Vector3.Up, out up); } if (GameClient.isPaused == false) { #region Input // check keyboard for which direction to move Vector3 move = Vector3.Zero; Vector3 moveVector = Vector3.Zero; if (InputManager.IsPressed("move.forward")) { moveVector += Vector3.Forward; move += forward; move += up; } if (InputManager.IsPressed("move.back")) { moveVector += Vector3.Backward; move -= forward; move -= up; } if (InputManager.IsPressed("move.right")) { moveVector += Vector3.Left; move += right; } if (InputManager.IsPressed("move.left")) { moveVector += Vector3.Right; move -= right; } //jumping / flying if (InputManager.IsPressed("move.jump")) { if (noClip) { moveVector += Vector3.Up; move += Vector3.Up; } else if (IsGrounded) { //handle jump moveVector += Vector3.Up; move += Vector3.Up * JumpForce * 0.3f / MoveSpeed; } } //sneaking / flying down if (InputManager.IsPressed("move.sneak")) { if (noClip) { moveVector -= Vector3.Up; move -= Vector3.Up; } else { //handle sneak moveVector -= Vector3.Up; move -= Vector3.Up; MoveSpeed = SneakSpeed; } } #region Hotbar Slot Handling //Change the slot //Controller support if (InputManager.Released("hotbar.right") || InputManager.MouseScrollWheel < 0) { HeldSlot += 1; HeldSlot = FastMath.Normalise(HeldSlot, 0, 9); } if (InputManager.Released("hotbar.left") || InputManager.MouseScrollWheel > 0) { HeldSlot -= 1; HeldSlot = FastMath.Normalise(HeldSlot, 0, 9); } //Slot based on keypress if (InputManager.Released("hotbar.one")) { HeldSlot = 0; } if (InputManager.Released("hotbar.two")) { HeldSlot = 1; } if (InputManager.Released("hotbar.three")) { HeldSlot = 2; } if (InputManager.Released("hotbar.four")) { HeldSlot = 3; } if (InputManager.Released("hotbar.five")) { HeldSlot = 4; } if (InputManager.Released("hotbar.six")) { HeldSlot = 5; } if (InputManager.Released("hotbar.seven")) { HeldSlot = 6; } if (InputManager.Released("hotbar.eight")) { HeldSlot = 7; } if (InputManager.Released("hotbar.nine")) { HeldSlot = 8; } #endregion // check mouse for rotating float lx = InputManager.MouseDeltaX * LookVelocity * GameSettings.MouseSensitivity; float ly = InputManager.MouseDeltaY * LookVelocity * GameSettings.MouseSensitivity; if (GameSettings.HeadBobbing) { headBob.X += move.X * Time.DeltaTime; headBob.Y += move.Z * Time.DeltaTime; camera.offset = new Vector3(0, (float)Math.Sin(headBob.X * 5f) * 0.0625f, (float)Math.Sin(headBob.Y * 5f) * 0.125f); } // move and rotate the camera //move.Normalize(); ApplyForce(move * moveUnits); camera.Rotate(lx, ly); camera.position = position + eyePosition; rotation = camera.rotation; headRotation = new Vector2(camera.Yaw, camera.Pitch); #endregion #region Block Handling //Handle the block selection Vector2 mouseloc = new Vector2(GameClient.ViewWidth / 2 + lx, GameClient.ViewHeight / 2 + ly); LookingDir = RaytraceUtils.GetRay(mouseloc, camera.ViewMatrix, camera.ProjectionMatrix, GameClient.Viewport); rayHit = RaytraceUtils.RayTraceBlocks(LookingDir); if (rayHit != null && rayHit.typeOfHit == RayTraceResult.Type.BLOCK) { SelectedBlock = rayHit.hitVec.ToVector3Int(); } //Block placing / breaking if (BlockCooldownTimer <= 0f) { if (InputManager.IsPressed("item.break") && rayHit != null && GameClient.theWorld.GetBlockIdAt(RaytraceUtils.GetBreakBlock(rayHit)) != 0) { //TODO: breaking logic GameClient.theWorld.SetBlockAt(RaytraceUtils.GetBreakBlock(rayHit), 0, (uint)BlockBreakReason.PLAYER_CREATIVE); BlockCooldownTimer = BlockCooldown; SelectedBlock = RaytraceUtils.GetBreakBlock(rayHit); } //Block placement if (InputManager.IsPressed("item.use") && rayHit != null && GameClient.theWorld.GetBlockIdAt(RaytraceUtils.GetPlaceBlock(rayHit)) == BlockManager.AIR.Id && !Intersects(position, HeldBlock, RaytraceUtils.GetPlaceBlock(rayHit))) { //GameClient.theWorld.SetBlockAt(RaytraceUtils.GetPlaceBlock(rayHit), HeldBlock, (byte)BlockPlaceReason.PLAYER); BlockCooldownTimer = BlockCooldown; SelectedBlock = RaytraceUtils.GetPlaceBlock(rayHit); ItemManager.GetItem(inventory.items[HeldSlot].ItemID).OnUse(this, RaytraceUtils.GetBreakBlock(rayHit), SelectedBlock, BlockPlaceReason.PLAYER); } } else { BlockCooldownTimer -= GameClient.RawDeltaTime; if (!InputManager.IsPressed("item.break") && !InputManager.IsPressed("item.use")) { //none of the buttons are held //reset the timer BlockCooldownTimer = 0f; } } //Orthographic camera mode if (InputManager.IsPressed("debug.hotkey") && InputManager.Released("debug.orthographic")) { Ortho = !Ortho; } //Highlight the block after placing if (rayHit != null && rayHit.typeOfHit == RayTraceResult.Type.BLOCK) { Block id = BlockManager.GetBlock(GameClient.theWorld.GetBlockIdAt(SelectedBlock)); RenderUtils.RenderBox(id.GetBoundingBox(SelectedBlock).Offset(new Vector3(-0.5f, -0.5f, -0.5f)), GameSettings.BlockOutlineColor, GameSettings.BlockOutlineWidth); } #endregion // update previous states InputManager.CenterMouse(); //Snooping Snooper.Snoop("move.totaldistance", Vector3.Distance(previousPosition, position)); } previousPosition = position; base.Update(); }
virtual protected void OnTrapTriggered(Collider other, Snooper trapedSnooper) { }
private void _Detach() { m_taker = null; GalaxyAudioPlayer.PlaySnooperDropsFlagSound(); }