void PlayHaptic() { counter = 0; int index = Random.Range(0, sequences.Length); sequences[index].Play(HardlightSuit.Find().FindNearestFlag(transform.position)); }
private void UpdateTrackedValues() { currentAngularVelocity = MyRB.velocity; currentVelocity = MyRB.angularVelocity; angularVelocitySqr = MyRB.angularVelocity.sqrMagnitude; currentVelocitySqr = MyRB.velocity.sqrMagnitude; playerDistanceSqr = (HardlightSuit.Find().transform.position - transform.position).sqrMagnitude; }
public void CollideWithBody(HardlightSuit body, Collider col, Vector3 where) { //Default sequence, gets reassigned HapticSequence seq = body.GetSequence("pulse"); //Depending on the type of projectile that we are. switch (typeOfCollision) { case CollisionType.MinorCoinHit: //Hit the body with a simple effect name - which should be in "Resources/Haptics/<Name>" body.HitNearest(lastPosition, "click"); break; case CollisionType.SharpImpact: body.FindNearbyLocation(lastPosition); body.HitImpulse(lastPosition, body.GetSequence("pain_short"), .1f, 1, 0); //body.HitImpulse(lastPosition, Effect.Pulse, .2f, .35f, 1, 2); break; case CollisionType.ThudImpact: //This plays an effect across all found pads within a range. body.HitNearby(lastPosition, "click", BigImpactArea); break; case CollisionType.MediumCashPackHit: body.HitNearest(lastPosition, "pulse"); break; case CollisionType.SackOfGoldhit: //More helper function usage. This asset is from the Death and Dying pack (which is a very intense effect) seq = body.GetSequence("pain_short"); //This makes use of the other HitImpulse which allows for repeated effects. body.HitImpulse(lastPosition, seq, .2f, 2, 3, .15f, 1.0f); break; case CollisionType.MudBlob: seq = body.GetSequence("pulse"); body.HitImpulse(lastPosition, seq, .02f, 5, 3, .15f, 1.0f); break; } }
void Start() { suit = HardlightSuit.Find(); mySequence.LoadFromAsset(sequenceFileName); handleList = new List <HapticHandle>(); if (SpherecastStartObject == null) { Debug.LogError("[Haptic Spherecast] - [" + name + "] has a null object for where it should begin.\n", this); } }
private void StingPlayer() { var Where = HardlightSuit.Find().FindRandomLocation().Where; sting.Play(Where); float floor = Mathf.Max(.02f, .75f * (1 - beeCount / 500)); float ceiling = Mathf.Max(.25f, 1.3f * (1 - beeCount / 500)); stingCounter += UnityEngine.Random.Range(floor, ceiling); //Debug.Log(floor + " " + ceiling + " " + stingCounter + "\n", this); }
//Variable for my pitching area. void Start() { suit = HardlightSuit.Find(); MoneyFolder = new GameObject(); MoneyFolder.name = "Money Folder"; MoneyFolder.transform.position = Vector3.zero; if (transform.parent != null) { MoneyFolder.transform.SetParent(transform.parent); } StartCoroutine(StandardGame()); }
public void Collide(Collider col, Vector3 where) { #region Hit Player //Layer 31 is the default haptics layer. //This lets us check if what we hit is a 'haptic object' since thats all the Example Projectile wants to hit. if (col.gameObject.layer == NSManager.HAPTIC_LAYER) { //Debug.DrawLine(transform.position, transform.position + Vector3.up * 100, Color.cyan, 15); bool hapticCollisionOccurred = false; //Is what we hit a Hardlight Suit? HardlightSuit body = col.gameObject.GetComponent <HardlightSuit>(); //We make some assumptions about the impact point. //Our projectiles are moving fast, so we keep track of our position last frame (lastPosition) and use that instead of our current one. //I won't pretend to know what is best for your game (Desert of Danger uses a highly sophisticated predictive system because the projectiles are nearly hitscan) //This demo uses last frame to avoid tunneling and accidentally hitting the back pads. //If we hit a suit if (body != null) { CollideWithBody(body, col, where); hapticCollisionOccurred = true; } else { HardlightCollider individualCollider = col.gameObject.GetComponent <HardlightCollider>(); if (individualCollider != null) { CollideWithBody(HardlightSuit.Find(), col, where); //CollideWithHardlightCollider(individualCollider, where); hapticCollisionOccurred = true; } } if (hapticCollisionOccurred && DestroyAfterCollision) { DestroyProjectile(DestroyDelay); } } #endregion }
public void CollideWithBody(HardlightSuit body, Collider col, Vector3 where) { //Default sequence, gets reassigned HapticSequence seq = body.GetSequence("pulse"); //Depending on the type of projectile that we are. switch (typeOfCollision) { case CollisionType.Hit: //Hit the body with a simple effect name - which should be in "Resources/Haptics/<Name>" body.HitNearest(lastPosition, "double_click"); break; case CollisionType.HitImpulse: //Plays a simple impulse on the assumed impact point. body.HitImpulse(lastPosition, Effect.Pulse, .2f, .35f, 1, 2); break; case CollisionType.BigImpact: //This plays an effect across all found pads within a range. body.HitNearby(lastPosition, "buzz", BigImpactArea); break; case CollisionType.RepeatedImpulse: //More helper function usage. This asset is from the Death and Dying pack (which is a very intense effect) seq = body.GetSequence("pain_short"); //This makes use of the other HitImpulse which allows for repeated effects. body.HitImpulse(lastPosition, seq, .2f, 2, 3, .15f, 1.0f); break; } }
public bool RecieveExplosion(Explosion.ExplosionInfo info) { if (HasFlag(ExplosionResponse.None)) { return(false); } Vector3 direction = transform.position - info.explosionCenter; Vector3 blast = Vector3.Scale(direction.normalized, info.forceMultipliers); //Debug.Log("I have recieved an explosion\t" + name + "\n\tForce: " + forceMultipliers); if (HasFlag(ExplosionResponse.Rigidbody)) { if (rb != null) { if (rb.isKinematic && info.source.RemoveKinematicAttribute) { rb.isKinematic = false; rb.useGravity = true; } //Debug.Log("Applying force to " + name + "\n"); rb.AddForce(blast, ForceMode.Impulse); } } if (HasFlag(ExplosionResponse.Haptics)) { if (info.explosionSequence != null) { var Where = HardlightSuit.Find().FindNearestFlag(info.explosionCenter, 5); HardlightSuit.Find().EmanatingHit(Where, info.explosionSequence, .25f, 8); } } if (HasFlag(ExplosionResponse.Fireworks)) { //Create a visual effect at the point of impact? } if (HasFlag(ExplosionResponse.ChainReaction)) { StartCoroutine(StartChainReaction(info)); } if (HasFlag(ExplosionResponse.Destroyable)) { Destroyable breakable = GetComponent <Destroyable>(); if (breakable != null) { //Debug.Log(info.BlastStrength() + " \n" + blast + "\n"); breakable.DestroyableHit(info.BlastStrength(), blast); } } if (HasFlag(ExplosionResponse.CallScript)) { if (WhenExploded != null) { WhenExploded.Invoke(info); } //Delegate to call if (HitByExplosionDelegate != null) { HitByExplosionDelegate.Invoke(info); } } return(true); }
void Start() { suit = HardlightSuit.Find(); mySequence.LoadFromAsset(sequenceFileName); }
void Start() { suit = HardlightSuit.Find(); }
void Start() { refs = HardlightSuit.Find().Definition.SceneReferences; }
void Pitch(int index = -1) { if (index < 0) { index = WeightedRandomProjectileIndex(); //Prevent you from getting heavier hitting projectiles. index = Mathf.Clamp(index, 0, level); //for (int i = 0; i < 100; i++) //{ // index = WeightedRandomProjectileIndex(); // Debug.Log(index + "\n"); //} } GameObject go = validProjectiles[Mathf.Clamp(index, 0, validProjectiles.Length - 1)]; go = Instantiate(go, RequestSpawnPosition(), Quaternion.identity) as GameObject; //Shoot the projectile towards the player. Rigidbody rb = go.GetComponent <Rigidbody>(); //Find the world position of the target (a random node) Vector3 target = HardlightSuit.Find().FindRandomLocation().transform.position; if (CanMiss) { //A fifth of the time if (Random.Range(0, 50) > 40) { //We'll random miss the player. target += Vector3.right * Random.Range(-0.5f, 0.5f); target += Vector3.forward * Random.Range(-0.5f, 0.5f); } } //Draw a line to show where it's going. Debug.DrawLine(go.transform.position, target, Color.red, 8.0f); if (rb != null) { //Add some force to send the projectile on it's way. float speed = Random.Range(pitchSpeedRange.x, pitchSpeedRange.y) + Mathf.Clamp(2 * ((index)), 0, 15); //Clamp the speed to prevent tunneling. speed = Mathf.Clamp(speed, 5, maxSpeed); rb.AddForce((target - go.transform.position) * speed); //So we can see the speed go.name += " V = " + speed; } //Track the amount of pitches we've made counter++; //When we've pitched enough if (counter > levelUpCounter) { //Up the experience intensity Escalate(); } //Ensure the projectiles that miss are cleaned up. Destroy(go, 30); }