//[HideInInspector] public float projectileForce = 250f; // Float variable to hold the amount of force which we will apply to launch our projectiles public void Launch() //Function thats run on Script call. There is no Start() in this script. { passedDirect = attacker.GetComponent <MeleeCoolDown>(); faceDir = passedDirect.direction; MonoBehaviour.print("DIRECTION GIVEN " + faceDir); rangedDelay = 0.25f; // print("ability triggered"); print("Triggerable attacker is " + attacker); print("Triggerable damage is " + damage); //Instantiate a copy of our projectile and store it in a new rigidbody variable called clonedBullet //projectile.GetComponent("hitbox1").damage = damage; //up date the damage of the hitbox that will be spawned. Then I need it to spawn the hitboxes in a set direction or pattern. if (faceDir == 0) { givenProjectile = projectile; // Passes the id of the hitbox that will be spawned when triggered. hitboxRotation = transform.rotation; hitboxSpawn = hitboxSpawnCardinal; anim.SetBool("attackBack", true); anim.SetBool("forward", false); anim.SetBool("back", false); anim.SetBool("left", false); anim.SetBool("right", false); } else if (faceDir == 1) { givenProjectile = projectile; // Passes the id of the hitbox that will be spawned when triggered. hitboxRotation = transform.rotation; hitboxSpawn = hitboxSpawnCardinal; anim.SetBool("attackRight", true); anim.SetBool("forward", false); anim.SetBool("back", false); anim.SetBool("left", false); anim.SetBool("right", false); } else if (faceDir == 2) { givenProjectile = projectile; // Passes the id of the hitbox that will be spawned when triggered. // print("bar hitbox"); hitboxRotation = transform.rotation; hitboxSpawn = hitboxSpawnCardinal; anim.SetBool("attackForward", true); anim.SetBool("forward", false); anim.SetBool("back", false); anim.SetBool("left", false); anim.SetBool("right", false); } else if (faceDir == 3) { givenProjectile = projectile; // Passes the id of the hitbox that will be spawned when triggered. hitboxRotation = transform.rotation; hitboxSpawn = hitboxSpawnCardinal; anim.SetBool("attackLeft", true); anim.SetBool("forward", false); anim.SetBool("back", false); anim.SetBool("left", false); anim.SetBool("right", false); } // Checks for the diagonals. else if (faceDir == 4) { givenProjectile = projectileAngled; // print("angled hitbox"); hitboxRotation = transform.rotation; hitboxRotation *= Quaternion.Euler(0, 45, 0); hitboxSpawn = hitboxSpawnAngle; } else if (faceDir == 5) { givenProjectile = projectileAngled; // print("angled hitbox"); hitboxRotation = transform.rotation; hitboxRotation *= Quaternion.Euler(0, 45, 0); hitboxSpawn = hitboxSpawnAngle; } else if (faceDir == 6) { givenProjectile = projectileAngled; // print("angled hitbox"); hitboxRotation = transform.rotation; hitboxRotation *= Quaternion.Euler(0, 45, 0); hitboxSpawn = hitboxSpawnAngle; } else if (faceDir == 7) { givenProjectile = projectileAngled; // print("angled hitbox"); hitboxRotation = transform.rotation; hitboxRotation *= Quaternion.Euler(0, 45, 0); hitboxSpawn = hitboxSpawnAngle; } else { givenProjectile = projectile; } // GameObject clonedHitbox = Instantiate(givenProjectile, hitboxSpawn.position, transform.rotation); //Instantiates a projectile from the given prefab. StartCoroutine("AbilityWindup"); StartCoroutine("AnimationDelay"); //Add force to the instantiated bullet, pushing it forward away from the bulletSpawn location, using projectile force for how hard to push it away //clonedBullet.AddForce(bulletSpawn.transform.forward * projectileForce); }
// Update is called once per frame void Update() { meleeLocker = gameObject.GetComponent <MeleeCoolDown>(); rangedLocker = gameObject.GetComponent <RangedCoolDown>(); charDirect = gameObject.GetComponent <PlayerMovementDash>(); print("Start state of Melee Lock " + meleeLocker.attackLock); print("Start state of Ranged Lock " + rangedLocker.attackLock); print("Dash Locker State " + charDirect.dashLocked); direction = charDirect.faceDir; bool firstCoolDownComplete = (Time.time > firstNextReadyTime); // Check to see if cooldown is available or not. bool secondCoolDownComplete = (Time.time > secondNextReadyTime); // Check to see if cooldown is available or not. if (firstCoolDownComplete && !summonActive) { // print("First Summon Cooldown Complete"); if (Input.GetKeyDown("q")) // Checks for pressing the Q key to start casting for first summon. Look into possibly changing this so it pulls the string from a variable for more flexbility. { castActive = true; sumChosen = 1; print("First summon ready"); meleeLocker.attackLock = true; rangedLocker.attackLock = true; //charDirect.dashLocked = true; print("Dash Locker State " + charDirect.dashLocked); } if (Input.GetKeyDown(KeyCode.Tab)) // Checks for pressing the Space key to deactivate the casting state. NOTE: This and the left/right clicks still need locks on abilities in other functions. { castActive = false; sumChosen = 0; print("Summon Deactivated"); meleeLocker.attackLock = false; rangedLocker.attackLock = false; } /* * if (Input.GetKeyUp("space")) * { * //charDirect.dashLocked = false; * StartCoroutine("DashUnlockDelay"); * } */ } else { print("FIRST SUMMON COOLING DOWN"); FirstCoolDown(); // If cooldown is not complete then run CoolDown function to update the display for the ui. CURRENTLY NOT USED FULLY. } if (secondCoolDownComplete && !summonActive) { // print("Second Summon Cooldown Complete"); if (Input.GetKeyDown("e")) // Checks for pressing the E key to start casting for second summon. { castActive = true; sumChosen = 2; print("Second summon ready"); meleeLocker.attackLock = true; rangedLocker.attackLock = true; //charDirect.dashLocked = true; } if (Input.GetKeyDown(KeyCode.Tab)) // Checks for pressing the Space key to deactivate the casting state. NOTE: This and the left/right clicks still need locks on abilities in other functions. { castActive = false; sumChosen = 0; print("Summon Deactivated"); meleeLocker.attackLock = false; rangedLocker.attackLock = false; } /* if (Input.GetKeyUp(KeyCode.Tab)) * { * StartCoroutine("DashUnlockDelay"); * * } */ } else { print("SECOND SUMMON COOLING DOWN"); SecondCoolDown(); // If cooldown is not complete then run CoolDown function to update the display for the ui. CURRENTLY NOT USED FULLY. } if (castActive && sumChosen == 1) // If the player has pressed the Q key to activate casting, pull from the two abilities assigned to the given first summon. { if (Input.GetButtonDown("Fire1")) // If assigned button is pressed then perform proper actions for the given ability. NOTE: Take another look at this, the process seems wrong, might not need clone yet. { selectedSummon = firstSummon; selectedSummon.attacker = attackingChar; selectedSummon.selectedSprite = selectedSummon.sumChar; selectedSummon.summonSlot = sumChosen; selectedAbility = selectedSummon.ability1; selectedSummon.selectedAbility = selectedAbility; SetTargetPosition(); selectedSummon.Initialize(summonHolder); // Sets the spawn point of the ability as the object weaponholder. castActive = false; summonActive = true; print("cast deactivated"); // firstNextReadyTime = firstSumCooldown + Time.time; // Sets the ready time for the summon based off cooldown. This value is what handles the checking for the cooldown. firstCoolDownTimeLeft = firstSumCooldown; // Updated to update the display for the player. selectedSummon.TriggerAbility(); // Runs TriggerAbility of the summon to then run the given ability. StartCoroutine(AbilityUnlockerBuffer(unlockBuffer)); //meleeLocker.attackLock = false; //rangedLocker.attackLock = false; } if (Input.GetButtonDown("Fire2")) { selectedSummon = firstSummon; selectedSummon.attacker = attackingChar; selectedSummon.summonSlot = sumChosen; selectedSummon.selectedSprite = selectedSummon.sumChar2; selectedAbility = selectedSummon.ability2; selectedSummon.selectedAbility = selectedAbility; SetTargetPosition(); selectedSummon.Initialize(summonHolder); // Sets the spawn point of the ability as the object weaponholder. castActive = false; print("cast deactivated"); firstNextReadyTime = firstSumCooldown + Time.time; // Sets the ready time for the summon based off cooldown. firstCoolDownTimeLeft = firstSumCooldown; selectedSummon.TriggerAbility(); meleeLocker.attackLock = false; rangedLocker.attackLock = false; // charDirect.dashLocked = false; } } if (castActive && sumChosen == 2) // If the player has pressed the E key to activate casting, pull from the two abilities assigned to the given second summon. { if (Input.GetButtonDown("Fire1")) { selectedSummon = secondSummon; selectedSummon.attacker = attackingChar; selectedSummon.summonSlot = sumChosen; selectedSummon.selectedSprite = selectedSummon.sumChar; selectedAbility = selectedSummon.ability1; // This might be a thing that leads nowhere GIVE IT ANOTHER LOOK selectedSummon.selectedAbility = selectedAbility; SetTargetPosition(); selectedSummon.Initialize(summonHolder); // Sets the spawn point of the ability as the object weaponholder. castActive = false; summonActive = true; print("cast deactivated"); //secondNextReadyTime = secondSumCooldown + Time.time; // Sets the ready time for the summon based off cooldown. secondCoolDownTimeLeft = secondSumCooldown; selectedSummon.TriggerAbility(); StartCoroutine(AbilityUnlockerBuffer(unlockBuffer)); } if (Input.GetButtonDown("Fire2")) { selectedSummon = secondSummon; selectedSummon.attacker = attackingChar; selectedSummon.summonSlot = sumChosen; selectedSummon.selectedSprite = selectedSummon.sumChar2; selectedAbility = selectedSummon.ability2; // This might be a thing that leads nowhere GIVE IT ANOTHER LOOK selectedSummon.selectedAbility = selectedAbility; SetTargetPosition(); selectedSummon.Initialize(summonHolder); // Sets the spawn point of the ability as the object weaponholder. castActive = false; summonActive = true; print("cast deactivated"); //secondNextReadyTime = secondSumCooldown + Time.time; // Sets the ready time for the summon based off cooldown. secondCoolDownTimeLeft = secondSumCooldown; selectedSummon.TriggerAbility(); StartCoroutine(AbilityUnlockerBuffer(unlockBuffer)); } } }