private void OnCollisionEnter(Collision other) { VRDebug.Log(other.collider.name + " arrow bump", -1, other.collider); if (inFlight) { } }
public void ArrowTaken(int index, SelectEnterEventArgs args) { if (bow.debugLog) { VRDebug.Log("Arrow taken " + index); } arrowsSpawned[index].transform.localScale = Vector3.one; int killed = menuItems[index].transform.DOKill(); killed += DOTween.Kill(menuItems[index]); if (bow.debugLog) { Debug.Log("select killed " + killed); } // ? todo dont remove all listeners arrowsSpawned[index].selectEntered.RemoveAllListeners(); // make sure arrow is already unparented if (arrowsSpawned[index].transform.parent == menuItems[index].transform) { VRDebug.Log("Arrow taken not unparented!"); arrowsSpawned[index].transform.SetParent(null); } // remove the menu item Destroy(menuItems[index]); menuItems.RemoveAt(index); arrowsSpawned.RemoveAt(index); // recreate it, with a new arrow CreateMenuItem(index); // disable menu for now HideMenuItems(); }
protected override void OnSelectEntered(SelectEnterEventArgs args) { base.OnSelectEntered(args); // need to force hand to go on the string otherwise it could select something else // VRDebug.Log("Forcing hand string connection"); // if (bow.offHand.selectTarget != null && bow.offHand.selectTarget != bowString) // { // interactionManager.CancelInteractorSelection(bow.offHand); // } // interactionManager.SelectEnter(bow.offHand, bowString); // interactionManager.ForceSelect(bow.offHand, bowString); if (!(args.interactable is ArrowInteractable)) { VRDebug.Log("wrong interaction " + args.interactable.name, 5); } // get arrow currentArrow = args.interactable as ArrowInteractable; if (bow.debugLog) { VRDebug.Log("Arrow '" + currentArrow.gameObject.name + "' notched"); } isArrowArmed = false; currentArrow.ArrowSet(); currentArrow.SetBow(bow); bow.ArrowSet(); }
public void Respawn() { VRDebug.Log("Player respawning"); bow.canUse = true; health.RestoreHealth(); if (!spawnPoint) { FindSpawnPoint(); } if (spawnPoint) { rig.rig.transform.position = spawnPoint.position; rig.rig.transform.rotation = spawnPoint.rotation; } else { VRDebug.Log("No Spawn point found"); rig.rig.transform.position = Vector3.zero; rig.rig.transform.rotation = Quaternion.identity; } // velocity? // remove thrown arrows? // todo reload scene instead? // arrows, enemies, lots of stuff }
public void ReleaseArrow() { if (currentArrow != null) { var launchArrow = currentArrow; // disconnect with arrow interactionManager.CancelInteractorSelection(this); // launch or drop it if (isArrowArmed) { float normPullAmount = Mathf.InverseLerp(releaseThreshold, 1f, pullAmount); if (bow.debugLog) { VRDebug.Log("Arrow launched " + normPullAmount * 100 + "%"); } launchArrow.ArrowLaunched(normPullAmount); bow.ArrowLaunched(normPullAmount); } else { if (bow.debugLog) { VRDebug.Log("Arrow dropped"); } launchArrow.ArrowDropped(); bow.ArrowDropped(); } } bow.ArrowReleased(); // todo move up, do only if have an arrow? isArrowArmed = false; }
protected void Knockback(Vector3 point, Vector3 vel) { float mag = vel.magnitude; // todo fix VRDebug.Log("Knockback " + mag); rb.AddExplosionForce(mag, point, 1, 1.5f); }
protected virtual void LaunchForce() { SetPhysicsEnabled(true); float forceAmount = GetLaunchForce(launchPullAmount); VRDebug.Log("Launching at " + forceAmount + " force", debugContext: this); rb.AddForce(transform.forward * forceAmount, ForceMode.Impulse); }
void Die() { VRDebug.Log("Player died"); lastDeathTime = Time.time; Invoke("StartReloading", deathWaitMinDur); bow.canUse = false; EnemyManager.Instance.PlayerDefeated(); // todo death state // cannot fire arrows, time frozen? enemies frozen or something }
protected override void OnSelectExited(SelectExitEventArgs args) { base.OnSelectExited(args); if (bow.debugLog) { VRDebug.Log("Arrow exited notch"); } currentArrow.ArrowUnSet(); bow.ArrowUnSet(); currentArrow = null; }
protected override void OnSelectEntered(SelectEnterEventArgs args) { if (bow.debugLog) { VRDebug.Log("String Grabbed"); } // bowstring grabbed by player base.OnSelectEntered(args); pullingInteractor = args.interactor; bowNotch.Grabbed(); UpdateLine(); }
private void Update() { if (transform.position.y <= minHeight) { VRDebug.Log(name + " fell off the map!"); if (justDestroy) { Destroy(gameObject); } fallEvent.Invoke(); } }
protected override void OnSelectEntered(SelectEnterEventArgs args) { VRDebug.Log("Quiver new arrow"); base.OnSelectEntered(args); // spawn arrow Transform interT = args.interactor.transform; GameObject arrow = Instantiate(arrowPrefab, interT.position, interT.rotation); XRBaseInteractable arrInt = arrow.GetComponent <XRBaseInteractable>(); // force select it interactionManager.ForceSelect(args.interactor, arrInt); }
public void SpawnAllArrows() { if (bow.debugLog) { VRDebug.Log("Spawning all arrows"); } for (int i = 0; i < arrowPrefabs.Length; i++) { CreateMenuItem(i); } // curSel = -1;// force update UpdateSel(); }
public void HideMenuItems() { if (bow.debugLog) { VRDebug.Log("Hiding Arrows"); } for (int i = 0; i < menuItems.Count; i++) { menuItems[i].transform.DOKill(); menuItems[i].gameObject.SetActive(false); // menuItems[i].transform.localScale = 0.1f * Vector3.one; } }
IEnumerator Start() { yield return(new WaitForSecondsRealtime(vrTimeout)); if (!disableVR && !XRSettings.isDeviceActive) { Debug.LogWarning("No VR detected!"); } if (!disableVR && XRSettings.isDeviceActive) { VRDebug.Log("VR detected!"); } }
public void DeSpawnAllArrows() { if (bow.debugLog) { VRDebug.Log("Despawning all arrows"); } for (int i = menuItems.Count - 1; i >= 0; i--) { Destroy(menuItems[i]); } menuItems.Clear(); arrowsSpawned.Clear(); }
public void SpawnAllEnemies() { // find all spawnlocations string spawnLocString = "EnemySpawnPoint"; var splocs = GameObject.FindGameObjectsWithTag(spawnLocString); VRDebug.Log("Spawning " + splocs.Length + " Enemies"); // just spawn one at each foreach (var sploc in splocs) { SpawnEnemy(allEnemyPrefabs[0], sploc.transform); } // Debug.Break(); }
protected override void OnSelectExited(SelectExitEventArgs args) { if (bow.debugLog) { VRDebug.Log("String released"); } // bowstring released by player base.OnSelectExited(args); bowNotch.ReleaseArrow(); SetPullAmount(0); pullingInteractor = null; // todo snap animation? // todo when grabbing arrows quickly, they are being placed into the world // actually, not enough time to debug. its not gamebreaking }
protected virtual void CheckHit() { if (inFlight) { float dist = Vector3.Distance(tip.transform.position, lastPos); Vector3 dir = tip.transform.position - lastPos; Debug.DrawRay(lastPos, dir, Color.red, 5); if (Physics.SphereCast(lastPos, 0.05f, dir, out var hit, dist, collisionMask, QueryTriggerInteraction.Ignore)) { // todo piercing keep going for range or until hit a non hittable // hit something VRDebug.Log("Arrow hit " + hit.collider.name, 5, this); stopped = true; // remove physics SetPhysicsEnabled(false); // child arrow to new transform for correct scale Transform newParent = new GameObject(name + " stick").transform; newParent.SetParent(hit.collider.transform, true); newParent.position = hit.point; newParent.rotation = Quaternion.identity; transform.SetParent(newParent, false); transform.localPosition = Vector3.zero; // disable collisions rb.detectCollisions = false; // transform.SetParent(hit.collider.transform, true); groundHitTime = Time.time; ArrowHit(hit); // check hittable if (hit.collider.gameObject.TryGetComponent <IHittable>(out var hittable)) { // VRDebug.Log("Arrow hit hittable"); HitArgs args = new HitArgs(); args.isDirect = true; args.damage = damage; args.attacker = launchBow.ownerName; args.point = hit.point; args.velocity = lastVel; // Debug.Log("vel: " + rb.velocity); SetHitArgs(ref args); hittable.Hit(args); } } lastPos = tip.transform.position; lastVel = rb.velocity; } }
public void ShowMenu() { if (menuItems.Count == 0) { SpawnAllArrows(); } else { if (bow.debugLog) { VRDebug.Log("Showing Arrows"); } for (int i = 0; i < menuItems.Count; i++) { // menuItems[i].transform.localScale = displayModelScale * Vector3.one; menuItems[i].gameObject.SetActive(true); } UpdateSel(); } }
public void TakeDamage(HitArgs args) { VRDebug.Log(name + " hit by " + args.attacker + " for " + args.damage, debugContext: this); if (isDead) { VRDebug.Log(name + " is already dead", debugContext: this); return; } else if (isInvincible) { // VRDebug.Log(name + " is invincible", debugContext: this); return; } lastHitArgs = args; currentHealth -= args.damage; lastDamageTime = Time.time; damageEvent.Invoke(); if (currentHealth <= 0) { Die(); } }
protected bool TryTeleportLocation(RaycastHit hit) { // check if surface is flat float hitDotUp = Vector3.Dot(hit.normal, Vector3.up); if (hitDotUp >= verticalityThreshold) { // check if area is wide enough bool areaSizeOk = false; float checkDist = tpMinWidth; var cols = Physics.OverlapSphere(hit.point + (checkDist + 0.01f) * Vector3.up, checkDist, collisionMask, QueryTriggerInteraction.Ignore); if (cols.Length == 0) { areaSizeOk = true; } else { Debug.Log("TP blocked: Cols " + cols.Length); foreach (var col in cols) { Debug.Log("Col " + col.name); } } if (areaSizeOk) { // height check Debug.DrawRay(hit.point, Vector3.up * tpMinHeight, Color.magenta, 2); //? different mask - playercol if (!Physics.SphereCast(hit.point, tpMinWidth, Vector3.up, out var hitheight, tpMinHeight, collisionMask, QueryTriggerInteraction.Ignore)) { TeleportTo(hit.point); return(true); } else { VRDebug.Log("TP blocked by height"); } } }
protected void Die() { VRDebug.Log("Enemy " + name + " died"); foreach (var tween in myTweens) { // stop all tweening tween.Kill(); } EnemyManager.Instance.EnemyDied(this); // anim if (deathGoDetach) { // activate rbs and deactivate anim anim.enabled = false; GetComponentInChildren <RigBuilder>().enabled = false; deathGoDetach.transform.SetParent(null); Destroy(deathGoDetach, deathGoDetachDestroyDelay); ActivateRbs(deathGoDetach.transform, true); } // todo change eye color Destroy(gameObject); }
public override void ArrowHit(RaycastHit hit) { base.ArrowHit(hit); // VRDebug.Log("tp hit"); if (TryTeleportLocation(hit)) { return; } else { // raycast down to find a good spot Vector3 startPos = hit.point + hit.normal * wallOffsetDist; Debug.DrawRay(startPos, Vector3.down * tpDropDist, Color.magenta, 2); if (Physics.Raycast(startPos, Vector3.down, out var hitDown, tpDropDist, collisionMask, QueryTriggerInteraction.Ignore)) { if (TryTeleportLocation(hitDown)) { return; } } } // failed to teleport VRDebug.Log("Failed to teleport"); }
void OnDeviceLoad(string name) { VRDebug.Log("Device loaded " + name); isVRReady = true; }
void SaveSettings() { VRDebug.Log("Saving Settings..."); }
void TryLoadSettings() { VRDebug.Log("Loading Settings..."); }
protected override void OnSelectExited(SelectExitEventArgs args) { base.OnSelectExited(args); VRDebug.Log("Quiver desel"); }
protected override void OnSelectEntering(SelectEnterEventArgs args) { VRDebug.Log("Quiver selling new arrow"); base.OnSelectEntering(args); }
protected override void OnHoverEntered(HoverEnterEventArgs args) { VRDebug.Log("Quiver hover new arrow"); base.OnHoverEntered(args); }