public override void StateBegin() { if (currentReloadAnimation != null) { Destroy(currentReloadAnimation.gameObject); } currentReloadAnimation = Instantiate <ReloadAnimation>(forGun.gunStats.reloadAnimation); currentReloadAnimation.transform.SetParent(animationCLocation, false); currentReloadAnimation.transform.localPosition = Vector3.zero; currentReloadAnimation.SetShotCount(forGun.GetShotsLeft()); currentTimer = forGun.gunStats.reloadDelay; }
IEnumerator HideReloadAnimation(ReloadAnimation animation) { float timer = 0.5f; while (timer > 0.0f && animation != null) { animation.SetShotCount(forGun.GetShotsLeft()); timer -= Time.deltaTime; yield return(null); } if (animation != null) { Destroy(animation.gameObject); } }
public static IEnumerator ReloadAnimation(GunStats forGun, Transform at, VariableStore variableStore) { ReloadAnimation currentReloadAnimation = Instantiate <ReloadAnimation>(forGun.reloadAnimation); currentReloadAnimation.transform.SetParent(at, false); currentReloadAnimation.transform.localPosition = Vector3.zero; int currentShots = 0; currentReloadAnimation.SetShotCount(currentShots); yield return(AsyncUtil.Pause(forGun.reloadDelay)); while (currentShots < forGun.capacity) { ++currentShots; forGun.SetShotsLeft(variableStore, currentShots); currentReloadAnimation.SetShotCount(currentShots); yield return(AsyncUtil.Pause(forGun.reloadBulletDuration)); } Destroy(currentReloadAnimation.gameObject); }
protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; ele.TryPathTo("AnimationType", true, out subEle); subEle.Value = AnimationType.ToString(); ele.TryPathTo("AnimationMultiplier", true, out subEle); subEle.Value = AnimationMultiplier.ToString("G15"); ele.TryPathTo("Reach", true, out subEle); subEle.Value = Reach.ToString("G15"); ele.TryPathTo("Flags1", true, out subEle); subEle.Value = Flags1.ToString(); ele.TryPathTo("GripAnimation", true, out subEle); subEle.Value = GripAnimation.ToString(); ele.TryPathTo("AmmoUse", true, out subEle); subEle.Value = AmmoUse.ToString(); ele.TryPathTo("ReloadAnimation", true, out subEle); subEle.Value = ReloadAnimation.ToString(); ele.TryPathTo("MinSpread", true, out subEle); subEle.Value = MinSpread.ToString("G15"); ele.TryPathTo("Spread", true, out subEle); subEle.Value = Spread.ToString("G15"); ele.TryPathTo("Unknown", true, out subEle); subEle.Value = Unknown.ToHex(); ele.TryPathTo("SightFOV", true, out subEle); subEle.Value = SightFOV.ToString("G15"); ele.TryPathTo("Unknown2", true, out subEle); subEle.Value = Unknown2.ToString("G15"); ele.TryPathTo("Projectile", true, out subEle); Projectile.WriteXML(subEle, master); ele.TryPathTo("BaseVATSToHitChance", true, out subEle); subEle.Value = BaseVATSToHitChance.ToString(); ele.TryPathTo("AttackAnimation", true, out subEle); subEle.Value = AttackAnimation.ToString(); ele.TryPathTo("ProjectileCount", true, out subEle); subEle.Value = ProjectileCount.ToString(); ele.TryPathTo("EmbeddedWeaponActorValue", true, out subEle); subEle.Value = EmbeddedWeaponActorValue.ToString(); ele.TryPathTo("Range/Min", true, out subEle); subEle.Value = MinRange.ToString("G15"); ele.TryPathTo("Range/Max", true, out subEle); subEle.Value = MaxRange.ToString("G15"); ele.TryPathTo("LimbKillBehavior", true, out subEle); subEle.Value = LimbKillBehavior.ToString(); ele.TryPathTo("Flags2", true, out subEle); subEle.Value = Flags2.ToString(); ele.TryPathTo("AttackAnimationMultiplier", true, out subEle); subEle.Value = AttackAnimationMultiplier.ToString("G15"); ele.TryPathTo("FireRate", true, out subEle); subEle.Value = FireRate.ToString("G15"); ele.TryPathTo("ActionPointCost", true, out subEle); subEle.Value = ActionPointCost.ToString("G15"); ele.TryPathTo("Rumble/LeftMotorStrength", true, out subEle); subEle.Value = RumbleLeftMotorStrength.ToString("G15"); ele.TryPathTo("Rumble/RightMotorStrength", true, out subEle); subEle.Value = RumbleRightMotorStrength.ToString("G15"); ele.TryPathTo("Rumble/Duration", true, out subEle); subEle.Value = RumbleDuration.ToString("G15"); ele.TryPathTo("DamageToWeaponMult", true, out subEle); subEle.Value = DamageToWeaponMult.ToString("G15"); ele.TryPathTo("AttackShotsPerSecond", true, out subEle); subEle.Value = AttackShotsPerSecond.ToString("G15"); ele.TryPathTo("ReloadTime", true, out subEle); subEle.Value = ReloadTime.ToString("G15"); ele.TryPathTo("JamTime", true, out subEle); subEle.Value = JamTime.ToString("G15"); ele.TryPathTo("AimArc", true, out subEle); subEle.Value = AimArc.ToString("G15"); ele.TryPathTo("Skill", true, out subEle); subEle.Value = Skill.ToString(); ele.TryPathTo("Rumble/Pattern", true, out subEle); subEle.Value = RumblePattern.ToString(); ele.TryPathTo("Rumble/Wavelength", true, out subEle); subEle.Value = RumbleWavelength.ToString("G15"); ele.TryPathTo("LimbDamageMult", true, out subEle); subEle.Value = LimbDamageMult.ToString("G15"); ele.TryPathTo("ResistanceType", true, out subEle); subEle.Value = ResistanceType.ToString(); ele.TryPathTo("SightUsage", true, out subEle); subEle.Value = SightUsage.ToString("G15"); ele.TryPathTo("SemiAutomaticFireDelay/Min", true, out subEle); subEle.Value = SemiAutomaticFireDelayMin.ToString("G15"); ele.TryPathTo("SemiAutomaticFireDelay/Max", true, out subEle); subEle.Value = SemiAutomaticFireDelayMax.ToString("G15"); ele.TryPathTo("Unknown3", true, out subEle); subEle.Value = Unknown3.ToString("G15"); ele.TryPathTo("Mods/Mod1/Effect", true, out subEle); subEle.Value = Mod1Effect.ToString(); ele.TryPathTo("Mods/Mod2/Effect", true, out subEle); subEle.Value = Mod2Effect.ToString(); ele.TryPathTo("Mods/Mod3/Effect", true, out subEle); subEle.Value = Mod3Effect.ToString(); ele.TryPathTo("Mods/Mod1/ValueA", true, out subEle); subEle.Value = Mod1ValueA.ToString("G15"); ele.TryPathTo("Mods/Mod2/ValueA", true, out subEle); subEle.Value = Mod2ValueA.ToString("G15"); ele.TryPathTo("Mods/Mod3/ValueA", true, out subEle); subEle.Value = Mod3ValueA.ToString("G15"); ele.TryPathTo("PowerAttackAnimation", true, out subEle); subEle.Value = PowerAttackAnimation.ToString(); ele.TryPathTo("StrengthRequirement", true, out subEle); subEle.Value = StrengthRequirement.ToString(); ele.TryPathTo("Unknown4", true, out subEle); subEle.Value = Unknown4.ToString(); ele.TryPathTo("Mods/Mod1/ReloadAnimation", true, out subEle); subEle.Value = Mod1ReloadAnimation.ToString(); ele.TryPathTo("Unknown5", true, out subEle); subEle.Value = Unknown5.ToHex(); ele.TryPathTo("AmmoRegenRate", true, out subEle); subEle.Value = AmmoRegenRate.ToString("G15"); ele.TryPathTo("KillImpulse", true, out subEle); subEle.Value = KillImpulse.ToString("G15"); ele.TryPathTo("Mods/Mod1/ValueB", true, out subEle); subEle.Value = Mod1ValueB.ToString("G15"); ele.TryPathTo("Mods/Mod2/ValueB", true, out subEle); subEle.Value = Mod2ValueB.ToString("G15"); ele.TryPathTo("Mods/Mod3/ValueB", true, out subEle); subEle.Value = Mod3ValueB.ToString("G15"); ele.TryPathTo("ImpulseDistance", true, out subEle); subEle.Value = ImpulseDistance.ToString("G15"); ele.TryPathTo("SkillRequirement", true, out subEle); subEle.Value = SkillRequirement.ToString(); }
public override void StateEnd() { StartCoroutine(HideReloadAnimation(currentReloadAnimation)); currentReloadAnimation = null; }