public void SpawnFireball(Transform sun, Vector3 velocity) { var offset = Quaternion.Euler( UnityEngine.Random.value * 360.0f, UnityEngine.Random.value * 360.0f, UnityEngine.Random.value * 360.0f) * Vector3.forward * 0.2f; fireballItem.SpawnAsync(fireball => { fireball.transform.position = sun.position + offset; fireball.transform.localScale = Vector3.zero; fireball.rb.isKinematic = true; ThrowFireball(fireball, velocity); }); }
public override void Merge(bool active) { base.Merge(active); if (active) { if (!isActive) { isActive = true; sunData.SpawnAsync(sun => { sunInstance = sun; sunInstance.transform.position = Player.currentCreature.mana.mergePoint.transform.position; sunInstance.transform.rotation = Player.currentCreature.mana.mergePoint.transform.rotation; sunInstance.rb.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative; sunInstance.rb.isKinematic = true; SunController control = sunInstance.GetComponent <SunController>(); control.mergeSpell = this; }); } } else { isActive = false; Vector3 velocity = Player.local.transform.rotation * PlayerControl.GetHand(GameManager.options.twoHandedDominantHand).GetHandVelocity(); if (currentCharge == 1) { Throw(velocity); } else if (sunInstance != null) { sunInstance.GetComponent <SunController>().Despawn(); sunInstance = null; } } }
public static Task <Item> SpawnItem(ItemPhysic itemData) { var promise = new TaskCompletionSource <Item>(); System.Action action = () => itemData.SpawnAsync(item => promise.SetResult(item)); Task.Run(action); return(promise.Task); }
//instance.gameObject.GetOrAddComponent<HoleSphereBehaviour>().Detach(); public override void Merge(bool active) { base.Merge(active); if (active) { if (!isActive) { isActive = true; blackGrabbed = false; whiteGrabbed = false; GetOrFindHole(Black)?.GetComponent <HoleSphereBehaviour>()?.Despawn(); GetOrFindHole(White)?.GetComponent <HoleSphereBehaviour>()?.Despawn(); whiteHoleData.SpawnAsync(instance => { whiteHoleInstance = instance; whiteHoleInstance.disallowDespawn = true; whiteHoleInstance.transform.localScale = Vector3.one * 0.3f; whiteHoleInstance.transform.position = Player.currentCreature.mana.mergePoint.position; whiteHoleInstance.gameObject.GetOrAddComponent <HoleSphereBehaviour>().Begin(White, ref blackHoleInstance, this); }); blackHoleData.SpawnAsync(instance => { blackHoleInstance = instance; blackHoleInstance.disallowDespawn = true; blackHoleInstance.transform.localScale = Vector3.one * 0.3f; blackHoleInstance.transform.position = Player.currentCreature.mana.mergePoint.position; blackHoleInstance.gameObject.GetOrAddComponent <HoleSphereBehaviour>().Begin(Black, ref whiteHoleInstance, this); }); } } else { isActive = false; blackGrabbed = false; whiteGrabbed = false; if (currentCharge < 1) { blackHoleInstance.GetComponent <HoleSphereBehaviour>().Despawn(); blackHoleInstance = null; whiteHoleInstance.GetComponent <HoleSphereBehaviour>().Despawn(); whiteHoleInstance = null; } else { whiteHoleInstance.GetComponent <HoleSphereBehaviour>().active = true; blackHoleInstance.GetComponent <HoleSphereBehaviour>().active = true; } } }
public FloatingDagger(ItemPhysic daggerBase, GameObject blackHolePrefab, EffectData soundEffect, int number, int count) { daggerBase.SpawnAsync(dagger => { item = dagger; item.transform.localScale = Vector3.one * charge; item.transform.position = GetTarget(number, count); soundEffect.Spawn(dagger.transform).Play(); PointItemFlyRefAtTarget(item, GetHandsPointingQuaternion() * Vector3.forward, 1.0f); item.rb.collisionDetectionMode = CollisionDetectionMode.Discrete; item.GetComponent <Rigidbody>().isKinematic = true; item.disallowDespawn = false; blackHole = UnityEngine.Object.Instantiate(blackHolePrefab, item.transform.position, Quaternion.identity); blackHole.transform.localScale = Vector3.one * 0.25f; blackHole.transform.localPosition = Vector3.zero; blackHole.GetComponent <Renderer>().material.SetFloat("HoleSize", 0); blackHole.GetComponent <Renderer>().material.SetFloat("DistortionStrength", 0); }); }
public override void Merge(bool active) { base.Merge(active); if (active) { if (!daggerActive) { if (Player.currentCreature.mana.casterLeft.spellInstance is DaggerSpell leftSpell && leftSpell.summonedDagger != null) { leftSpell.summonedDagger.gameObject.SetActive(false); } else if (Player.currentCreature.mana.casterRight.spellInstance is DaggerSpell rightSpell && rightSpell.summonedDagger != null) { rightSpell.summonedDagger.gameObject.SetActive(false); } daggerActive = true; daggerBase.SpawnAsync(dagger => { summonedDagger = dagger; PointItemFlyRefAtTarget(summonedDagger, GetClosestCreatureHead() - summonedDagger.transform.position, 1.0f); summonedDagger.transform.position = GetHandCenterPoint(); summonedDagger.GetComponent <Rigidbody>().isKinematic = true; }); } }