public static void DrainHealth(float health, BloodSpell bloodSpell, Creature creature) { if (OnDrain != null) { OnDrain(health); } if (!drainEffectLeft) { drainEffectLeft = Catalog.GetData <EffectData>("BloodDrain").Spawn(Vector3.zero, Quaternion.identity, null, null, false).effects[0].GetComponent <VisualEffect>(); drainEffectLeft.transform.SetParent(null); } if (!drainEffectRight) { drainEffectRight = Catalog.GetData <EffectData>("BloodDrain").Spawn(Vector3.zero, Quaternion.identity, null, null, false).effects[0].GetComponent <VisualEffect>(); drainEffectRight.transform.SetParent(null); } if (creature != null) { if (bloodSpell.spellCaster.ragdollHand.side == Side.Left) { drainEffectLeft.transform.position = creature.ragdoll.GetPart(RagdollPart.Type.Neck).transform.position; } else { drainEffectRight.transform.position = creature.ragdoll.GetPart(RagdollPart.Type.Neck).transform.position; } Player.currentCreature.Heal(health, Player.currentCreature); } }
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); }
public static bool TryToActivate(BloodSpell bloodSpell, Vector3 velocity, SaveData saveData) { RaycastHit hit; if (Physics.Raycast(bloodSpell.spellCaster.magic.position, bloodSpell.spellCaster.magic.forward, out hit)) { if (hit.collider.GetComponentInParent <Creature>() && hit.distance < saveData.drainDistance) { Creature creature = hit.collider.GetComponentInParent <Creature>(); if (!creature.isPlayer && creature.isKilled && Player.currentCreature.currentHealth < Player.currentCreature.maxHealth) { CreatureDrainComponent dC = creature.GetComponent <CreatureDrainComponent>(); if (dC && dC.health > 0) { dC.health -= BookUIHandler.saveData.drainPower * Time.deltaTime; DrainHealth(BookUIHandler.saveData.drainPower * Time.deltaTime, bloodSpell, creature); return(true); } else { creature.Despawn(); } } } } return(false); }
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); }
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); }
public void TestBloodGimmick() { var setting = new Settings { CombatPower = 10, PrimaryWeapon = WeaponType.Blood, SecondaryWeapon = WeaponType.Fist, FightLength = 5, TargetType = TargetType.Champion, Apl = "" }; var player = new Player(setting); var bSpell = new BloodSpell(); player.Spells.Add(bSpell); var engine = new Engine(setting); var fight = engine.StartFight(player); var bSpells = fight.RoundResults .SelectMany(r => r.Attacks.Where(a => a.Spell is BloodSpell)).Count(); var round1 = fight.RoundResults.First(r => r.TimeSec == 1); var round2 = fight.RoundResults.First(r => r.TimeSec == 2); var round3 = fight.RoundResults.First(r => r.TimeSec == 3); var round4 = fight.RoundResults.First(r => r.TimeSec == 4); var round5 = fight.RoundResults.First(r => r.TimeSec == 5); Assert.IsTrue(Math.Abs(round1.TotalDamage - 10) < 0.001); // 0 Assert.IsTrue(Math.Abs(round2.TotalDamage - 11.56) < 0.01); // 30 Assert.IsTrue(Math.Abs(round3.TotalDamage - 11.56) < 0.01); // 60 Assert.IsTrue(Math.Abs(round4.TotalDamage - 13.27) < 0.01); // 90 Assert.IsTrue(Math.Abs(round5.TotalDamage - 15.34) < 0.01); // 100 Assert.IsTrue(bSpells == 5); }
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); }