示例#1
0
        private void EventManager_onPossess(Creature creature, EventTime eventTime)
        {
            if (creature.container.contents.Where(c => c.itemData.id == "SpellBloodItem").Count() <= 0)
            {
                creature.container.AddContent(Catalog.GetData <ItemData>("SpellBloodItem"));
            }

            creature.OnDamageEvent += Creature_OnDamageEvent;

            BloodDrain.DrainHealth(0, this, null);
        }
示例#2
0
        public override void UpdateCaster()
        {
            base.UpdateCaster();

            if (spellCaster.ragdollHand.side == Side.Left)
            {
                BloodDrain.drainEffectLeft.SetVector3("AttractiveTargetPosition", spellCaster.magic.position);
            }
            else
            {
                BloodDrain.drainEffectRight.SetVector3("AttractiveTargetPosition", spellCaster.magic.position);
            }


            //Check for passive healing
            if (SkillHandler.IsSkillUnlocked("Healing"))
            {
                if (Time.time - lastDamageTime > 5)
                {
                    Creature spellcastCreature = spellCaster.ragdollHand.creature;
                    //Not been damaged for 5 seconds
                    if (spellcastCreature.currentHealth < spellcastCreature.maxHealth)
                    {
                        spellcastCreature.Heal(BookUIHandler.saveData.drainPower * 0.2f * Time.deltaTime, spellcastCreature);
                    }
                }
            }

            //check for choking

            if (SkillHandler.IsSkillUnlocked("Choke Drain"))
            {
                //Debug.Log("Choke unlocked");
                Handle grabbedHandle = spellCaster.ragdollHand.grabbedHandle;
                if (grabbedHandle is HandleRagdoll)
                {
                    //Debug.Log("Handle is handle ragdoll");
                    //Grabbed handle is a neck of a creature
                    if (PlayerControl.GetHand(spellCaster.ragdollHand.side).useAxis > 0)
                    {
                        //Player is pressing the use button
                        Creature grabbedCreature = (grabbedHandle as HandleRagdoll).ragdollPart.ragdoll.creature;
                        if (!grabbedCreature.isKilled)
                        {
                            //Creature not killed
                            float             health            = BookUIHandler.saveData.drainPower * Time.deltaTime * 2;
                            CollisionInstance collisionInstance = new CollisionInstance(new DamageStruct(DamageType.Energy, health));
                            grabbedCreature.Damage(collisionInstance);

                            lastDamageTime = Time.time;
                            BloodDrain.DrainHealth(health, this, grabbedCreature);
                        }
                    }
                }
            }


            if (currentCharge > 0.8f)
            {
                //Check for draining
                if (BloodDrain.TryToActivate(this, Vector3.zero, BookUIHandler.saveData))
                {
                    if (spellCaster.ragdollHand.side == Side.Left)
                    {
                        BloodDrain.drainEffectLeft.Play();
                    }
                    else
                    {
                        BloodDrain.drainEffectRight.Play();
                    }
                }
                else
                {
                    if (spellCaster.ragdollHand.side == Side.Left)
                    {
                        BloodDrain.drainEffectLeft.Stop();
                    }
                    else
                    {
                        BloodDrain.drainEffectRight.Stop();
                    }
                }

                if (!swordSpawned && SkillHandler.IsSkillUnlocked("Blood Sword"))
                {
                    if (BloodSword.TryToActivate(this, Vector3.zero, BookUIHandler.saveData))
                    {
                        spellCaster.StartCoroutine(SpawnSword());
                        lastDamageTime = Time.time;
                    }
                }

                if (!bowSpawned && SkillHandler.IsSkillUnlocked("Blood Bow"))
                {
                    if (BloodBow.TryToActivate(this, Vector3.zero, BookUIHandler.saveData))
                    {
                        spellCaster.StartCoroutine(SpawnBow());
                        lastDamageTime = Time.time;
                    }
                }

                //Check wave
                if (!BloodWave.waveCreated && SkillHandler.IsSkillUnlocked("Blood Wave"))
                {
                    if (BloodWave.TryToActivate(this, Vector3.zero, BookUIHandler.saveData))
                    {
                        spellCaster.StartCoroutine(SpawnBloodWave());
                        lastDamageTime = Time.time;
                    }
                }
            }
            else
            {
                if (spellCaster.ragdollHand.side == Side.Left)
                {
                    BloodDrain.drainEffectLeft.Stop();
                }
                else
                {
                    BloodDrain.drainEffectRight.Stop();
                }
            }
        }