IEnumerator AbilityWindup() { yield return(new WaitForSeconds(0.4f)); //yield for certain amount of seconds print("Waited for ability windup"); // GameObject clonedVisual = Instantiate(abilityVisual, hitboxSpawn.position, hitboxRotation); GameObject clonedHitbox = Instantiate(givenProjectile, hitboxSpawn.position, hitboxRotation); //Instantiates a projectile from the given prefab. // clonedVisual.transform.parent = clonedHitbox.gameObject.transform; Rigidbody tempRigidBody; tempRigidBody = clonedHitbox.GetComponent <Rigidbody>(); tempRigidBody.AddForce(transform.right * hitBoxForwardForce); detector = clonedHitbox.GetComponent <HitboxDetection>(); // grabs script that will initialize the object. detector.attacker = attacker; detector.damage = damage; detector.doesDamage = doesDamage; Destroy(clonedHitbox, rangedDelay); yield return(null); }
void SpawnHitbox() { GameObject clonedHitbox = Instantiate(givenHitbox, summonVisual.transform.position, hitboxRotation); // CHECK THIS for clarity of hitboxrotation; detector = clonedHitbox.GetComponent <HitboxDetection>(); // grabs script that will initialize the object. if (doesDamage) // Determine damage and pass it to the hitbox script { print("Summon ability 2 Final Hitbox Deals Damage"); detector.attacker = attacker; print("detector passed attacker " + attacker); print("detector attacker " + detector.attacker); detector.damage = attackVal; detector.doesDamage = doesDamage; detector.textDelay = 0.2f; } if (doesForce) // Determine force and pass it to the hitbox script { } if (doesHeal) // Determine heal and pass it to the hitbox script { detector.attacker = attacker; detector.healingDone = healVal; detector.doesHeal = doesHeal; } if (doesStatus) // Determine status and pass it to the hitbox script { } Destroy(clonedHitbox, hitDespawnDelay); print("STATIC DOES RETURN RESULT" + doesReturn); if (doesReturn) { StartCoroutine("timeToReturn"); } else { StartCoroutine("timetoVanish"); } //isStatic = false; //summonControl.cooldown = sumCooldown; // TO REFINE THIS HAVE THE COOLDOWN ACTIVATE ONCE THE ABILITY RETURNS AND JUST HAVE AN ACTIVE STATE THAT KEEPS THE ABILITY UNACTIVATABLE. arrived = false; }
void TwoPartFollow() { if (twoParterHitboxes) { print("arrived state for two part" + arrived); print("noHitBoxSpawn state for two part" + noHitBoxSpawn); if (arrived && noHitBoxSpawn) { Destroy(charHitbox); // destroy the hitbox to trigger the next part of the animation. charHitbox = Instantiate(triggerHitbox, attacker.transform.position, hitboxRotation); charDetector = charHitbox.GetComponent <HitboxDetection>(); // Accesses the detector for the hitbox that will follow the character.. print("CHARHITBOX 2 INSTANTIATED"); if (doesDamage) // Determine damage and pass it to the hitbox script { print("CHARHITBOX 2 DOES DAMAGE"); charDetector.attacker = attacker; print("charHitbox 2 ATTACKER " + charDetector.attacker); charDetector.damage = attackVal; print("charHitbox 2 DAMAGE " + charDetector.damage); charDetector.doesDamage = doesDamage; } if (doesForce) // Determine force and pass it to the hitbox script { } if (doesHeal) // Determine heal and pass it to the hitbox script { charDetector.attacker = attacker; charDetector.healingDone = healVal; } if (doesStatus) // Determine status and pass it to the hitbox script { } charHitbox.transform.parent = summonVisual.gameObject.transform; if (doesReturn) { StartCoroutine("timeToReturn"); } else { StartCoroutine("timetoVanish"); } arrived = false; } } }
void Awake() { newPosition = transform.position; TopHitbox = TopHitboxObject.GetComponent <HitboxDetection>(); LeftHitbox = LeftHitboxObject.GetComponent <HitboxDetection>(); BottomHitbox = BottomHitboxObject.GetComponent <HitboxDetection>(); RightHitbox = RightHitboxObject.GetComponent <HitboxDetection>(); enemySpawnerScript = enemySpawner.GetComponent <EnemySpawner>(); previousPosition = transform.position; }
void SpawnFollowHitbox() { charHitbox = Instantiate(triggerHitbox, attacker.transform.position, hitboxRotation); // CHECK THIS for clarity of hitboxrotation AND HITBOX; Creates hitbox on top of the summon. // Need to set the spawned hitbox as the child of the object. Alternatively just slap a hitbox as the child of it and activate it. // Currently saying its an empty reference because the charDetector = charHitbox.GetComponent <HitboxDetection>(); // Accesses the detector for the hitbox. if (charDetector.hitDetected) // If the hitbox hits a target. { castTarget = attacker.transform.position; // Updates the castTarget position for the MovePlayer() script to stop it from moving. Destroy(charHitbox); // destroy the hitbox to trigger the next part of the animation. SpawnHitbox(); // Spawn the hitboxes for the new action that was passed by the ability. } }
IEnumerator AbilityWindup() { yield return(new WaitForSeconds(0.3f)); //yield for certain amount of seconds print("Waited for ability windup"); // GameObject clonedVisual = Instantiate(abilityVisual, hitboxSpawn.position, hitboxRotation); print("Melee finished"); GameObject clonedHitbox = Instantiate(givenProjectile, hitboxSpawn.position, hitboxRotation); //Instantiates a projectile from the given prefab. detector = clonedHitbox.GetComponent <HitboxDetection>(); // grabs script that will initialize the object. detector.attacker = attacker; detector.damage = damage; detector.doesDamage = doesDamage; Destroy(clonedHitbox, meleeDelay); yield return(null); }
// Update is called once per frame void Update() { // Starts with is Moving based off of isMoving bool. Will start a new state and turn off the previous one to perform each action. // All of this is to create the summonVisual instantiation to dictate where hitboxes will spawn as it moves around. if (isCasting) // Bool to ensure that the summon cannot be used multiple times due to update. { print("isCasting Activated"); isMoving = true; isCasting = false; summonVisual = Instantiate(sumChar, attacker.transform.position, attacker.transform.rotation); // Create visual element for the summon. /* * if (faceDir == 3 || faceDir == 5 || faceDir == 7) * { * summonVisual.transform.rotation = Quaternion.Inverse(summonVisual.transform.rotation); * } */ print("VISUAL SUMMONED"); charHitbox = Instantiate(triggerHitbox, attacker.transform.position, hitboxRotation); charDetector = charHitbox.GetComponent <HitboxDetection>(); // Accesses the detector for the hitbox that will follow the character.. print("CHARHITBOX INSTANTIATED"); if (doesDamage) // Determine damage and pass it to the hitbox script { print("CHARHITBOX DOES DAMAGE"); charDetector.attacker = attacker; print("charHitbox ATTACKER " + charDetector.attacker); charDetector.damage = attackVal; print("charHitbox DAMAGE " + charDetector.damage); charDetector.doesDamage = doesDamage; } if (doesForce) // Determine force and pass it to the hitbox script { } if (doesHeal) // Determine heal and pass it to the hitbox script { charDetector.attacker = attacker; charDetector.healingDone = healVal; } if (doesStatus) // Determine status and pass it to the hitbox script { } charHitbox.transform.parent = summonVisual.gameObject.transform; } if (isMoving) { print("IS MOVING DETECTED"); MovePlayer(); // spawn player representation and move it to clicked location. } //detector = clonedHitbox.GetComponent<HitboxDetection>(); // grabs script that will initialize the object. if (arrived && !noHitBoxSpawn) // Spawn the hitboxes with the effects they have once they arrive to their location or activates. { print("SPAWN HITBOX DETECTED"); SpawnHitbox(); } if (arrived && noHitBoxSpawn) { TwoPartFollow(); } if (returning) // Returns to the summmoner after completing its actions. { print("RETURN HOME DETECTED"); ReturnHome(); } if (isLeaving) { SummonLeave(); } // Need to set a delay function before it spawns the hitbox. //GameObject clonedHitbox = Instantiate(givenHitbox, hitboxSpawn.position, hitboxRotation); // CHECK THIS for clarity of hitboxrotation; /* * summonVisual.transform.position = Vector3.Lerp(startingPosition.position, castTarget, fracJourney); * * if (fracJourney == 1) * { * GameObject hitboxClone = Intantiate(givenHitbox, hitboxSpawn.position, hitboxSpawn.rotation); * } */ }