2017-04-29 14:11:25 +02:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Text;
|
|
|
|
using Syroot.IO;
|
|
|
|
using Syroot.Worms.Core;
|
|
|
|
|
|
|
|
namespace Syroot.Worms.Gen2.Armageddon.ProjectX
|
|
|
|
{
|
|
|
|
public class AirstrikeStyle : StyleBase
|
|
|
|
{
|
|
|
|
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public int PlaneSprite;
|
|
|
|
|
|
|
|
public int BombsCount;
|
|
|
|
|
|
|
|
public int DropDistance;
|
|
|
|
|
|
|
|
public int HorizontalSpeed;
|
|
|
|
|
|
|
|
public int Sound;
|
|
|
|
|
|
|
|
public WeaponAirstrikeAction Action;
|
|
|
|
|
|
|
|
public StyleBase Style;
|
|
|
|
|
|
|
|
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Loads the data from the given <see cref="Stream"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
|
|
|
public override void Load(Stream stream)
|
|
|
|
{
|
|
|
|
using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
|
|
|
|
{
|
|
|
|
PlaneSprite = reader.ReadInt32();
|
|
|
|
BombsCount = reader.ReadInt32();
|
|
|
|
DropDistance = reader.ReadInt32();
|
|
|
|
HorizontalSpeed = reader.ReadInt32();
|
|
|
|
Sound = reader.ReadInt32();
|
|
|
|
|
2017-05-01 14:39:14 +02:00
|
|
|
Action = reader.ReadEnum<WeaponAirstrikeAction>(false);
|
2017-04-29 14:11:25 +02:00
|
|
|
switch (Action)
|
|
|
|
{
|
|
|
|
case WeaponAirstrikeAction.Launcher:
|
|
|
|
Style = reader.Load<LauncherStyle>();
|
|
|
|
break;
|
|
|
|
case WeaponAirstrikeAction.Mines:
|
|
|
|
Style = reader.Load<MineStyle>();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Saves the data into the given <paramref name="stream"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
|
|
|
public override void Save(Stream stream)
|
|
|
|
{
|
|
|
|
using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII, true))
|
|
|
|
{
|
|
|
|
writer.Write(PlaneSprite);
|
|
|
|
writer.Write(BombsCount);
|
|
|
|
writer.Write(DropDistance);
|
|
|
|
writer.Write(HorizontalSpeed);
|
|
|
|
writer.Write(Sound);
|
|
|
|
|
|
|
|
writer.Write(Action, true);
|
|
|
|
if (Action != WeaponAirstrikeAction.Worms)
|
|
|
|
{
|
|
|
|
writer.Save(Style);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum WeaponAirstrikeAction : int
|
|
|
|
{
|
|
|
|
Mines,
|
|
|
|
Worms,
|
|
|
|
Launcher
|
|
|
|
}
|
|
|
|
}
|