public void CreateMagicFireball(Vector2 startingPosition, Vector2 direction) { ProjectileHandler projectileHandler = ProjectileHandler.Instance; projectileHandler.CreateSwordWeapon(batch, startingPosition, direction, InventoryUtilities.convertSwordToInt(InventoryManager.ItemType.MagicalRod)); projectileHandler.CreateMagicFireball(batch, startingPosition, direction); }
public bool OnHit(BaseController self, ProjectileHandler projectile) { cooldown = 5; if (!projectile || shield <= 0) { return(!Remaining); } Transform debrisParent = GameModes.GetDebrisTransform(self.team); if (shield >= projectile.damage) { ShieldHealth(-projectile.damage, self); Shielded(projectile.transform.position, debrisParent); projectile.active = false; return(!Remaining); } projectile.damage -= shield; ShieldHealth(-shield, self); Shielded(projectile.transform.position, debrisParent); return(!Remaining); }
public bool CreateItem(Vector2 startingPos, Vector2 direction) { ProjectileHandler projectileHandler = ProjectileHandler.Instance; InventoryManager.ItemType type = InventoryManager.Instance.ItemSlot; if (type == InventoryManager.ItemType.None) { return(false); } InventoryManager.ItemType decType = type; if (type == InventoryManager.ItemType.Arrow) { decType = InventoryManager.ItemType.Rupee; } if (InventoryManager.Instance.ItemCount(decType) == 0) { return(false); } InventoryManager.Instance.RemoveFromInventory(decType); switch (type) { case InventoryManager.ItemType.Arrow: projectileHandler.CreateArrowItem(batch, startingPos, direction); break; case InventoryManager.ItemType.Boomerang: if (!RoomProjectiles.Instance.projectiles.Contains(boomerang)) { boomerang = projectileHandler.CreateBoomerangItem(batch, linkState.Sprite, direction); } else { return(false); } break; case InventoryManager.ItemType.Bomb: projectileHandler.CreateBombItem(batch, startingPos); break; case InventoryManager.ItemType.MagicalRod: if (InventoryManager.Instance.ItemCount(InventoryManager.ItemType.MagicBook) > 0) { CreateMagicFireball(startingPos, direction); } else { CreateMagicBeam(startingPos, direction); } break; case InventoryManager.ItemType.BluePotion: linkState.Health = linkState.TotalHealth; break; default: return(false); } return(true); }
private void Start() { playerTurnText = GameObject.Find("Turn").GetComponent <Text>(); windResistanceText = GameObject.Find("Wind Resistance").GetComponent <Text>(); playerTurnText.text = ProjectileHandler.PlayerTurnToText(); displayWind(); }
protected override void Initialize() { base.Initialize(); collisionManager = new CollisionManager(); projectileSpriteFactory = new ProjectileSpriteFactory(this); projectileHandler = new ProjectileHandler(this); link = new Classes.Link(this); linkStateMachine = new LinkStateMachine(link); link.SetState(linkStateMachine); hudSpriteFactory = new HudSpriteFactory(this); enemySpriteFactory = new EnemySpriteFactory(this); controllerList.Add(new CKeyboard(this)); controllerList.Add(new CMouse(this)); controllerList.Add(new ItemSelectionController(this)); neighbors = Parser.ParseNeighborCSV(); roomList = new List <Room>(); util.roomNumber = util.startingRoomNumber(); for (int i = 1; i < util.numberOfRooms() + 1; i++) { roomList.Add(Parser.ParseRoomCSV(this, i)); } foreach (Room r in roomList) { if (r.getRoomNumber() == util.roomNumber) { currentRoom = r; } } currentRoom.Initialize(); currentMainGameState = new MainState(this, currentRoom); currentGameState = currentMainGameState; MediaPlayer.Play(song); MediaPlayer.IsRepeating = true; }
void SetInitialReferences() { if (GameObject.Find("SceneCamera") != null) { Debug.Log("found camera"); sceneCameraObj = GameObject.Find("SceneCamera"); } if (GameObject.Find("_GameManager") != null) { gameManagerMaster = GameObject.Find("_GameManager").GetComponent<GameManager_Master>(); gameManagerPlayers = GameObject.Find("_GameManager").GetComponent<GameManager_Players>(); gameManagerMaster.isAlive = true; gameManagerMaster.CallEventCursorLockUpdate(); } else { Debug.LogError("No GameManager found!"); } if (GetComponent<ProjectileHandler>() != null) { projectileHandler = GetComponent<ProjectileHandler>(); } if (GetComponent<Player_Master>() != null) { playerMaster = GetComponent<Player_Master>(); } }
private void LoadFireballs() { //the direction the fireballs will travel Vector2 direction1; Vector2 direction2; Vector2 direction3; //all fireballs originate in the mouth Vector2 location; location.X = this.center.X; location.X -= MovementConstants.AquamentusFireballChangeX; if (aquamentusSprite.StartingFrameIndex == (int)AquamentusSprite.FrameIndex.RightFacing) { location.X += 2 * MovementConstants.AquamentusFireballChangeX; } location.Y = this.center.Y - 10; direction2 = player.Center - location; direction2.Normalize(); double angle2 = Math.Atan2(direction2.Y, direction2.X); double angle1 = angle2 + MovementConstants.AquamentusFireballSpreadAngle; double angle3 = angle2 - MovementConstants.AquamentusFireballSpreadAngle; direction1 = new Vector2((float)Math.Cos(angle1), (float)Math.Sin(angle1)); direction3 = new Vector2((float)Math.Cos(angle3), (float)Math.Sin(angle3)); ProjectileHandler projectileHandler = ProjectileHandler.Instance; projectileHandler.CreateFireballObject(spriteBatch, location, direction1); projectileHandler.CreateFireballObject(spriteBatch, location, direction2); projectileHandler.CreateFireballObject(spriteBatch, location, direction3); SoundFactory.PlaySound(SoundFactory.Instance.bossScream); }
private void LoadFireballs() { //the direction the fireballs will travel Vector2 direction1; Vector2 direction2; Vector2 direction3; //all fireballs originate in the mouth Vector2 location; location.X = this.center.X; location.X += 3 * MovementConstants.AquamentusFireballChangeX; location.Y = this.center.Y - 10; direction2 = player.Center - location; direction2.Normalize(); double angle2 = Math.Atan2(direction2.Y, direction2.X); double angle1 = angle2 + MovementConstants.BoggusFireballSpreadAngle; double angle3 = angle2 - MovementConstants.BoggusFireballSpreadAngle; direction1 = new Vector2((float)Math.Cos(angle1), (float)Math.Sin(angle1)); direction3 = new Vector2((float)Math.Cos(angle3), (float)Math.Sin(angle3)); ProjectileHandler projectileHandler = ProjectileHandler.Instance; projectileHandler.CreateFireballObject(spriteBatch, location, direction1); projectileHandler.CreateFireballObject(spriteBatch, location, direction2); projectileHandler.CreateFireballObject(spriteBatch, location, direction3); }
protected ProjectileHandler SpawnProjectile( BaseController sender, Vector2 direction, WeaponStats stats, float damage, float statsMod = 1) { GameObject projectile = Instantiate(projectilPrefab, GameModes.GetDebrisTransform(sender.team)); projectile.name = $"{gameObject.name}_Projectile"; projectile.transform.position = (Vector2)transform.position + direction; ProjectileHandler handler = projectile .GetComponent <ProjectileHandler>(); handler.onUpdate = OnProjectileUpdate; handler.onHit = OnProjectileHit; Collider2D collider = handler.body .GetComponent <Collider2D>(); Physics2D.IgnoreCollision(collider, sender.body.Collider); handler.SetStats(sender, damage * statsMod, (life + stats.life) / statsMod, ((speed + stats.speed) / statsMod) * direction.normalized, ((force + stats.force) / 4) * statsMod); sender.perks.Activate <IProjectileFired>(1, perk => perk.OnFire(handler)); return(handler); }
protected override void OnProjectileHit (ProjectileHandler projectile, Collider2D collision) { if (projectile.IsSameSender(collision.gameObject)) { return; } BaseController victim = collision.gameObject .GetComponent <BaseController>(); if (!victim || victim.IsTeammate(projectile.Sender)) { return; } projectile.Sender.perks.Activate <IProjectileHitTarget>(1, perk => perk.OnHit(projectile, victim)); float damage = Math.Min(projectile.damage, (projectile.Rigidbody.velocity.magnitude + victim.body.Body.velocity.magnitude)); victim.ProcessDamage(damage, projectile.Sender, projectile.transform.position); float push = (damage * projectile.force) / 8; victim.ApplyCollisionForce(projectile.transform.position, push / 2, push); }
private Vector2 rotateBuffer = new Vector2(0, 0); // sin = X , cos = Y public BaseTurret(Game game, SpriteBatch batch, float scale, ProjectileHandler shotHandler) : base(game) { // TODO: Construct any child components here this.spriteBatch = batch; this.scale = scale; this.shotHandler = shotHandler; }
public void CreateSwordProjectile(Vector2 startingPosition, Vector2 direction) { ProjectileHandler projectileHandler = ProjectileHandler.Instance; if (!RoomProjectiles.Instance.projectiles.Contains(weapon)) { weapon = projectileHandler.CreateSwordItem(batch, startingPosition, direction); } }
// Start is called before the first frame update void Start() { col = GetComponent <CapsuleCollider>(); verticalColliderExtents = new Vector3(0, col.bounds.extents.y, 0); rb = GetComponent <Rigidbody>(); ph = GetComponent <ProjectileHandler>(); hVelocity = new Vector3(1 * hSpeed, 0, 0); gravity = Vector3.down * gConstant; }
void OnTriggerEnter(Collider other) { ProjectileHandler projHandler = other.transform.root.GetComponent <ProjectileHandler>(); if (projHandler != null) { projHandler.GetComponent <SimpleMotor3D>().desiredDirec *= -1.0f; //Debug.Log(projHandler.GetComponent<SimpleMotor3D>().desiredDirec); } }
// Start private void Start() { // Get Rigidbody2D if (rigidbody2d == null) { this.rigidbody2d = GetComponent <Rigidbody2D>(); } // Set Default Projectile this.projectile = ProjectileHandler.GetProjectile("Red"); }
protected virtual void OnProjectileUpdate(ProjectileHandler projectile) { if (projectile.LifeSpan < projectile.Airtime) { projectile.ToDestroy(); return; } projectile.transform.position += (Vector3)projectile.Velocity * Time.deltaTime; }
void SetInitialReferences() { localPlayer = transform.root.gameObject; playerMaster = localPlayer.GetComponent<Player_Master>(); projectileHandler = localPlayer.GetComponent<ProjectileHandler>(); gunAssemblyMaster = localPlayer.GetComponent<GunAssembly_Master>(); modifiers = GetComponent<ComponentModifiers>(); gunAudio = localPlayer.GetComponent<GunAudio>(); gunAudio.clipArray = shootSoundClips; }
protected override void OnProjectileUpdate(ProjectileHandler projectile) { if (projectile.LifeSpan < projectile.Airtime) { projectile.ToDestroy(); return; } float s = 1 - (projectile.Airtime / projectile.LifeSpan); projectile.transform.localScale = new Vector3(s, s, 1); }
/// <summary> /// Public function to throw (For now used within the "Throw" animation /// </summary> public void ThrowObject() { // Choose a random target point int m_point = Random.Range(0, aimPoints_A.Length); ProjectileHandler objectData = heldProjectile.GetComponent <ProjectileHandler>(); objectData.SetThrowingValues(bodyHand.transform.position, rangePower, aimPoints_A[m_point].transform.position); heldProjectile.transform.SetParent(null); heldProjectile = null; anim.SetTrigger("hasThrown"); throwTimer = 0; }
void Awake() { if (_pHandler == null) { _pHandler = this; } else { Destroy(gameObject); } p1projUI = GameObject.Find("Canvas/MatchUI/P1_SelectedProj"); p2projUI = GameObject.Find("Canvas/MatchUI/P2_SelectedProj"); }
/* --------------------------------------- */ /* ---------------- Public --------------- */ /* --------------------------------------- */ /// <summary> Only used for shooting weapon cards. </summary> public void FireProjectile() { // Cant shoot if player not holding a gun if (pHand.CurrentlySelected == null) { return; } // If currently selected card is not of type "weapon" don't do anything if (pHand.CurrentlySelected.CardType != ItemType.weapon) { return; } // Type conversion to WeaponCardSO since not all cards can shoot... WeaponCardSO weaponCardRefr = pHand.CurrentlySelected as WeaponCardSO; /* * Might modify how projectile timing works. This currently allows for "full auto" weapon types * without instantiating like hundreds of projectiles in a fraction of a second since this function * could theoretically be called every single frame */ if ((Time.time - timeSinceLastAttack) >= weaponCardRefr.ROF) { // Cache time last fired weapon timeSinceLastAttack = Time.time; // Spawn the projectile to fire ProjectileHandler refr = LeanPool.Spawn <ProjectileHandler>(_projComponentRefr, _projSpawnLocation.position, _projSpawnLocation.rotation, _projParentObject.transform); // Set the ProjectileData for the spawned projectile refr._projData = weaponCardRefr.ProjectileData; if (UpdateProjectileData != null) { UpdateProjectileData.RaiseEvent(refr.gameObject.GetInstanceID()); } // Activate necessary events if (KnockbackEvent != null) { KnockbackEvent.RaiseEvent(); } if (CameraShakeEvent != null) { CameraShakeEvent.RaiseEvent(weaponCardRefr._camShakePreset); } } }
protected override void OnProjectileHit(ProjectileHandler projectile, Collider2D collision) { if (projectile.IsSameSender(collision.gameObject)) { return; } BaseController controller = collision.gameObject .GetComponent <BaseController>(); if (controller) { controller.ProjectileHit(projectile); } }
public override bool applyEffect(Buffable target) { //Attempt to get a reference to the ProjectileHandler of the object we're giving the energy to ProjectileHandler handler = target.GetComponent <ProjectileHandler>(); //If handler exists, add energyBonus to its energy pool if (handler) { handler.energy += energyBonus; return(true); } else { return(false); } }
private IEnumerator RushAttack() { rushAttackCooldownRemaining = rangeAttackCooldown; isInvulnerable = true; isRushing = true; Vector2 rushDirection = GameData.playerMovement.transform.position - transform.position; float timer = rushTime; rushDirection.Normalize(); SetEffect(Effect.NoControl, rushTime, false); while (timer > 0 && !Is(Effect.Stun)) { rb.velocity = rushDirection * rushVelocity; timer -= Time.fixedDeltaTime; yield return(new WaitForFixedUpdate()); } SetEffect(Effect.NoControl, 0, false); isInvulnerable = false; isRushing = false; // Fin du rush float subAngle = attackWidthAngle / (projectileNumber - 1); float firstAngle = -attackWidthAngle / 2; for (int x = 0; x < projectileSend && !Is(Effect.Stun); x++) { for (int i = 0; i < projectileNumber && !Is(Effect.Stun); i++) { float relativeAngle = firstAngle + subAngle * i; float angledDirection = Vector2.SignedAngle(Vector2.right, aimDirection) + relativeAngle; Vector2 direction = new Vector2(Mathf.Cos((angledDirection) * Mathf.Deg2Rad), Mathf.Sin((angledDirection) * Mathf.Deg2Rad)); Vector2 spawnPos = (Vector2)transform.position + direction * projectileSpawnDistance; GameObject newProjectile = Instantiate(projectilePrefab, spawnPos, Quaternion.identity); ProjectileHandler newProjectileHandler = newProjectile.GetComponent <ProjectileHandler>(); newProjectileHandler.initialVelocity = direction * projectileSpeed; newProjectileHandler.knockBackForce = projectileKnockbackForce; newProjectileHandler.destroyTime = 0; newProjectileHandler.damage = projectileDamage; newProjectileHandler.lifeTime = projectileLifeTime; } yield return(new WaitForSeconds(bulletAttackSpeed)); } }
private void LoadFireballs() { //the direction the fireballs will travel Vector2 direction; //all fireballs originate in the mouth Vector2 location; location.X = this.center.X; location.Y = this.center.Y - 10; direction = player.Center - location; direction.Normalize(); location.X += -15; //originate fireballs at mouth if facing left ProjectileHandler projectileHandler = ProjectileHandler.Instance; projectileHandler.CreateFireballObject(spriteBatch, location, direction); }
public void ProjectileBehavior() { if (target != null) { if (Vector3.Distance(transform.position, target.position) > minDistance) { direction = target.position - transform.position; _rb.AddForce((direction.normalized * moveSpeed * Time.fixedDeltaTime), ForceMode2D.Impulse); if (applyKnockback) { Vector2 dir = transform.position - transform.TransformVector(projLaunchPoint.position); _rb.AddForce((dir.normalized * _knockBackForce), ForceMode2D.Impulse); applyKnockback = false; _knockBackForce = -1f; } } else { if ((Time.time - timeLastFired) >= damageTickRate) { Vector3 projDir = target.position - transform.position; projDir = projDir.normalized; GameObject refr = Instantiate(projectileRefr, transform.TransformVector(projLaunchPoint.position), Quaternion.identity); ProjectileHandler pHandler = refr.GetComponent <ProjectileHandler>(); pHandler.damagePlayer = true; pHandler.SetLookDirection(projDir); pHandler.sr.sprite = _dataContainer.projectileSprite; pHandler.projectileVelocity = _dataContainer.projectileVelocity; pHandler.projectileDamage = _dataContainer.Damage; pHandler.projectileLifetime = _dataContainer.projectileLifetime; AudioManager._inst.PlaySFX(7); timeLastFired = Time.time; } } } }
public TurretDefaultBullet(Game game, SpriteBatch batch, float scale, ProjectileHandler shotHandler) : base(game, batch, scale, shotHandler) { rotation = 0.0f; supportedAmmoTypes.Add(Ammo.AmmoDamageType.Bullet); currentAmmoType = new AmmoDefaultBullet(game); currentAmmoType.Initialize(); turnSpeed = 0.1f; fireRate_spm = 2000.0f; accuracy_per = 75.0f; ammoMax = 10000; ammoCount = 10000; isAmmoUnlimited = false; ammoSpeedModifier = 1.0f; ammoDamageModifier = 1.0f; ammoAccelerationModifier = 1.0f; ammoLifetimeModifier = 1.0f; }
private void RangeAttack() { rangeAttackCooldownRemaining = rangeAttackCooldown; float subAngle = attackWidthAngle / (projectileNumber - 1); float firstAngle = -attackWidthAngle / 2; for (int i = 0; i < projectileNumber; i++) { float relativeAngle = firstAngle + subAngle * i; float angledDirection = Vector2.SignedAngle(Vector2.right, aimDirection) + relativeAngle; Vector2 direction = new Vector2(Mathf.Cos((angledDirection) * Mathf.Deg2Rad), Mathf.Sin((angledDirection) * Mathf.Deg2Rad)); Vector2 spawnPos = (Vector2)transform.position + direction * projectileSpawnDistance; GameObject newProjectile = Instantiate(projectilePrefab, spawnPos, Quaternion.identity); ProjectileHandler newProjectileHandler = newProjectile.GetComponent <ProjectileHandler>(); newProjectileHandler.initialVelocity = direction * projectileSpeed; newProjectileHandler.knockBackForce = projectileKnockbackForce; newProjectileHandler.destroyTime = 0; newProjectileHandler.damage = projectileDamage; newProjectileHandler.lifeTime = projectileLifeTime; } }
void OnTriggerEnter2D(Collider2D col) { PlayerController pc = col.GetComponent <PlayerController>(); EnemyController ec = col.GetComponent <EnemyController>(); ChestController cc = col.GetComponent <ChestController>(); ProjectileHandler prc = col.GetComponent <ProjectileHandler>(); if (pc != null) { pc.OnHit(999f); } if (ec != null) { ec.OnHit(); } if (cc != null) { cc.OnHit(); } if (cc != null) { prc.OnHit(); } }
protected override void Awake() { base.Awake(); weapon = GetComponent <ProjectileHandler>(); }
void Start() { weapon = GameObject.Find("Player").GetComponent <ProjectileHandler>(); rebuildList(); }
protected override void OnProjectileUpdate(ProjectileHandler projectile) { projectile.transform.position += (Vector3)projectile.Velocity * Time.deltaTime; }