public UnitRecord(int unitId, int stackId) { Id = GameDataSequences.GetNextSequence("Unit"); UnitTypeId = new UnitTypeId(unitId); StackId = new StackId(stackId); var gameConfigCache = CallContext <GameConfigCache> .GetData("GameConfigCache"); var unit = gameConfigCache.GetUnitConfigById(unitId); MovementPoints = new MovementPoints((float)unit.MovementPoints); }
/// <summary> /// reloads weapon. /// plays reloading particle depending on unit type. /// </summary> /// <param name="type">unit type</param> /// <returns></returns> public bool Reload(UnitTypeId type) { this.state = WeaponState.Reloading; ParticleType reloadParticle = ParticleType.Count; SoundTrack reloadSound = SoundTrack.Count; switch (this.WeaponType) { case WeaponType.PlayerMachineGun: { reloadParticle = ParticleType.PlayerMachineGunReload; switch (type) { case UnitTypeId.Grund: case UnitTypeId.Kiev: reloadSound = SoundTrack.PlayerMachineGunGrundReload; break; case UnitTypeId.Mark: case UnitTypeId.Yager: reloadSound = SoundTrack.PlayerMachineGunMarkReload; break; } } break; case WeaponType.PlayerShotgun: { // Shotgun reload is no particle reloadSound = SoundTrack.PlayerShotgunReload; } break; case WeaponType.PlayerHandgun: { reloadParticle = ParticleType.PlayerHandgunReload; reloadSound = SoundTrack.PlayerHandgunReload; } break; } // Play a reloading particle if (reloadParticle != ParticleType.Count) { for (int i = 0; i < SpecData.ModelCount; i++) { int boneIdx = -1; Matrix boneTransform = Matrix.Identity; boneIdx = this.indexWeaponFireDummy[i]; boneTransform = modelWeapon[i].BoneTransforms[boneIdx]; if (reloadParticle != ParticleType.Count) { GameParticle.PlayParticle(reloadParticle, boneTransform, Matrix.CreateRotationX(MathHelper.ToRadians(-90.0f))); } } } switch (this.WeaponType) { case WeaponType.PlayerMachineGun: { if (GameSound.IsPlaying(soundFire)) { GameSound.Stop(soundFire); } } break; } // Play a reload sound if (reloadSound != SoundTrack.Count) { if (RobotGameGame.CurrentGameLevel.Info.GamePlayType == GamePlayTypeId.Versus) { soundReload = GameSound.Play3D(reloadSound, RobotGameGame.SinglePlayer.Emitter); } else { soundReload = GameSound.Play3D(reloadSound, this.OwnerUnit.Emitter); } } return(true); }
/// <summary> /// reloads weapon. /// plays reloading particle depending on unit type. /// </summary> /// <param name="type">unit type</param> /// <returns></returns> public bool Reload(UnitTypeId type) { this.state = WeaponState.Reloading; ParticleType reloadParticle = ParticleType.Count; SoundTrack reloadSound = SoundTrack.Count; switch (this.WeaponType) { case WeaponType.PlayerMachineGun: { reloadParticle = ParticleType.PlayerMachineGunReload; switch (type) { case UnitTypeId.Grund: case UnitTypeId.Kiev: reloadSound = SoundTrack.PlayerMachineGunGrundReload; break; case UnitTypeId.Mark: case UnitTypeId.Yager: reloadSound = SoundTrack.PlayerMachineGunMarkReload; break; } } break; case WeaponType.PlayerShotgun: { // Shotgun reload is no particle reloadSound = SoundTrack.PlayerShotgunReload; } break; case WeaponType.PlayerHandgun: { reloadParticle = ParticleType.PlayerHandgunReload; reloadSound = SoundTrack.PlayerHandgunReload; } break; } // Play a reloading particle if (reloadParticle != ParticleType.Count) { for (int i = 0; i < SpecData.ModelCount; i++) { int boneIdx = -1; Matrix boneTransform = Matrix.Identity; boneIdx = this.indexWeaponFireDummy[i]; boneTransform = modelWeapon[i].BoneTransforms[boneIdx]; if (reloadParticle != ParticleType.Count) { GameParticle.PlayParticle(reloadParticle, boneTransform, Matrix.CreateRotationX(MathHelper.ToRadians(-90.0f))); } } } switch (this.WeaponType) { case WeaponType.PlayerMachineGun: { if (GameSound.IsPlaying(soundFire)) GameSound.Stop(soundFire); } break; } // Play a reload sound if (reloadSound != SoundTrack.Count) { if (RobotGameGame.CurrentGameLevel.Info.GamePlayType == GamePlayTypeId.Versus) { soundReload = GameSound.Play3D(reloadSound, RobotGameGame.SinglePlayer.Emitter); } else { soundReload = GameSound.Play3D(reloadSound, this.OwnerUnit.Emitter); } } return true; }