public static void TriggerExplodion(Vector3 position, float damage, float range, NM_NoiseData noiseData) { CellSound.Post(EVENTS.STICKYMINEEXPLODE, position); _ = LightFlash(position); if (SNet.IsMaster) { var pos = position; var targets = Physics.OverlapSphere(pos, range, LayerManager.MASK_EXPLOSION_TARGETS); foreach (var target in targets) { Vector3 targetPos = target.transform.position; Agent agent = target.GetComponent <Agent>(); if (agent != null) { targetPos = agent.EyePosition; } Vector3 direction = (targetPos - position).normalized; bool hit = false; if (!Physics.Raycast(pos, direction.normalized, out RaycastHit raycastHit, range, LayerManager.MASK_EXPLOSION_BLOCKERS)) { hit = true; var comp = target.GetComponent <IDamageable>(); if (comp != null) { comp.ExplosionDamage(damage, pos, Vector3.up * 1000); } } else { GameObject mySphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); mySphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); mySphere.transform.position = raycastHit.point; var col = mySphere.GetComponent <Collider>(); var mesh = mySphere.GetComponent <MeshRenderer>(); mesh.material.color = Color.red; GameObject.Destroy(col); } #if DEBUG GameObject line = new GameObject(); line.AddComponent <LineRenderer>(); LineRenderer lineRender = line.GetComponent <LineRenderer>(); lineRender.material = new Material(Shader.Find("Sprites/Default")); lineRender.widthMultiplier = 0.05f; lineRender.SetColors(Color.green, Color.green); lineRender.SetPositions(new Vector3[] { pos, targetPos }); if (hit == false) { lineRender.SetColors(Color.red, Color.red); lineRender.SetPositions(new Vector3[] { pos, raycastHit.point }); } #endif }
private void SelectClosestRadialItem() { RadialItem lastClosest = closest; float closestDistance = 9999f; GameObject hand = GetHand(); if (closest != null && Vector3.Distance(closest.transform.position, hand.transform.position) > m_maxDistance * m_scale) { closest = null; } foreach (RadialItem item in radialItems) { if (item != closest) { item.Deselect(); } } foreach (RadialItem item in radialItems) { if (!item.Active) { continue; } float distance = Vector3.Distance(item.transform.position, hand.transform.position); if (distance < closestDistance) { closestDistance = distance; closest = item; } } if (closest != null && closest != lastClosest) { if (closestDistance < m_maxDistance * m_scale) { CellSound.Post(AK.EVENTS.GAME_MENU_SELECT_GEAR, closest.transform.position); SteamVR_InputHandler.TriggerHapticPulse(0.02f, 40f, 0.25f, Controllers.GetDeviceFromInteractionHandType(targetHand)); closest.Select(); m_lastHovered = closest; } else { closest = null; } } }
private void ChatMsgReceived(string msg) { if (msgBuffer.Contains(msg)) { return; } SteamVR_InputHandler.TriggerHapticPulse(0.1f, 40f, .75f, Controllers.GetDeviceFromInteractionHandType(InteractionHand.Offhand)); CellSound.Post(AK.EVENTS.GAME_MENU_CHANGE_PAGE, transform.position); msgBuffer.Enqueue(msg); if (msgBuffer.Count > 8) { msgBuffer.Dequeue(); } m_chatDisplay.text = ""; foreach (string chatMsg in msgBuffer) { m_chatDisplay.text += chatMsg + "\n"; } m_chatDisplay.ForceMeshUpdate(false); }
public void Activate(uint sound) { CellSound.Post(sound, ExtendedPlayerAgent.LocalPlayer.Position); }