void attack() { attackOrdered = false; if (Type.PreparationDelay != 0 && !self.DoesAction(ActionType.PREPARE_ATTACK)) { return; // Preparation has been canceled } var weapon = WeaponCache.Create(self.World, info.Type, target, self); Target = weapon.TargetPosition; beam = weapon as BeamWeapon; if (self.AttackWith(target, weapon)) { var reloadModifier = 1f; foreach (var effect in self.GetEffects(EffectType.COOLDOWN)) { reloadModifier *= effect.Effect.Value; } Reload = (int)(Type.Reload * reloadModifier); var cooldownAction = new ActorAction(ActionType.END_ATTACK, Type.CooldownDelay); self.AddAction(ActionType.ATTACK, Type.ShootDuration, cooldownAction); } }
// Use this for initialization void Start() { Name.text = Player.name; Weapon = Player.GetComponent<BeamWeapon>(); transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, 0.0f); _positionLock = transform.localPosition; }
// Use this for initialization void Start() { Name.text = Player.name; Weapon = Player.GetComponent <BeamWeapon>(); transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, 0.0f); _positionLock = transform.localPosition; }
public void NewSpecialWeapon() { // initialize special slot weapon weapons[SPECIAL_WEAPON_SLOT] = Instantiate(weapons[SPECIAL_WEAPON_SLOT]) as GameObject; InitializeWeapon(GetWeapon(SPECIAL_WEAPON_SLOT)); // the weapon prefabs don't default to hitting enemies (only scenery), // so add it to their list of targets. weapons[SPECIAL_WEAPON_SLOT].GetComponent <DamageSystem>().targets.Add("Enemy"); SwitchWeapon(SPECIAL_WEAPON_SLOT); _specialGun = weapons[SPECIAL_WEAPON_SLOT].GetComponent <Gun>(); _specialBeam = weapons[SPECIAL_WEAPON_SLOT].GetComponent <BeamWeapon>(); SetBuffs(); // disable possibly active and set to current gun ammoRing.SetActive(false); ammoRing.SetActive(true); }
void OnEnable() { // get special weapon and total ammo, update with gun and current ammo _playerWeapons = GetComponentInParent <PlayerWeapons>(); _isGun = _playerWeapons.DetermineSpecialType(); if (_isGun) { _specialGun = _playerWeapons.weapons[PlayerWeapons.SPECIAL_WEAPON_SLOT].GetComponent <Gun>(); _initialAmmo = _specialGun.ammo; UpdateGunAmmoBar(_specialGun.ammo); } else { _specialBeam = _playerWeapons.weapons[PlayerWeapons.SPECIAL_WEAPON_SLOT].GetComponent <BeamWeapon>(); _initialTime = _specialBeam.duration; UpdateBeamAmmoBar(_initialTime); } }
void OnEnable() { // get special weapon and total ammo, update with gun and current ammo _playerWeapons = GetComponentInParent<PlayerWeapons>(); _isGun = _playerWeapons.DetermineSpecialType(); if ( _isGun ) { _specialGun = _playerWeapons.weapons[PlayerWeapons.SPECIAL_WEAPON_SLOT].GetComponent<Gun>(); _initialAmmo = _specialGun.ammo; UpdateGunAmmoBar( _specialGun.ammo ); } else { _specialBeam = _playerWeapons.weapons[PlayerWeapons.SPECIAL_WEAPON_SLOT].GetComponent<BeamWeapon>(); _initialTime = _specialBeam.duration; UpdateBeamAmmoBar( _initialTime ); } }
public void Tick() { Reload--; if (attackOrdered && --prep <= 0) { attack(); } if (beam != null) { if (beam.Disposed) { beam = null; } else { beam.Move(Target, TargetHeight); } } }
public void Init(Weapon weapon, MonsterCharacter _) { BeamWeapon beam = (BeamWeapon)weapon; if (beam != null) { beam.OnFire.AddListener(() => { waitTimer = WaitTime; progressControl.always = true; float distance = beam.beamLength + beam.BeamDistanceMod; if (distance < 1f) { distance = 1f; } progressControl.maxLength = distance; transform.GetChild(0).gameObject.SetActive(true); }); } progressControl.always = false; }
public void OnLoad(PartLoader loader) { foreach (var node in loader.GetNodes(typeof(WeaponPart), info.InternalName)) { if (node.Key == "BeamWeapon") { var id = node.Convert <int>(); beam = (BeamWeapon)self.World.WeaponLayer.Weapons.Find(w => w.ID == id); } else if (node.Key == "PreparationTick") { prep = node.Convert <int>(); } else if (node.Key == nameof(Reload)) { Reload = node.Convert <int>(); } else if (node.Key == "Target") { var pos = node.Convert <CPos>(); target = new Target(new CPos(pos.X, pos.Y, 0), pos.Z); } } }
public void NewSpecialWeapon() { // initialize special slot weapon weapons[SPECIAL_WEAPON_SLOT] = Instantiate( weapons[SPECIAL_WEAPON_SLOT] ) as GameObject; InitializeWeapon( GetWeapon( SPECIAL_WEAPON_SLOT ) ); // the weapon prefabs don't default to hitting enemies (only scenery), // so add it to their list of targets. weapons[SPECIAL_WEAPON_SLOT].GetComponent<DamageSystem>().targets.Add( "Enemy" ); SwitchWeapon( SPECIAL_WEAPON_SLOT ); _specialGun = weapons[SPECIAL_WEAPON_SLOT].GetComponent<Gun>(); _specialBeam = weapons[SPECIAL_WEAPON_SLOT].GetComponent<BeamWeapon>(); SetBuffs(); // disable possibly active and set to current gun ammoRing.SetActive( false ); ammoRing.SetActive( true ); }
public override void OnInspectorGUI() { BeamWeapon script = (BeamWeapon)target; GUIContent tooltip = new GUIContent("", ""); /* GENERAL SETTINGS */ EditorGUILayout.Space(); EditorGUILayout.LabelField("General:", EditorStyles.boldLabel); tooltip = new GUIContent("Origin:", "Transform at the end of the muzzle where projectiles originate from"); script.shotOrigin = (Transform)EditorGUILayout.ObjectField(tooltip, script.shotOrigin, typeof(Transform), true); tooltip = new GUIContent("Audio Source:", "An audio source to handle gun sounds"); script.audioSrc = (AudioSource)EditorGUILayout.ObjectField(tooltip, script.audioSrc, typeof(AudioSource), true); /* VISUAL SETTINGS */ EditorGUILayout.Space(); EditorGUILayout.LabelField("Visual:", EditorStyles.boldLabel); tooltip = new GUIContent("Hit Effect:", "Prefab Particle System to be played where the bullet hits"); script.hitEffect = (ParticleSystem)EditorGUILayout.ObjectField(tooltip, script.hitEffect, typeof(ParticleSystem), true); tooltip = new GUIContent("Hit Emission:", "Number of hit particles emitted when the bullet collides"); script.hitParticles = (uint)EditorGUILayout.Slider(tooltip, script.hitParticles, 0, 100); tooltip = new GUIContent("On Fire", "List of scripts to execute when the gun fires"); showFireList = EditorGUILayout.Foldout(showFireList, tooltip); if (showFireList) { for (int i = 0; i < script.onFire.Count; i++) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("-", GUILayout.Width(23))) { script.onFire.RemoveAt(i); } else { script.onFire[i] = (MBAction)EditorGUILayout.ObjectField("", script.onFire[i], typeof(MBAction), true); } EditorGUILayout.EndHorizontal(); } if (script.onFire.Count > 0) { EditorGUILayout.Space(); } if (GUILayout.Button("+", GUILayout.Width(23))) { script.onFire.Add(default(MBAction)); } } /* AUDIO SETTINGS */ EditorGUILayout.Space(); EditorGUILayout.LabelField("Audio:", EditorStyles.boldLabel); tooltip = new GUIContent("Fire sounds", "A list of sounds that can be played when the gun is fired. One will be picked at random"); showSoundList = EditorGUILayout.Foldout(showSoundList, tooltip); if (showSoundList) { for (int i = 0; i < script.shotSound.Count; i++) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("-", GUILayout.Width(23))) { script.shotSound.RemoveAt(i); } else { script.shotSound[i] = (AudioClip)EditorGUILayout.ObjectField("", script.shotSound[i], typeof(AudioClip), false); } EditorGUILayout.EndHorizontal(); } if (script.shotSound.Count > 0) { EditorGUILayout.Space(); } if (GUILayout.Button("+", GUILayout.Width(23))) { script.shotSound.Add(new AudioClip()); } } EditorGUILayout.Space(); /* GUN SETTINGS */ EditorGUILayout.LabelField("Standard Properties:", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); tooltip = new GUIContent("Fire Mode:", "Semi-Auto guns will fire once per mouse-click. Auto guns will fire continuously while the fire button is held down"); EditorGUILayout.LabelField(tooltip); script.fMode = (FIRE_MODE)EditorGUILayout.EnumPopup(script.fMode); EditorGUILayout.EndHorizontal(); tooltip = new GUIContent("Damage:", "The amount of damage a single bullet will inflict on collision"); script.damage = EditorGUILayout.Slider(tooltip, script.damage, 0.1f, 300.0f); tooltip = new GUIContent("Damage Tags", "A list of tags which will either be ignored or exclusively damaged"); showDmgTagsList = EditorGUILayout.Foldout(showDmgTagsList, tooltip); if (showDmgTagsList) { tooltip = new GUIContent("Mode", "IgnoreSelected: Any objects with these tags will not be damaged.\nHitSelected: Any objects with these tags will be damaged. All others will be ignored"); script.dmgTagsMode = (COLLISION_MODE)EditorGUILayout.EnumPopup(tooltip, script.dmgTagsMode); for (int i = 0; i < script.dmgTags.Count; i++) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("-", GUILayout.Width(23))) { script.dmgTags.RemoveAt(i); } else { script.dmgTags[i] = EditorGUILayout.TextField(script.dmgTags[i]); } EditorGUILayout.EndHorizontal(); } if (script.dmgTags.Count > 0) { EditorGUILayout.Space(); } if (GUILayout.Button("+", GUILayout.Width(23))) { script.dmgTags.Add(""); } } tooltip = new GUIContent("Spread:", "Accuracy of shots, where 0 = completely accurate"); script.spread = EditorGUILayout.Slider(tooltip, script.spread, 0.0f, 10.0f); EditorGUILayout.Space(); /* BEAM WEAPON SETTINGS */ EditorGUILayout.LabelField("Beam Weapon Specifics", EditorStyles.boldLabel); tooltip = new GUIContent("Pulse Curve:", "Controls how the beam pulses over time"); script.pulseCurve = EditorGUILayout.CurveField(tooltip, script.pulseCurve); tooltip = new GUIContent("Line Renderer:", "Specify a line renderer component to be used"); script.lr = (LineRenderer)EditorGUILayout.ObjectField(tooltip, script.lr, typeof(LineRenderer), true); tooltip = new GUIContent("Laser Origin:", "Point where the laser will start from"); script.laserStart = (Transform)EditorGUILayout.ObjectField(tooltip, script.laserStart, typeof(Transform), true); tooltip = new GUIContent("Hitscan Range:", "The maximum range of a bullet when using hitscan firing method"); script.hitscanRange = EditorGUILayout.Slider(tooltip, script.hitscanRange, 5.0f, 200.0f); /* HEAT MECHANICS */ EditorGUILayout.LabelField("Heat Mechanics:", EditorStyles.boldLabel); tooltip = new GUIContent("Use Heat:", "Toggle the use of heat mechanics for this weapon"); script.useHeatMechanics = EditorGUILayout.Toggle(tooltip, script.useHeatMechanics); if (script.useHeatMechanics) { // Show all heat mechanics settings here tooltip = new GUIContent("Heat/Time:", "If true, 'heatRise' heat will be applied over one second while firing. \nElse 'heatRise' heat will be applied with each shot."); script.heatOverTime = EditorGUILayout.Toggle(tooltip, script.heatOverTime); tooltip = new GUIContent("Heat Rise:", "Amount heat will rise while firing"); script.heatRise = EditorGUILayout.Slider(tooltip, script.heatRise, 0, 100); tooltip = new GUIContent("Instant Reset:", "If true, heat will instantly reset to 0 once cooldown begins. Else 'heatFall' heat will be subtracted over each second"); script.instantHeatReset = EditorGUILayout.Toggle(tooltip, script.instantHeatReset); if (!script.instantHeatReset) { tooltip = new GUIContent(" Heat Fall:", "Amount heat will fall while not firing"); script.heatFall = EditorGUILayout.Slider(tooltip, script.heatFall, 0, 100); } tooltip = new GUIContent("Cooldown Delay:", "Delay in seconds before the gun will begin to cool down"); script.heatFallWait = EditorGUILayout.Slider(tooltip, script.heatFallWait, 0, 10); tooltip = new GUIContent("Cool Enable:", "Firing will be re-enabled once the gun cools to this value"); script.heatReEnable = EditorGUILayout.Slider(tooltip, script.heatReEnable, 0, 100); } EditorGUILayout.Space(); }
public void DisplayItemComparison(Item h, Item s) { Populate(hovered, h); Populate(slotted, s); if (h is WeaponBase && s is WeaponBase) { WeaponBase hw = h as WeaponBase; WeaponBase sw = s as WeaponBase; if (hw.DPS() > sw.DPS()) { hovered.dps.color = Color.green; slotted.dps.color = Color.red; } else if (hw.DPS() < sw.DPS()) { hovered.dps.color = Color.red; slotted.dps.color = Color.green; } if (hw.Stats.CritChance > sw.Stats.CritChance) { hovered.critChance.color = Color.green; slotted.critChance.color = Color.red; } else if (hw.Stats.CritChance < sw.Stats.CritChance) { hovered.critChance.color = Color.red; slotted.critChance.color = Color.green; } if (hw.Stats.CritDamage > sw.Stats.CritDamage) { hovered.critDamage.color = Color.green; slotted.critDamage.color = Color.red; } else if (hw.Stats.CritDamage < sw.Stats.CritDamage) { hovered.critDamage.color = Color.red; slotted.critDamage.color = Color.green; } if (h is ProjectileWeapon && s is ProjectileWeapon) { ProjectileWeapon hpw = h as ProjectileWeapon; ProjectileWeapon spw = s as ProjectileWeapon; int hAmmo = (hpw.Ammunition == 0) ? int.MaxValue : hpw.Ammunition; int sAmmo = (spw.Ammunition == 0) ? int.MaxValue : spw.Ammunition; if (hAmmo > sAmmo) { hovered.stat1Value.color = Color.green; slotted.stat1Value.color = Color.red; } else if (hAmmo < sAmmo) { hovered.stat1Value.color = Color.red; slotted.stat1Value.color = Color.green; } if (hpw.RateOfFire > spw.RateOfFire) { hovered.stat2Value.color = Color.green; slotted.stat2Value.color = Color.red; } else if (hpw.RateOfFire < spw.RateOfFire) { hovered.stat2Value.color = Color.red; slotted.stat2Value.color = Color.green; } if (hpw.ReloadTime < spw.ReloadTime) { hovered.stat3Value.color = Color.green; slotted.stat3Value.color = Color.red; } else if (hpw.ReloadTime > spw.ReloadTime) { hovered.stat3Value.color = Color.red; slotted.stat3Value.color = Color.green; } } else if (h is BeamWeapon && s is BeamWeapon) { BeamWeapon hbw = h as BeamWeapon; BeamWeapon sbw = s as BeamWeapon; if (hbw.PowerConsumption < sbw.PowerConsumption) { hovered.stat1Value.color = Color.green; slotted.stat1Value.color = Color.red; } else if (hbw.PowerConsumption > sbw.PowerConsumption) { hovered.stat1Value.color = Color.red; slotted.stat1Value.color = Color.green; } if (hbw.DamageFalloff > sbw.DamageFalloff) { hovered.stat2Value.color = Color.green; slotted.stat2Value.color = Color.red; } else if (hbw.DamageFalloff < sbw.DamageFalloff) { hovered.stat2Value.color = Color.red; slotted.stat2Value.color = Color.green; } } } }
private void Populate(InfoPanel panel, Item item) { // do not show the panel if it doesn't contain an item panel.gameObject.SetActive(item != null); if (item == null) { return; } panel.ResetFields(); panel.border.color = Constants.RarityColor[item.Rarity]; panel.title.text = item.name; panel.title.color = Constants.RarityColor[item.Rarity]; panel.slot.text = item.Slot().ToString(); if (item is WeaponBase) { WeaponBase w = item as WeaponBase; panel.dps.text = w.DPS().ToString("n0"); StringBuilder sb = new StringBuilder(); foreach (DamageTypes dt in w.Stats.Sort()) { if (w.Stats.Damage(dt) > 0) { sb.Append(dt.ToString()); sb.Append(", "); } } panel.damageType.text = sb.ToString().TrimEnd(',', ' '); panel.critChance.text = w.Stats.CritChance.ToString("p1"); panel.critDamage.text = w.Stats.CritDamage.ToString("p0"); if (item is ProjectileWeapon) { ProjectileWeapon p = item as ProjectileWeapon; panel.itemClass.text = "Projectile Weapon"; panel.stat1Title.text = "Ammo:"; panel.stat1Value.text = p.Ammunition.ToString("n0"); panel.stat1Title.transform.parent.gameObject.SetActive(true); panel.stat2Title.text = "RoF:"; panel.stat2Value.text = p.RateOfFire.ToString("n2"); panel.stat2Title.transform.parent.gameObject.SetActive(true); panel.stat3Title.text = "Reload:"; panel.stat3Value.text = p.ReloadTime.ToString("n3"); panel.stat3Title.transform.parent.gameObject.SetActive(true); } else if (item is BeamWeapon) { BeamWeapon b = item as BeamWeapon; panel.itemClass.text = "Beam Weapon"; panel.stat1Title.text = "Power:"; panel.stat1Value.text = b.PowerConsumption.ToString("n0") + "/s"; panel.stat1Title.transform.parent.gameObject.SetActive(true); panel.stat2Title.text = "Falloff:"; panel.stat2Value.text = b.DamageFalloff.ToString("n2") + "m"; panel.stat2Title.transform.parent.gameObject.SetActive(true); panel.stat3Title.text = "Tick Rate:"; panel.stat3Value.text = b.TickRate.ToString("n0"); panel.stat3Title.transform.parent.gameObject.SetActive(true); } } }