IEnumerator MindControlCoroutine(Creature creature, int origFac) { creature.SetFaction(2); GameObject fxs = null; if (controlledFX != null) { fxs = GameObject.Instantiate(controlledFX, creature.body.headBone); fxs.transform.localPosition = new Vector3(0, 0, 0); FXPlayer.StartAllFxOnObject(fxs); } while (item.isPenetrating && !creature.health.isKilled) { creature.SetFaction(2); CollisionStruct collisionStruct = new CollisionStruct(new DamageStruct(Damager.DamageType.Poison, damage), null, null, null, null, null, null, null); creature.health.Damage(ref collisionStruct); yield return(new WaitForSeconds(1f)); } if (fxs != null) { Destroy(fxs); } creature.SetFaction(origFac); }
private void LateUpdate() { if (hiddenCreature) { foreach (SkinnedMeshRenderer renderer in hiddenCreature.GetComponentsInChildren <SkinnedMeshRenderer>()) { renderer.enabled = false; } } if (item.mainHandler) { if (item.mainHandler.bodyHand.body.creature) { Creature creature = item.mainHandler.bodyHand.body.creature; if (creature != Creature.player) { if ((Time.time - lastUseTime) > (chargeTime + invisibilityTime)) { FXPlayer.StartAllFxOnObject(activeFX); FXPlayer.StopAllFxOnObject(chargedFX); lastUseTime = Time.time; StartCoroutine(InvisibilityCoroutine(item.mainHandler?.bodyHand.body.creature)); } } } } }
IEnumerator InvisibilityCoroutine(Creature creature) { hiddenCreature = creature; while ((Time.time - lastUseTime) < invisibilityTime) { if (creature == Creature.player) { foreach (Creature creature2 in Creature.list) { if (creature2 != Creature.player && !creature2.health.isKilled && creature2.factionId != -1) { StartCoroutine(ChangeFaction(creature2, lastUseTime)); } } } yield return(new WaitForSeconds(0.2f)); } FXPlayer.StopAllFxOnObject(activeFX); hiddenCreature = null; yield return(new WaitForSeconds(chargeTime)); FXPlayer.StartAllFxOnObject(chargedFX); PlayerControl.GetHand(item.mainHandler.playerHand.side)?.HapticPlayClip(Catalog.current.gameData.haptics.spellSelected, 1); }
private void Update() { if (!isCharged) { if ((Time.time - lastUseTime) > chargeTime) { isCharged = true; FXPlayer.StopAllFxOnObject(chargingFX); FXPlayer.StartAllFxOnObject(chargedFX); // Play is charged particles } } if (item.mainHandler) { if (item.mainHandler.bodyHand.body.creature) { Creature creature = item.mainHandler.bodyHand.body.creature; if (creature != Creature.player) { if (isCharged && !isActivated) { ActivateBlade(); } } } } }
private void ActivateFireBlade() { active = true; FXPlayer.StartAllFxOnObject(activeFX); if (whooshId != null) { item.GetComponentInChildren <Whoosh>().Load(Catalog.current.GetData <FXData>(whooshId), Whoosh.Trigger.Always, item.data.whooshs[0].minVelocity, item.data.whooshs[0].maxVelocity); } }
private void UseCharge() { //Stop all particles FXPlayer.StopAllFxOnObject(chargedFX); FXPlayer.StopAllFxOnObject(activatedFX); FXPlayer.StartAllFxOnObject(chargingFX); isCharged = false; isActivated = false; lastUseTime = Time.time; }
private void Item_OnHeldActionEvent(Interactor interactor, Handle handle, Interactable.Action action) { if (action == Interactable.Action.AlternateUseStart) { if ((Time.time - lastUseTime) > (chargeTime + invisibilityTime)) { FXPlayer.StartAllFxOnObject(activeFX); FXPlayer.StopAllFxOnObject(chargedFX); lastUseTime = Time.time; StartCoroutine(InvisibilityCoroutine(interactor.bodyHand.body.creature)); } } }
public void Initialize() { lastUseTime = 0; hiddenCreature = null; activeFX = item.definition.GetCustomReference("active")?.gameObject; chargedFX = item.definition.GetCustomReference("deactive")?.gameObject; FXPlayer.StopAllFxOnObject(activeFX); FXPlayer.StartAllFxOnObject(chargedFX); item.OnHeldActionEvent += Item_OnHeldActionEvent; }
IEnumerator LifeStealPenetration(Creature creature) { FXPlayer.StartAllFxOnObject(drainingFX); creature.StopAction <ActionParry>(); creature.StopAction <ActionWatch>(); creature.StopAction <ActionMove>(); creature.StopAction <ActionStrafe>(); creature.StopAction <ActionGrab>(); creature.TryAction(new ActionShock(10, 10f), true); while (item.isPenetrating && !creature.health.isKilled) { yield return(new WaitForSeconds(0.1f)); CollisionStruct collisionStruct = new CollisionStruct(new DamageStruct(Damager.DamageType.Poison, pierceDamagePerSec / 10), null, null, null, null, null, null, null); creature.health.Damage(ref collisionStruct); handlerCreature.health.currentHealth = Mathf.Clamp(handlerCreature.health.currentHealth + ((pierceDamagePerSec / 10) * (lifeStealPercent / 100)), 0, handlerCreature.health.maxHealth); } creature.StopAction <ActionShock>(); FXPlayer.StopAllFxOnObject(drainingFX); }
public void Initialize() { /* * chargingParticleSystem = item.definition.GetCustomReference("chargingFX").GetComponent<ParticleSystem>(); * activatedParticleSystem = item.definition.GetCustomReference("activatedFX").GetComponent<ParticleSystem>(); * * activeAudioSource = item.definition.GetCustomReference("chargingFX").GetComponent<AudioSource>(); * chargedAudioSource = item.definition.GetCustomReference("chargedFX").GetComponent<AudioSource>(); */ chargingFX = item.definition.GetCustomReference("charging")?.gameObject; activatedFX = item.definition.GetCustomReference("active")?.gameObject; chargedFX = item.definition.GetCustomReference("deactive")?.gameObject; item.OnCollisionEvent += Item_OnCollisionEvent; item.OnHeldActionEvent += Item_OnHeldActionEvent; isCharged = true; FXPlayer.StopAllFxOnObject(chargingFX); FXPlayer.StopAllFxOnObject(activatedFX); FXPlayer.StartAllFxOnObject(chargedFX); }
IEnumerator Burn(RagdollPart ragdollPart, CollisionStruct collisionStruct) { Burning burning = ragdollPart.gameObject.AddComponent <Burning>(); Creature creature = ragdollPart.ragdoll.creature; float duration = UnityEngine.Random.Range(burnDuration.x, burnDuration.y); float startTime = Time.time; GameObject burningParticles = GameObject.Instantiate(onFireFX, ragdollPart.transform); burningParticles.transform.localPosition = new Vector3(0, 0, 0); FXPlayer.StartAllFxOnObject(burningParticles); int i = 0; while ((Time.time - startTime) < duration) { if (i >= 4) { i = 0; } CollisionStruct collisionStruct1 = new CollisionStruct(new DamageStruct(Damager.DamageType.Poison, fireDamage), null, null, null, null, null, null, null); creature.health.Damage(ref collisionStruct1); i++; yield return(new WaitForSeconds(0.5f)); } FXPlayer.StopAllFxOnObject(burningParticles); yield return(new WaitUntil(() => !burningParticles.GetComponentInChildren <ParticleSystem>().isPlaying)); Destroy(burning); Destroy(burningParticles); }
private void Item_OnGrabEvent(Handle handle, Interactor interactor) { handlerCreature = interactor.GetComponentInParent <Creature>(); FXPlayer.StartAllFxOnObject(holdingFX); }
IEnumerator AttackCoroutine(Item item) { target = null; active = true; yield return(new WaitForSeconds(0.5f)); item.rb.useGravity = false; FXPlayer.StopAllFxOnObject(deactiveFX); FXPlayer.StartAllFxOnObject(activeFX); bool first = true; startTime = Time.time; while (active && (Time.time - startTime) < lifeSpan) { if (target != null && !target.health.isKilled) { if (item.isPenetrating) { yield return(new WaitForSeconds(0.2f)); foreach (Damager damager in item.damagers) { damager.UnPenetrateAll(); } item.rb.velocity = -item.transform.forward * 5; yield return(new WaitForSeconds(0.3f)); } Vector3 pos; if (Physics.Raycast(item.transform.position, -Vector3.up, out RaycastHit hit)) { pos = hit.point; } else { pos = transform.position; } NavMeshPath path = new NavMeshPath(); NavMesh.CalculatePath(pos, target.transform.position, NavMesh.AllAreas, path); if (path.corners.Length > 2) { Vector3 corner = new Vector3(path.corners[1].x, path.corners[1].y + 1.5f, path.corners[1].z); item.transform.LookAt(corner); item.rb.velocity = item.transform.forward * speed; } else { item.transform.LookAt(target.ragdoll.parts[(int)HumanBodyBones.Chest].transform); item.rb.velocity = item.transform.forward * speed; } item.Throw(1, Item.FlyDetection.Forced); item.rb.useGravity = false; yield return(new WaitForSeconds(navUpdatesDelay)); } else { item.Throw(1, Item.FlyDetection.Forced); target = FindNearstEnemy(item.transform); float delay = UnityEngine.Random.Range(minMaxDelayBetweenActions.x, minMaxDelayBetweenActions.y); if (!first) { yield return(new WaitForSeconds(delay)); } else { yield return(new WaitForSeconds(0.1f)); } if (target != null) { attacksound?.Play(); first = false; } } } item.rb.useGravity = true; FXPlayer.StopAllFxOnObject(activeFX); FXPlayer.StartAllFxOnObject(deactiveFX); }
private void DeactivateBlade() { isActivated = false; FXPlayer.StartAllFxOnObject(chargedFX); FXPlayer.StopAllFxOnObject(activatedFX); }