Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 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));
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        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();
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 private void Item_OnUngrabEvent(Handle handle, Interactor interactor, bool throwing)
 {
     if (item.handlers.Count <= 0)
     {
         FXPlayer.StopAllFxOnObject(holdingFX);
         handlerCreature = null;
     }
 }
Exemplo n.º 6
0
 private void DeactivateFireBlade()
 {
     active = false;
     FXPlayer.StopAllFxOnObject(activeFX);
     if (whooshId != null)
     {
         item.GetComponentInChildren <Whoosh>().Load(Catalog.current.GetData <FXData>(defaultWhooshId), Whoosh.Trigger.Always, item.data.whooshs[0].minVelocity, item.data.whooshs[0].maxVelocity);
     }
 }
Exemplo n.º 7
0
        public void Initialize()
        {
            holdingFX  = item.definition.GetCustomReference("active")?.gameObject;
            drainingFX = item.definition.GetCustomReference("draining")?.gameObject;
            FXPlayer.StopAllFxOnObject(holdingFX);
            FXPlayer.StopAllFxOnObject(drainingFX);

            item.OnGrabEvent      += Item_OnGrabEvent;
            item.OnCollisionEvent += Item_OnCollisionEvent;
            item.OnUngrabEvent    += Item_OnUngrabEvent;
        }
Exemplo n.º 8
0
        private void UseCharge()
        {
            //Stop all particles
            FXPlayer.StopAllFxOnObject(chargedFX);
            FXPlayer.StopAllFxOnObject(activatedFX);
            FXPlayer.StartAllFxOnObject(chargingFX);

            isCharged   = false;
            isActivated = false;
            lastUseTime = Time.time;
        }
Exemplo n.º 9
0
 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));
         }
     }
 }
Exemplo n.º 10
0
        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;
        }
Exemplo n.º 11
0
        private void Update()
        {
            foreach (Creature creature in Creature.list)
            {
                if (creature != Creature.player && !creature.health.isKilled)
                {
                    if (creature.GetComponentsInChildren <Burning>().Length >= 2)
                    {
                        CreatureAudioPreset creatureAudioPreset = null;

                        if (creature.umaCharacter.GetSex() == UMARace.Sex.Male)
                        {
                            creatureAudioPreset = creature.speak.maleAudioPreset;
                        }
                        else if (creature.umaCharacter.GetSex() == UMARace.Sex.Female)
                        {
                            creatureAudioPreset = creature.speak.femaleAudioPreset;
                        }

                        if (creatureAudioPreset != null)
                        {
                            if (!creatureAudioPreset.fallingSounds.Contains(creature.speak.GetComponent <AudioSource>().clip))
                            {
                                if (UnityEngine.Random.Range(0f, 1f) > 0.5f)
                                {
                                    FXPlayer.PlaySound(creature, CreatureAudio.Type.Falling);
                                }
                                else
                                {
                                    FXPlayer.PlaySound(creature, CreatureAudio.Type.Death);
                                }
                            }
                        }

                        creature.StopAction <ActionParry>();
                        creature.StopAction <ActionWatch>();
                        creature.StopAction <ActionMove>();
                        creature.StopAction <ActionStrafe>();
                        creature.StopAction <ActionGrab>();
                        creature.TryAction(new ActionShock(10, 1), true);
                    }
                }
            }
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
 private void Item_OnGrabEvent(Handle handle, Interactor interactor)
 {
     handlerCreature = interactor.GetComponentInParent <Creature>();
     FXPlayer.StartAllFxOnObject(holdingFX);
 }
Exemplo n.º 16
0
 private void DeactivateBlade()
 {
     isActivated = false;
     FXPlayer.StartAllFxOnObject(chargedFX);
     FXPlayer.StopAllFxOnObject(activatedFX);
 }
Exemplo n.º 17
0
        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);
        }