public void Shoot(ProjectileStats stats, Vector3 origin, Vector3 direction) { List<Projectile> pList; if (_projectiles.TryGetValue(stats.type, out pList)) { Projectile p = null; for (int i = 0; i < pList.Count; i++) { if (!pList[i].gameObject.activeInHierarchy) { p = pList[i]; break; } } if (!p) { p = NewProjectile(stats.type); } p.Shoot(stats, origin, direction); } }
public ProjectileStats constructProjectileStats(WeaponFactory.CLASS weaponClass) { //sets up assuming a ranged weapon var pStats = new ProjectileStats() { prefab = bulletTemplate, damage = projectileDamage(weaponClass), lifeTime = (weaponMods.projectileLifetimeAddition + projectileLifeTimesTable.get(weaponClass).Value) * weaponMods.projectileLifetimeMultiplier, ammoRefill = tables.ammoPerKill.get(weaponClass).Value }; if (tables.tagWeapon.get(weaponClass) == WeaponFactory.TAG.MELEE) { //corrects if melee pStats.damage = projectileDamage(weaponClass); pStats.lifeTime = projectileLifeTimesTable.get(weaponClass).Value; pStats.prefab = projectilePrefabTable.get(weaponClass); pStats.prefab.transform.localScale = Vector3.one * (1 + weaponMods.meleeSizeAddition) * weaponMods.meleeSizeMultiplier * 0.5f; //swordScale //Debug.Log("Scale: " + pStats.prefab.transform.localScale.ToString()); } //pStats.lifeTime = projectileLifeTimesTable.get(weaponClass).Value; return(pStats); }
private void OnStatChanged(BaseStat.StatType stat, GameObject source) { if (stat == BaseStat.StatType.MoveSpeed) { maxSpeed = ProjectileStats.GetStatModifiedValue(BaseStat.StatType.MoveSpeed); } }
private void Start() { mStats = GetComponent <ProjectileStats>(); mDamage = mStats.damage; mGod = mStats.creator; createOnDeath = mStats.creation; friendly = mStats.friendly; }
public void AddProjectileStats(ProjectileStats offset, ProjectileStats min, ProjectileStats max) { this.AddedSpeed = Mathf.Clamp(this.AddedSpeed + offset.AddedSpeed, min.AddedSpeed, max.AddedSpeed); this.Size = Mathf.Clamp(this.Size + offset.Size, min.Size, max.Size); this.Damage = Mathf.Clamp(this.Damage + offset.Damage, min.Damage, max.Damage); OnChangeEvent?.Invoke(); }
public override void SetPlayerProjectileStats(float currentSpeed, ProjectileStats stats) { movement = GetComponent <TransformMovement>(); damageOnCollision = GetComponent <ApplyDamageOnCollision>(); transform.localScale = Vector3.one * stats.Size; movement.AxisMultipliers = Vector3.one * (stats.AddedSpeed + currentSpeed); damageOnCollision.Damage = stats.Damage; }
private void Start() { FiringMode = _startFiringMode; MsBetweenShots = msBetweenShots; MuzzleVelocity = muzzleVelocity; BurstCount = burstCount; Accuracy = accuracy; KickMinMax = kickMinMax; ProjStats = projectileStats; }
protected void InitBattleObject(int hp, ProjectileStats projectileStats, bool isPlayer, int id) { ID = id; IsPlayer = isPlayer; m_InitHP = m_CurrentHP = hp; ProjectileStats = projectileStats; //UI UIController.transform.localPosition += new Vector3(0, WorldSize, 0); UIController.Init(m_InitHP); }
private void Reset() { towerName = "Tower"; description = "Big tower"; level = 1; cost = 1000f; maxHP = 1500; attackDelay = 2; range = 20f; projectileStats = new ProjectileStats(800, 1, 4f); }
public void Loauch(Vector3 tower, Vector3 point, ProjectileStats stats) { _isLanded = false; Damage = stats.Damage; this.Velocity = stats.Velocity; transform.position = tower; _direction = (point - tower).normalized; _remainTime = Vector3.Distance(tower, point) / stats.Velocity; Radius = stats.ExplosionRange; this.CoefSlow = stats.SlowMultiplier; this.TimeSlow = stats.SlowTime; transform.rotation = Quaternion.LookRotation(Vector3.back); }
public AbilityContainer(PlayerMain player, AbilityItem ability) { cooldown = new Timer(1000, OnTimer, true); cooldown.Active = false; this.player = player; Ability = ability; ability_prefab = Ability.Ability; upgrade_stats = Ability.Stats; projectile_prefab = ability_prefab.GetComponent <AbilityStats>().ProjectilePrefab; ProStats = ability_prefab.GetComponent <ProjectileStats>(); sfx = ability_prefab.GetComponent <StoreSounds>(); }
public void ArcShoot(ProjectileStats stats, Vector3 origin, Vector3 direction, int arcShots, float fireArc) { if (fireArc != 0 && arcShots > 1) { for (int i = 0; i < arcShots; i++) { float angleMod = (((float)i / (arcShots - 1f)) * 2f) - 1f; Vector3 shotDirection = (Quaternion.AngleAxis(angleMod * fireArc / 2, Vector3.forward) * direction).normalized; Shoot(stats, origin, shotDirection); } } else { Debug.LogWarning("ArcShot Should not be called for a single shot or with a fire arc of 0"); } }
public AbilityContainer(PlayerMain player,AbilityItem ability) { cooldown=new Timer(1000,OnTimer,true); cooldown.Active=false; this.player=player; Ability=ability; ability_prefab=Ability.Ability; upgrade_stats=Ability.Stats; projectile_prefab=ability_prefab.GetComponent<AbilityStats>().ProjectilePrefab; ProStats = ability_prefab.GetComponent<ProjectileStats>(); sfx = ability_prefab.GetComponent<StoreSounds>(); }
private void HandlePenetration() { float penetrationCount = ProjectileStats.GetStatModifiedValue(BaseStat.StatType.ProjectilePenetration); if (penetrationCount <= -1f) { return; } if (penetrationCount <= 0) { CleanUp(); } else { StatAdjustmentManager.ApplyUntrackedStatMod(ProjectileStats, ProjectileStats, BaseStat.StatType.ProjectilePenetration, -1f); } }
public void Shoot(ProjectileStats stats, Vector3 origin, Vector3 direction) { alive = true; transform.parent = null; transform.position = _origin = origin; _stats = stats; _direction = direction.normalized; _lifeCounter = 0; _material.color = _orignalColor; gameObject.SetActive(true); if (_stats.motionPattern != null && _stats.motionPattern.length > 0) { _motionPattern = _stats.motionPattern; _tangentDirection = Vector3.Cross(Vector3.back, _direction); } else { _motionPattern = null; } transform.rotation = Quaternion.FromToRotation(Vector3.right, direction); gameObject.layer = LayerConstants.Projectile; if (_stats.ignoreTerrain) { switch (_stats.team) { case Team.Player: gameObject.layer = LayerConstants.EnemyTrigger; break; case Team.Enemy: gameObject.layer = LayerConstants.PlayerTrigger; break; } } }
public void RefreshPowerUps() { shield = 0; _projectileStats = Constants.GreenBolts; bool hasPurple = false; foreach (var powerUp in SaveGameManager.instance.saveGameData.powerUpsCollected) { switch (powerUp) { case PowerUpID.PogoStick: hasPogo = true; break; case PowerUpID.MaruMari: hasMorphBall = true; break; case PowerUpID.PurpleLazer: hasPurple = true; _projectileStats = Constants.PurpleBolts; break; case PowerUpID.RedLazer: if (!hasPurple) { _projectileStats = Constants.RedBolts; } break; case PowerUpID.ColdSuit: hasColdSuit = true; break; case PowerUpID.PowerSuit: hasPowerSuit = true; shield = maxHealth; break; case PowerUpID.HoverBoots: hasHoverBoots = true; break; } } if (onRefreshPowerUps != null) { onRefreshPowerUps(); } }
public abstract void SetPlayerProjectileStats(float currentSpeed, ProjectileStats stats);
public override void HoldStyle(Player player) { //int dust3 = Dust.NewDust(player.Top+new Vector2(player.direction*-10, 0), 0, 0, 87, 0f, 0f, 25, Color.Goldenrod, 1.5f); //Main.dust[dust3].noGravity = true; //Main.dust[dust3].velocity = new Vector2(0, 0); reloading = Math.Max(reloading, 0); //altfire = Math.Min(altfire, reloadspeed-1); if (reloading > 0) { reloading = reloading = Math.Max(reloading + (reloadspeed - (altfire)), 0); player.itemRotation = (reloading / 7.5f) * -player.direction; item.holdStyle = 1; int d = Dust.NewDust(player.itemLocation, 1, 1, 159, 0, 0, 0, Color.Goldenrod, 0.5f); Main.dust[d].noGravity = true; /*item.Center*/ player.itemLocation = ((player.direction > 0?player.Right:player.Left) - new Vector2(16, 8)) - (new Vector2(24, 2).RotatedBy(player.itemRotation) * player.direction); //player.itemLocation-new Vector2(player.direction>0?16:0,0); if (RoundsLeft > 0 && -Math.Abs(player.itemRotation) % 1 <= 0.2f) { //int a = (int)(item.damage*1.5f); //GetWeaponDamage(player, ref a); int b = Projectile.NewProjectile(player.itemLocation, new Vector2(4).RotatedBy(player.itemRotation), bullets[0].id == 14?160:bullets[0].id, player.GetWeaponDamage(item), item.knockBack, item.owner); //8, if (bullets[0].id != 14) { Main.projectile[b].GetGlobalProjectile <ElementalGlobalProjectile>().extraAI = 8; } if (bullets[0].id == 14) { Main.projectile[b].aiStyle = 8; } RoundsLeft--; if (bullets.Count > 0) { //if(bullets[0].id!=14)Main.projectile[b].aiStyle = bullets[0].id; bullets.RemoveAt(0); } } } if (reloading >= 100) { item.useAmmo = AmmoID.Bullet; for (int i = 0; i < RoundsMax; i++) { bool canShoot = false; ProjectileStats p = new ProjectileStats(); player.PickAmmo(item, ref p.id, ref p.speed, ref canShoot, ref p.damage, ref p.knockback); if (canShoot) { bullets.Add(p); RoundsLeft++; } else { break; } //RoundsLeft = RoundsMax; } item.useAmmo = 0; reloading = 0; item.holdStyle = 0; altfire = 0; } }
public void Init(int hp, Sprite planetSprite, float orbitPeriod, Color hightlightColor, ProjectileStats projectileStats, float planetScaleToWeightMltp, bool isPlayer, int id, float scaleMultiplayer = 0) { //Data m_OrbitPeriod = orbitPeriod; //Sprites PlanetSprite.sprite = planetSprite; HightlightSprite.color = hightlightColor; //Planet diversity PlanetSprite.transform.localScale += PlanetSprite.transform.localScale * scaleMultiplayer; Weight = WorldSize * planetScaleToWeightMltp; //Adjust collider size BoxCollider2D boxCollider = GetComponent <BoxCollider2D>(); boxCollider.size = new Vector2(WorldSize * 2, WorldSize * 2); //Battle object InitBattleObject(hp, projectileStats, isPlayer, id); }
public static void projectile(Actor cardUser, float distanceFromUser, ProjectileBase preInstateatedProjectile, ProjectileStats stats) { Vector2 userPosition = cardUser.get2dPostion(); //this can be changed to a muzzle location Vector2 aimVectorFromUser = cardUser.getNormalizedAim(userPosition); //setting projectile properties ProjectileBase projectile = preInstateatedProjectile; projectile.transform.position = userPosition + aimVectorFromUser * distanceFromUser; //start projectile a little ways off of the user projectile.setVolocity(aimVectorFromUser * getProjectileSpeed(cardUser, stats.speed)); projectile.setDamage(getProjectileDamage(cardUser, stats.damage, stats.damageType), stats.damageType, cardUser.Team); projectile.setProjectileColor(Color.yellow); projectile.setIgnoredColliders(new Collider2D [] { cardUser.collider }); }
void Update() { #region Makes easy references to the appropriate sets of stats so I don't have to type "xModes[firingModes[firingModeIndex].xMode]" every single bloody time I need to reference a set of stats fireControls = fireControlModes[firingModes[firingModeIndex].fireControlMode]; accuracy = accuracyModes[firingModes[firingModeIndex].accuracyMode]; projectile = projectileModes[firingModes[firingModeIndex].projectileMode]; optics = GetOpticsStats(firingModeIndex); recoil = GetRecoilStats(firingModeIndex); ammunition = GetAmmunitionStats(firingModeIndex); magazine = GetMagazineStats(firingModeIndex); #endregion // Checks following criteria to determine if the player should be able to control their weapon: // If the player is not currently switching weapon or firing mode // If the player's weapon selector is not active if (isSwitchingWeapon == false && isSwitchingFireMode == false && playerHolding.weaponSelector.MenuIsActive() == false) { if (Input.GetAxis("Mouse ScrollWheel") != 0 && firingModes.Length > 1) // Switch firing modes with the scroll wheel { int i = 0; if (Input.GetAxis("Mouse ScrollWheel") < 0) { i = 1; } else if (Input.GetAxis("Mouse ScrollWheel") > 0) { i = -1; } i += firingModeIndex; if (i > firingModes.Length - 1) { i = 0; } else if (i < 0) { i = firingModes.Length - 1; } SwitchWeaponMode(i); } fireControls.fireTimer += Time.deltaTime; // If player is active // If player is pressing fire button // If fireTimer has finished // If burst count has not exceeded the limit OR burst count is set to zero // If ammo is available OR supply is null // If magazine is not empty OR null if (playerHolding.ph.CurrentState() == PlayerState.Active && /*playerHolding.ph.isActive == true && */ Input.GetButton("Fire") && fireControls.fireTimer >= 60 / fireControls.roundsPerMinute && (fireControls.burstCounter < fireControls.maxBurst || fireControls.maxBurst <= 0) && (ammunition == null || (playerHolding.ph.a.GetStock(ammunition.ammoType) >= ammunition.ammoPerShot)) && (magazine == null || (magazine.magazine.current >= 1 /*ammoPerShot*/ && isReloading == false))) { // Adjust fire control variables fireControls.fireTimer = 0; // Reset fire timer to count up to next shot fireControls.burstCounter += 1; #region Alter ammunition, magazine and recoil variables if present // Consume ammo if supply is present if (ammunition != null) { playerHolding.ph.a.Spend(ammunition.ammoType, ammunition.ammoPerShot); } // Deplete magazine if present if (magazine != null) { if (ammunition != null) // If ammunition supply is present, consume appropriate amount of { magazine.magazine.current -= ammunition.ammoPerShot; } else { magazine.magazine.current -= 1; } } // Apply recoil if recoil stat exists if (recoil != null) { recoilToApply += recoil.recoil; } #endregion #region Trigger cosmetic effects /* * firingModes[firingModeIndex].muzzleFlash.Play(); * weaponSoundSource.PlayOneShot(firingModes[firingModeIndex].firingNoise); * firingModes[firingModeIndex].shellEjection.Play(); */ MuzzleFlashEffect m = firingModes[firingModeIndex].muzzleFlash; if (m != null) { m.Play(); } AudioClip a = firingModes[firingModeIndex].firingNoise; if (a != null) { weaponSoundSource.PlayOneShot(a); } ParticleSystem s = firingModes[firingModeIndex].shellEjection; if (s != null) { s.Play(); } #endregion // Calculate direction to shoot in //Quaternion ar = Quaternion.Euler(Random.Range(-playerHolding.standingAccuracy, playerHolding.standingAccuracy), Random.Range(-playerHolding.standingAccuracy, playerHolding.standingAccuracy), Random.Range(-playerHolding.standingAccuracy, playerHolding.standingAccuracy)); //Vector3 aimDirection = ar * transform.forward; Vector3 aimDirection = transform.forward; if (optics == null || isAiming == false) { aimDirection = Quaternion.Euler(Random.Range(-playerHolding.standingAccuracy, playerHolding.standingAccuracy), Random.Range(-playerHolding.standingAccuracy, playerHolding.standingAccuracy), Random.Range(-playerHolding.standingAccuracy, playerHolding.standingAccuracy)) * aimDirection; } for (int i = 0; i < projectile.projectileCount; i++) // Shoots an amount of projectiles based on the projectileCount variable. { Damage.ShootProjectile(projectile.projectile, accuracy.projectileSpread, accuracy.range, playerHolding.gameObject, playerHolding.ph.faction, transform, projectile.muzzle, aimDirection); } } else if (!Input.GetButton("Fire")) { fireControls.burstCounter = 0; } if (optics != null) { AimHandler(optics, firingModes[firingModeIndex].heldPosition, playerHolding.toggleAim); } if (magazine != null) { if (ammunition != null) { ReloadHandler(magazine.reloadTime, fireControls.fireTimer, fireControls.roundsPerMinute, magazine.roundsReloaded, magazine.magazine, playerHolding, ammunition.ammoType); } else { ReloadHandler(magazine.reloadTime, fireControls.fireTimer, fireControls.roundsPerMinute, magazine.roundsReloaded, magazine.magazine); } } } if (recoil != null) { RecoilHandler(recoil.recoilApplyRate, playerHolding); } }
public void ApplyStats(ProjectileStats ps) { _speed = ps.speed; _damage = ps.damage; _lifetime = ps.lifetime; }
public ProjectileContainer() { stats = new ProjectileStats(); graphics = new ProjectileGraphics(); mods = new List <ProjMod>(); }
public void BurstShoot(ProjectileStats stats, Vector3 origin, Vector3 direction, int burstCount, float burstTime, int arcShots = 1, float fireArc = 0) { StartCoroutine(BurstShot(stats, origin, direction, burstCount, burstTime, arcShots, fireArc)); }
public ProjectileContainer(ProjectileStats _stats, ProjectileGraphics _graphics, List <ProjMod> _mods) { stats = _stats; graphics = _graphics; mods = ProjMod.CloneList(_mods); }
private IEnumerator BurstShot(ProjectileStats stats, Vector3 origin, Vector3 direction, int burstCount, float burstTime, int arcShots, float fireArc) { var shotsFired = 0; while (shotsFired < burstCount) { shotsFired++; if (fireArc != 0 && arcShots > 1) { ArcShoot(stats, origin, direction, arcShots, fireArc); } else { Shoot(stats, origin, direction); } yield return new WaitForSeconds(burstTime/burstCount); } }
public void SetProjectileStats(ProjectileStats other) { SetProjectileStats(other.AddedSpeed, other.Size, other.Damage); }
private void Start() { projectileStats = Instantiate(projectileStats); ProjectileSpeed = projectileStats.projectileSpeed; }
protected ProjectileContainer(ProjectileContainer other) { stats = other.stats; graphics = other.graphics; mods = ProjMod.CloneList(other.mods); }