Example #1
0
        public static bool TryToActivate(BloodSpell bloodSpell, Vector3 velocity, SaveData saveData)
        {
            if (Vector3.Dot(Player.currentCreature.transform.forward, bloodSpell.spellCaster.magic.up) > saveData.gesturePrescision) //Fingers facing forwards
            {
                if (SpellAbilityManager.SpendHealth(3))
                {
                    //Spawn dagger
                    Catalog.GetData <ItemData>("BloodDagger").SpawnAsync(delegate(Item dagger)
                    {
                        dagger.IgnoreRagdollCollision(bloodSpell.spellCaster.mana.creature.ragdoll);


                        Vector3 aimDir = BloodSpell.AimAssist(dagger.transform.position, velocity.normalized, 0.7f, 0.01f).aimDir;

                        dagger.rb.AddForce(aimDir * velocity.magnitude * saveData.bulletSpeed, ForceMode.Impulse);
                        dagger.transform.rotation = Quaternion.LookRotation(aimDir);

                        dagger.Throw(1f, Item.FlyDetection.Forced);

                        BloodDagger bd = dagger.gameObject.AddComponent <BloodDagger>();
                        bd.Initialize(dagger);
                    }, bloodSpell.spellCaster.magic.position, Quaternion.Euler(bloodSpell.spellCaster.magic.forward), null, false, null);
                    return(true);
                }
            }
            return(false);
        }
Example #2
0
        public static bool TryToActivate(BloodSpell bloodSpell, Vector3 velocity, SaveData saveData)
        {
            if (!SpellAbilityManager.HasEnoughHealth(20))
            {
                return(false);
            }

            if (waveCreated)
            {
                return(false);
            }


            if (!PlayerControl.GetHand(Side.Right).gripPressed || !PlayerControl.GetHand(Side.Left).gripPressed)
            {
                return(false);
            }

            if (Vector3.Dot(Player.currentCreature.transform.forward, bloodSpell.spellCaster.magic.forward) > saveData.gesturePrescision) //palm forwards
            {
                //Check other hand
                if (Vector3.Dot(Player.currentCreature.transform.forward, bloodSpell.spellCaster.other.magic.forward) > saveData.gesturePrescision) //other palm forwards
                {
                    Vector3 leftSpeed  = Player.local.transform.rotation * PlayerControl.GetHand(Side.Left).GetHandVelocity();
                    Vector3 rightSpeed = Player.local.transform.rotation * PlayerControl.GetHand(Side.Right).GetHandVelocity();

                    //Check if both hand are moving forwards
                    if (Vector3.Dot(Player.currentCreature.transform.forward, leftSpeed) > saveData.gesturePrescision * 1.5f && Vector3.Dot(Player.currentCreature.transform.forward, rightSpeed) > saveData.gesturePrescision * 1.5f)
                    {
                        SpellAbilityManager.SpendHealth(20);
                        //Right and left is moving forwards with enough speed
                        waveCreated = true;
                        return(true);
                    }
                }



                //This is the hand to check
                Side    side       = bloodSpell.spellCaster.other.ragdollHand.side;
                Vector3 otherSpeed = Player.local.transform.rotation * PlayerControl.GetHand(side).GetHandVelocity();
                Vector3 dir        = otherSpeed.normalized;

                //Make sure other is also charging
                if (!bloodSpell.spellCaster.other.isFiring)
                {
                    return(false);
                }
            }
            return(false);
        }
Example #3
0
        public static bool TryToActivate(BloodSpell bloodSpell, Vector3 velocity, SaveData saveData)
        {
            if (!SpellAbilityManager.HasEnoughHealth(10))
            {
                return(false);
            }


            if (Math.Abs(Vector3.Dot(Vector3.up, bloodSpell.spellCaster.magic.right)) > saveData.gesturePrescision) //thumb up
            {
                //This is the hand to check
                Side    side       = bloodSpell.spellCaster.other.ragdollHand.side;
                Vector3 otherSpeed = Player.local.transform.rotation * PlayerControl.GetHand(side).GetHandVelocity();
                Vector3 dir        = otherSpeed.normalized;

                //Make sure other is also charging
                if (!bloodSpell.spellCaster.other.isFiring)
                {
                    return(false);
                }

                //check if fingers are facing the same way
                if (Vector3.Dot(bloodSpell.spellCaster.magic.up, bloodSpell.spellCaster.other.magic.up) > saveData.gesturePrescision)
                {
                    //Maybe Check that they are in line
                    Vector3 dirBetween = (bloodSpell.spellCaster.magic.position - bloodSpell.spellCaster.other.magic.position).normalized;

                    if (Vector3.Dot(bloodSpell.spellCaster.magic.up, dirBetween) > saveData.gesturePrescision)
                    {
                        //They are far enough apart
                        if (Vector3.Distance(bloodSpell.spellCaster.magic.position, bloodSpell.spellCaster.other.magic.position) > 0.15f)
                        {
                            //Now check if movement is in correct direction
                            if (Vector3.Dot(-bloodSpell.spellCaster.magic.up, dir) > saveData.gesturePrescision)
                            {
                                //And finally check if speed in that direction is good enough
                                Vector3 projection = Vector3.Project(otherSpeed, -bloodSpell.spellCaster.magic.up);
                                if (projection.magnitude > 1f)
                                {
                                    SpellAbilityManager.SpendHealth(10);
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Example #4
0
        public static bool TryToActivate(BloodSpell bloodSpell, Vector3 velocity, SaveData saveData)
        {
            if (!SpellAbilityManager.HasEnoughHealth(15))
            {
                return(false);
            }

            if (Vector3.Dot(Vector3.down, bloodSpell.spellCaster.magic.forward) > saveData.gesturePrescision) //Palm down
            {
                //This is the hand to check
                Side    side       = bloodSpell.spellCaster.other.ragdollHand.side;
                Vector3 otherSpeed = Player.local.transform.rotation * PlayerControl.GetHand(side).GetHandVelocity();
                Vector3 dir        = otherSpeed.normalized;

                //Other has to be firing
                if (!bloodSpell.spellCaster.other.isFiring)
                {
                    return(false);
                }

                //check if other hand is rotated correctly

                //Check distance
                if (Vector3.Distance(bloodSpell.spellCaster.other.magic.position, bloodSpell.spellCaster.magic.position) > 0.2f)
                {
                    return(false);
                }

                //If on left
                if (side == Side.Left)
                {
                    if (Vector3.Dot(bloodSpell.spellCaster.magic.right, bloodSpell.spellCaster.other.magic.forward) > saveData.gesturePrescision)
                    {
                        //Rotation is correct!
                        //Now check for speed in the correct direction!
                        Vector3 projection = Vector3.Project(otherSpeed, -bloodSpell.spellCaster.magic.right);
                        Debug.Log($"BloodSword :: projection magnitude {projection.magnitude}");

                        //Moving in the right direction
                        if (Vector3.Dot(-bloodSpell.spellCaster.magic.right, projection.normalized) > saveData.gesturePrescision)
                        {
                            if (projection.magnitude > 1.0f)
                            {
                                SpellAbilityManager.SpendHealth(15);
                                return(true);
                            }
                        }
                    }
                }
                else
                {
                    if (Vector3.Dot(-bloodSpell.spellCaster.magic.right, bloodSpell.spellCaster.other.magic.forward) > saveData.gesturePrescision)
                    {
                        //Rotation is correct!
                        //Now check for speed in the correct direction!
                        Vector3 projection = Vector3.Project(otherSpeed, bloodSpell.spellCaster.magic.right);
                        Debug.Log($"BloodSword :: projection magnitude {projection.magnitude}");

                        //Moving in the right direction
                        if (Vector3.Dot(bloodSpell.spellCaster.magic.right, projection.normalized) > saveData.gesturePrescision)
                        {
                            if (projection.magnitude > 1.0f)
                            {
                                SpellAbilityManager.SpendHealth(15);
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }