private void Update() { if (Input.GetMouseButtonDown(0)) { Hitscan.Cast(transform.position, camera.transform.forward, dHealth, layerMask: hitscanMask); } }
public static void Fire(Items.Instance Item, Player UsingPlayer) { { float Multiplyer = Pow(UsingPlayer.AdsMultiplyer, 2); for (int x = -2; x <= 2; x++) { for (int y = -2; y <= 2; y++) { Hitscan.QueueFire(x * AngularOffset * Multiplyer, y * AngularOffset * Multiplyer, Range, HeadshotDamage, BodyshotDamage, LegshotDamage); } } Hitscan.ApplyQueuedFire(); } Hitscan.ApplyAdditiveRecoil(VerticalRecoil, RecoilLength); if (UsingPlayer.IsCrouching) { UsingPlayer.SetCooldown(0, FireCooldown * UsingPlayer.AdsMultiplyer * Hitscan.CrouchAffectPercentage, true); } else { UsingPlayer.SetCooldown(0, FireCooldown * UsingPlayer.AdsMultiplyer, true); } UsingPlayer.SfxManager.FpScattershockFire(); }
void Fire() { bool success = Hitscan.Raycast(actionPoint.position, actionPoint.forward, out HitscanInfo scanInfo, maxDistance, muzzle.position); audioSource?.Play(); if (success) { Debug.DrawRay(actionPoint.position, scanInfo.hitInfo.point, Color.white, 0.1F); if (scanInfo.hitInfo.collider.gameObject.layer == LayerMask.NameToLayer("Enemy")) { float damage = this.damage; if (GameState.HasCourage) { damage *= 2.0F; } Boss.ApplyDamage(damage); } } else { Debug.DrawRay(actionPoint.position, actionPoint.forward * maxDistance, Color.red, 0.1F); } }
public static void Fire(Items.Instance Item, Player UsingPlayer) { Hitscan.Fire(0, 0, Range, HeadshotDamage, BodyshotDamage, LegshotDamage); Hitscan.ApplyRecoil(VerticalRecoil, HorizontalRecoil); UsingPlayer.SetCooldown(0, FireCooldown, true); UsingPlayer.SfxManager.FpThunderboltFire(); }
public void InventorySlotSelect(int Slot) { if (!(CurrentCooldown < CurrentMaxCooldown && PreventSwitch)) { InventorySlot = Slot; HUDInstance.HotbarUpdate(); Hitscan.Reset(); SetCooldown(0, SlotSwitchCooldown, false); } }
public Hitscan(Hitscan copy) { hitscanType = copy.hitscanType; dmgType = copy.dmgType; range = copy.range; damage = copy.damage; lifetime = copy.lifetime; startPosition = copy.startPosition; direction = copy.direction; }
private void Update() { if (Input.GetMouseButtonDown(0)) { Hitscan.Cast(transform.position, camera.transform.forward, HitscanType.damage, dHealth, layerMask: hitscanMask); } if (Input.GetMouseButtonDown(1)) { Hitscan.Cast(transform.position, camera.transform.forward, HitscanType.eventScan, cEvent: new UseEvent(), layerMask: hitscanMask); } }
Hitscan() { if (Engine.EditorHint) { return; } HitscanTrailScene = GD.Load <PackedScene>("res://Items/Logic/Hitscan/HitscanTrail.tscn"); Self = this; Reset(); }
void setGuns() { StringReader GDLines = new StringReader(gunData.text); //Debug.Log(path); //Debug.Log(inputline); String inputline = ""; GDLines.ReadLine(); while ((inputline = GDLines.ReadLine()) != null) { string[] currentGunData = inputline.Split(); string gunName = currentGunData[0]; float gunDamage = float.Parse(currentGunData[1], CultureInfo.InvariantCulture.NumberFormat); float gunReload = float.Parse(currentGunData[2], CultureInfo.InvariantCulture.NumberFormat); float gunFireRate = float.Parse(currentGunData[3], CultureInfo.InvariantCulture.NumberFormat); //Debug.Log(currentGunData[4]); int gunClipSize = Int32.Parse(currentGunData[4]); bool gunAuto = currentGunData[5].Equals("1"); float gunAccuracy = float.Parse(currentGunData[7], CultureInfo.InvariantCulture.NumberFormat); int gunPrice = Int32.Parse(currentGunData[8]); if (currentGunData[6].Equals("1")) { if (currentGunData[0].Contains("Shotgun")) { Shotgun newShotgun = new Shotgun(); newShotgun.setVals(gunName, gunDamage, gunReload, gunFireRate, gunClipSize, gunAuto, gunAccuracy, ShotTracer, gunPrice); guns.Add(newShotgun); } else if (currentGunData[0].Contains("Beam")) { Beam newBeam = new Beam(); newBeam.setVals(gunName, gunDamage, gunReload, gunFireRate, gunClipSize, gunAuto, gunAccuracy, ShotTracer, gunPrice); guns.Add(newBeam); } else { Hitscan newHitscan = new Hitscan(); newHitscan.setVals(gunName, gunDamage, gunReload, gunFireRate, gunClipSize, gunAuto, gunAccuracy, ShotTracer, gunPrice); guns.Add(newHitscan); } } else { Projectile newProj = new Projectile(); newProj.setVals(gunName, gunDamage, gunReload, gunFireRate, gunClipSize, gunAuto, gunAccuracy, ShotTracer, gunPrice); guns.Add(newProj); } nameToGun.Add(gunName, guns.Count - 1); } //Debug.Log(guns.Count); }
public void InventoryDown() { if (!(CurrentCooldown < CurrentMaxCooldown && PreventSwitch)) { BuildRotation = 0; InventorySlot++; if (InventorySlot > 9) { InventorySlot = 0; } HUDInstance.HotbarUpdate(); Hitscan.Reset(); SetCooldown(0, SlotSwitchCooldown, false); } }
public static void Fire(Items.Instance Item, Player UsingPlayer) { Hitscan.QueueFire(0, 0, Range, HeadshotDamage, BodyshotDamage, LegshotDamage); Hitscan.ApplyQueuedFire(); Hitscan.ApplyAdditiveRecoil(VerticalRecoil, RecoilLength); if (UsingPlayer.IsCrouching) { UsingPlayer.SetCooldown(0, FireCooldown * UsingPlayer.AdsMultiplier * Hitscan.CrouchAffectPercentage, true); } else { UsingPlayer.SetCooldown(0, FireCooldown * UsingPlayer.AdsMultiplier, true); } UsingPlayer.SfxManager.FpThunderboltFire(); }
public static void InventoryDown() { Game.PossessedPlayer.MatchSome( (Plr) => { if (!(Plr.CurrentCooldown < Plr.CurrentMaxCooldown && Plr.PreventSwitch)) { Plr.BuildRotation = 0; Plr.InventorySlot++; if (Plr.InventorySlot > 9) { Plr.InventorySlot = 0; } Plr.HUDInstance.HotbarUpdate(); Hitscan.Reset(); Plr.SetCooldown(0, Player.SlotSwitchCooldown, false); Plr.Ads = false; } } ); }
void Fire() { // Make sure this shot counts for getting a stack Status markStatus = new Status(gameObject, StatusType.SuperlaserMark); markStatus.SetTimeLeft(CalcDamage()); Hitscan shot = new Hitscan(shotTemplate); shot.SetDamage(0); for (int i = 1; i < sourcePositions.Length; i++) { hitscans.SpawnHitscan(shot, sourcePositions[i].position, sourcePositions[0].forward, parentUnit, markStatus); } shot.SetDamage(CalcDamage()); hitscans.SpawnHitscan(shot, sourcePositions[0].position, sourcePositions[0].forward, parentUnit, markStatus); Destroy(countdownStart); // TODO: ??? //Instantiate(countdownFinishExplosion, targetUnit.transform.position, Quaternion.identity); // Explosion Instantiate(countdownFinishPrefab, transform.position, Quaternion.identity); // Sound TODO: ??? Reset(); StartCooldown(); // Now start ability cooldown }
public void SpawnHitscan(Hitscan temp, Vector3 position, Vector3 direction, Unit from, Status onHit, ITargetable goal) { Hitscan scan = new Hitscan(temp); scan.startPosition = position; scan.direction = direction; scan.SetFrom(from); scan.SetStatus(onHit); //hitscans.Add(scan); int index = IndexFromHitscanType(temp.GetHitscanType()); bool noGoal = IsNull(goal); // Raycast or do damage immediately. Use actual distance / hit information to inform visuals Vector3 dif = noGoal ? Vector3.zero : (position - goal.GetPosition()); float length = noGoal ? Raycast(scan) : dif.magnitude; if (!noGoal) // Has goal, do damage manually { goal.Damage(scan.GetDamage(), length, scan.GetDamageType()); vfx.SpawnEffect(VFXType.Hit_Near, position + direction * length, direction, scan.GetFrom().GetTeam()); } Vector3 size = new Vector3(pS[index].main.startSizeX.constant, length, 1); EmitParams param = new EmitParams() { position = position, velocity = direction * directionMult, startSize3D = size, //startColor = Random.value * Color.red + Random.value * Color.green + Random.value * Color.blue, startLifetime = scan.GetLifetime() // 2x just in case. Particles dying prematurely is the worst thing that could happen to this system }; pS[index].Emit(param, 1); }
public void SpawnHitscan(Hitscan temp, Vector3 position, Vector3 direction, Unit from, Status onHit) { SpawnHitscan(temp, position, direction, from, onHit, null); }
public void Fire(WeaponFireEvent fireEvent) { Hitscan.Cast(fireEvent.ray, dHealth, distance, layerMask, penetrate, OnHit: OnHit); }
// Called immediately after a hitscan is spawned float Raycast(Hitscan scan) { // Raycast according to start position, direction, and range RaycastHit hit; if (Physics.Raycast(scan.startPosition, scan.direction, out hit, scan.GetRange(), mask)) { int scanTeam = scan.GetFrom().Team; Unit unit = null; bool hitSelf = false; if (hit.collider.transform.parent) // Is this a unit? { unit = hit.collider.transform.parent.GetComponent <Unit>(); if (unit) // Is this a unit? { if (unit != scan.GetFrom()) // If we hit a unit and its not us, damage it { Status status = scan.GetStatus(); if (status != null) { if (status.statusType == StatusType.SuperlaserMark) { status.SetTimeLeft(scan.GetDamage() < gameRules.ABLY_superlaserDmgByStacks[1] ? scan.GetDamage() * SL_turretMult : scan.GetDamage() * SL_superlaserMult); // Store damage in timeLeft field of status } unit.AddStatus(status); } float actualRange = (hit.point - scan.startPosition).magnitude; // If we hit an ally, do reduced damage because it was an accidental hit bool doFullDamage = DamageUtils.IgnoresFriendlyFire(scan.GetDamageType()) || unit.Team != scanTeam; DamageResult result = unit.Damage(doFullDamage ? scan.GetDamage() : scan.GetDamage() * gameRules.DMG_ffDamageMult, actualRange, scan.GetDamageType()); if (result.lastHit && scan.GetFrom()) { scan.GetFrom().AddKill(unit); } } else { // Ignore this collision hitSelf = true; // TODO: Adapt friendly fire code for raycasting here } } } Vector3 endPosition = (hit.point - scan.direction * gameRules.PRJ_hitOffset); // Don't do anything if we are passing through the unit that fired us if (!hitSelf) { if (unit) { if (unit.GetShields().x > 0) // Shielded { vfx.SpawnEffect(VFXType.Hit_Absorbed, endPosition, -scan.direction, scanTeam); } else // Normal hit { vfx.SpawnEffect(VFXType.Hit_Normal, endPosition, -scan.direction, scanTeam); } } else // Terrain { vfx.SpawnEffect(VFXType.Hit_Normal, endPosition, -scan.direction, scanTeam); } return((scan.startPosition - endPosition).magnitude); // Return actual length of hitscan } } //if Raycast return(scan.GetRange()); }
private void Start() { Player.coins = 0; levelEnd = GameObject.Find("Portal"); levelEnd.SetActive(false); //coins = PlayerPrefs.GetInt("coins", 0); Physics2D.IgnoreLayerCollision(9, 10); Physics2D.IgnoreLayerCollision(9, 2); Physics2D.IgnoreLayerCollision(10, 2); Physics2D.IgnoreLayerCollision(2, 2); //currentScene = SceneManager.GetActiveScene().buildIndex; GM = FindObjectOfType <GameManager>(); gunObject = transform.Find("Guns").gameObject; guns = GunData.guns; nameToGun = GunData.nameToGun; int[] gunSlots = PlayerPrefsX.GetIntArray("gunsEquipped", 0, 2); gunsEquipped.Add(gunSlots[0]); gunsEquipped.Add(gunSlots[1]); //Debug.Log(gunSlots[0]); //Debug.Log(gunSlots[1]); for (int i = 0; i < guns.Count; i++) { if (gunsEquipped.Contains(i)) { Gun clone = new Gun(); if (guns[i] is Shotgun) { clone = new Shotgun(); } else if (guns[i] is Beam) { clone = new Beam(); } else if (guns[i] is Hitscan) { clone = new Hitscan(); } else if (guns[i] is Projectile) { clone = new Projectile(); } clone.setVals(guns[i]); playerGuns.Add(clone); Debug.Log(nameToGun[clone.gunName]); playerGunsObjects.Add(nameToGun[clone.gunName], gunObject.transform.Find(clone.gunName).gameObject); } } gun = playerGuns[currentGun]; playerGunsObjects[nameToGun[playerGuns[currentGun].gunName]].SetActive(true); gunAccuracy = gun.accuracy; crouchAccuracy = gunAccuracy / 2; if (healthBar.barHeight == 0) { healthBar.barHeight = 0.5f; } if (healthBar.barLength == 0) { healthBar.barLength = 2f; } healthBar.bar.startWidth = healthBar.barHeight / 2; healthBar.bar.material.color = Color.red; healthBar.bar.positionCount = 2; healthBar.health.startWidth = healthBar.barHeight / 2; healthBar.health.material.color = Color.green; healthBar.health.positionCount = 2; }