private void shootBolt(ScriptableRaycastAbility raycastAbility, Vector3 start, Vector3 end) { if (raycastAbility.RaycastBolt != null) { RaycastBolt bolt = useableAbility.InstantiateObject(raycastAbility.RaycastBolt.gameObject, useableAbility.Origin.position, useableAbility.Origin.rotation).GetComponent <RaycastBolt>(); bolt.SetPoints(start, end); } }
private IEnumerator ChainAttack(CharacterBase ownerCharacter, List <CharacterBase> affectedCharacters) { List <GameObject> bolts = new List <GameObject>(); for (var i = 0; i < affectedCharacters.Count; i++) { if (i < affectedCharacters.Count - 1) { var affectedCharacter = affectedCharacters[i]; Transform start = affectedCharacter.transform; Transform end = affectedCharacters[i + 1].transform; GameObject gameObject = Instantiate(LineGameObject, start.position, start.rotation); bolts.Add(gameObject); RaycastBolt raycastBolt = gameObject.GetComponent <RaycastBolt>(); raycastBolt.LifeTime = -1.0f; raycastBolt.TimeToTarget = Delay; raycastBolt.SetPoints(start, end); } damage(ownerCharacter, affectedCharacters[i]); yield return(new WaitForSeconds(Delay)); } yield return(new WaitForSeconds(LifeTime)); foreach (var affectedCharacter in affectedCharacters) { if (ElectricMaterial != null) { var meshRenderer = affectedCharacter.GetComponent <MeshRenderer>(); if (meshRenderer != null) { List <Material> matArray = meshRenderer.materials.ToList(); matArray.RemoveAt(1); meshRenderer.materials = matArray.ToArray(); } } } for (int i = 0; i < bolts.Count; i++) { Destroy(bolts[i]); } }