public void DeleteOrbAndKinfe(SpellOrbController spellOrb) { spellOrb.DestroyOrb(); playerManager.AddPoints(); //orbExplAS.pitch = Random.Range(0.8f, 1f); orbExplAS.PlayOneShot(orbExplosionSounds[Random.Range(0, orbExplosionSounds.Count)]); }
void CreateOrb() { if (orbSpeed < 3f) //check what speed to assign to orb { float increase = ((float)GameManager.instance.level * 4) / 100; orbSpeed = defaultOrbSpeed + increase; } int rand = Random.Range(0, orbPrefabs.Length); GameObject go = Instantiate(orbPrefabs[rand], startPositions[rand].position, Quaternion.identity); SpellOrbController tempContr = go.GetComponent <SpellOrbController>(); tempContr.route = CreateRoutePoints(rand); tempContr.speed = orbSpeed; orbs.Add(tempContr); int tempRand = 0; //two particle effects for each side, which in turn have 2 spawn positions so first 2 have particle 0 and next 2 particle 1 if (rand > 1) { tempRand = 1; } spawningEffects[tempRand].GetComponent <particleController>().ChangeColor(tempContr.mainColor); //effects on spawn spawningEffects[tempRand].Play(); spawnAudio.clip = spawnAudioClips[Random.Range(0, spawnAudioClips.Length)]; spawnAudio.pitch = Random.Range(0.9f, 1.1f); spawnAudio.Play(); }
IEnumerator MoveTowardsOrb(ThrowingManager.ThrowAndDelete callback, SpellOrbController orb) { while (true) { // Move our position a step closer to the target. float step = speed * Time.deltaTime; // calculate distance to move transform.position = Vector3.MoveTowards(transform.position, target.position, step); yield return(new WaitForSeconds(0)); // Check if the position of the cube and sphere are approximately equal. if (Vector3.Distance(transform.position, target.position) <= 0.3f) { callback(orb); break; } } Destroy(this.gameObject); }
public void StartMove(Transform tar, ThrowingManager.ThrowAndDelete callback, SpellOrbController orb) { target = tar; StartCoroutine(MoveTowardsOrb(callback, orb)); }