public float verticalRotationOffset; //Degree rotation of aim angle in the y direction public override void SpawnSpell(PlayerComponent.Buf data) { Vector3 spawnAngle = data.vectorList[0]; Vector3 spawnPosition = data.vectorList[1]; float nPhi; nPhi = Mathf.Max(Mathf.Acos(spawnAngle.y) + (90 - verticalRotationOffset) * Mathf.PI / 180, Mathf.PI / 2); Vector3 rotated = new Vector3(spawnAngle.x, 0, spawnAngle.z); rotated = Vector3.Normalize(rotated); rotated = Vector3.Normalize(rotated) * -Mathf.Cos(nPhi); rotated.y = Mathf.Sin(nPhi); // Spawn our spell in the place the server told us // However if we are the client, we don't wait for that luxury. GameObject spawn = GameObject.Instantiate(itemToSpawn, spawnPosition + transform.TransformDirection(spawnOffset), transform.rotation); Rigidbody r; if (r = spawn.GetComponent <Rigidbody>()) { r.AddForce((rotated) * spawnSpeed); } OnSpellSpawned(spawn); }
public virtual void SpawnSpell(PlayerComponent.Buf data) { Vector3 spawnAngle = data.vectorList[0]; Vector3 spawnPosition = data.vectorList[1]; // Spawn our spell in the place the server told us // However if we are the client, we don't wait for that luxury. GameObject spawn = GameObject.Instantiate(itemToSpawn, spawnPosition + transform.TransformDirection(spawnOffset), transform.rotation); Rigidbody r; if (r = spawn.GetComponent <Rigidbody>()) { r.AddForce(spawnAngle * spawnSpeed); } OnSpellSpawned(spawn); if (data.intList [0] == 1) // called if grounded { } else // called if player hit or not grounded { spawn = GameObject.Instantiate(itemToSpawnAlt, spawnPosition + transform.TransformDirection(spawnOffset), transform.rotation); OnSpellSpawned(spawn); } }
public override void SpawnSpell(PlayerComponent.Buf data) { Vector3 spawnAngle = data.vectorList[0]; Vector3 spawnPosition = data.vectorList[1]; // Spawn our spell in the place the server told us // However if we are the client, we don't wait for that luxury. GameObject spawn = GameObject.Instantiate(itemToSpawn, spawnPosition + transform.TransformDirection(spawnOffset), transform.rotation); Rigidbody r; Quaternion aimAngle = Quaternion.LookRotation(spawnAngle); flameSpawned = GameObject.Instantiate(FlameThrowerEffect, spawnPosition + transform.TransformDirection(spawnOffset), aimAngle); if (r = spawn.GetComponent <Rigidbody>()) { r.AddForce(spawnAngle * spawnSpeed); } OnSpellSpawned(spawn); Destroy(flameSpawned, lifetime); PlayerStats sourcePlayerStats = GetComponentInParent <PlayerStats>(); HitManager.HitClientside(new HitArguments(sourcePlayerStats.gameObject, sourcePlayerStats.gameObject).withEffect(effect).withEffectDuration(cooldown)); }
public override void SpawnSpell(PlayerComponent.Buf data) { Vector3 spawnPosition = data.vectorList[0]; GameObject spawn = GameObject.Instantiate(itemToSpawn, spawnPosition + transform.TransformDirection(spawnOffset), transform.rotation); OnSpellSpawned(spawn); }
public virtual void SpawnSpell(PlayerComponent.Buf data) { Vector3 spawnPosition = data.vectorList[0]; // Spawn our spell in the place the server told us // However if we are the client, we don't wait for that luxury. GameObject spawn = GameObject.Instantiate(itemToSpawn, spawnPosition + transform.TransformDirection(spawnOffset), transform.rotation); OnSpellSpawned(spawn); }
public override void SpawnSpell(PlayerComponent.Buf data) { Vector3 spawnAngle = data.vectorList[0]; Vector3 spawnPosition = data.vectorList[1]; Ray ray1 = new Ray(spawnPosition, spawnAngle); ray1 = new Ray(ray1.origin, new Vector3(ray1.direction.x, 0, ray1.direction.z)); Ray ray2 = new Ray(ray1.origin, new Vector3(0, -1, 0)); check = 0; layer = 1 << 11; SpawnSpell(data, 0, ray1, ray2); }
public IEnumerator spawnDelay(PlayerComponent.Buf data, int it, Ray ray1, Ray ray2) { yield return(new WaitForSeconds(delay)); float offset = spawnRange / numSpawns; ray1 = new Ray(ray1.origin + ray1.direction * offset, ray1.direction); it++; if (it < numSpawns) { SpawnSpell(data, it, ray1, ray2); } }
public GameObject castOne(PlayerComponent.Buf data, ref Ray ray1, ref Ray ray2, ref int it) { GameObject spawn; RaycastHit hit; if (Physics.Raycast(ray1, out hit, offset, layer)) { Ray temp = ray1; ray1 = new Ray(ray1.origin, -ray2.direction); ray2 = temp; spawn = castOne(data, ref ray1, ref ray2, ref it); } else { spawn = castTwo(data, ref ray1, ref ray2, ref it); } return(spawn); }
public void SpawnSpell(PlayerComponent.Buf data, int it, Ray ray1, Ray ray2) { offset = spawnRange / numSpawns; GameObject spawn; spawn = castOne(data, ref ray1, ref ray2, ref it); Rigidbody r; r = spawn.GetComponent <Rigidbody> (); /*if (r = spawn.GetComponent<Rigidbody>()) * { * r.AddForce(spawnAngle * spawnSpeed); * }*/ OnSpellSpawned(spawn); StartCoroutine(spawnDelay(data, it, ray1, ray2)); }
private void Callback_GetRotationAngle(PlayerComponent.Buf data) { Vector3 target = data.vectorList[0]; for (int i = 0; i < hitByThese.Count; i++) { Rigidbody r = (Rigidbody)hitByThese[i]; if (r != null && r.gameObject != null) { Projectile p; if (p = r.transform.GetComponent <Projectile>()) { p.sourcePlayer = this.gameObject; } Vector3 newDirection = Vector3.Normalize(target - r.transform.position); r.AddForce((float)magnitudes[i] * newDirection * returnSpeed); } } }
public GameObject castTwo(PlayerComponent.Buf data, ref Ray ray1, ref Ray ray2, ref int it) { GameObject spawn; RaycastHit hit; ray2 = new Ray(ray1.origin + ray1.direction * offset, ray2.direction); if (Physics.Raycast(ray2, out hit, offset, layer)) { spawn = GameObject.Instantiate(itemToSpawn, hit.point, Quaternion.LookRotation(ray1.direction)); check = 0; } else { if (check < 4) { check++; Ray temp = ray1; ray1 = new Ray(ray1.origin + ray1.direction * offset, ray2.direction); ray2 = new Ray(ray1.origin, -temp.direction); spawn = castOne(data, ref ray1, ref ray2, ref it); check = 0; } else { if (Physics.Raycast(ray2, out hit, 2 * spawnRange, layer)) { spawn = GameObject.Instantiate(itemToSpawn, hit.point, Quaternion.identity); ray1 = new Ray(ray1.origin + ray2.direction * (hit.distance - offset * .5f), ray1.direction); } else { spawn = GameObject.Instantiate(itemToSpawn, ray2.origin + ray2.direction * 2 * spawnRange, Quaternion.identity); it = numSpawns; } } } return(spawn); }
public override void SpawnSpell(PlayerComponent.Buf data) { Vector3 spawnPosition = data.vectorList[0]; // Spawn our spell in the place the server told us // However if we are the client, we don't wait for that luxury. for (int i = 0; i < bambooShootsSpawned; i++) { Vector3 t = new Vector3(0, 0, 0); t.x += (float)((Random.Range(0.0f, 1.0f) - .5) * spreadMultiplier); t.z += (float)((Random.Range(0.0f, 1.0f) - .5) * spreadMultiplier); if (t.magnitude > spreadMultiplier) { float mag = t.magnitude; t.x /= mag; t.z /= mag; } GameObject spawn = GameObject.Instantiate(itemToSpawn, spawnPosition + transform.TransformDirection(spawnOffset) + t, transform.rotation); OnSpellSpawned(spawn); } }
public override void SpawnSpell(PlayerComponent.Buf data) { Vector3 spawnAngle = data.vectorList[0]; Vector3 spawnPosition = data.vectorList[1]; // Spawn our spell in the place the server told us // However if we are the client, we don't wait for that luxury. for (int i = 0; i < amountToSpawn; i++) { GameObject spawn = GameObject.Instantiate(itemToSpawn, spawnPosition + transform.TransformDirection(spawnOffset), transform.rotation); Rigidbody r; Vector3 spawnAngleTemp = spawnAngle; if (r = spawn.GetComponent <Rigidbody>()) { spawnAngleTemp.x += (float)((Random.Range(0.0f, 1.0f) - .5) * spreadMultiplier); spawnAngleTemp.y += (float)((Random.Range(0.0f, 1.0f) - .5) * spreadMultiplier); spawnAngleTemp.z += (float)((Random.Range(0.0f, 1.0f) - .5) * spreadMultiplier); r.AddForce(spawnAngleTemp * spawnSpeed); } OnSpellSpawned(spawn); } }