/// <summary> /// Shoots into the backward direction. /// </summary> /// <param name="kind">The kind of shot.</param> /// <param name="time">The amount of ticks when the produced shot shall explode.</param> /// <returns>The name of the shot.</returns> public async Task <string> ShootAft(FlattiverseResourceKind kind, int time) { using (Session session = server.connection.NewSession()) { Packet packet = session.Request; packet.Command = 0xB9; packet.SubAddress = ID; ManagedBinaryMemoryWriter writer = packet.Write(); writer.Write((byte)kind); writer.Write((ushort)time); server.connection.Send(packet); server.connection.Flush(); Packet responsePacket = await session.Wait().ConfigureAwait(false); BinaryMemoryReader reader = responsePacket.Read(); if (reader.Size < 11) { throw new InvalidOperationException("Couldn't create Shot."); } return(reader.ReadString()); } }
/// <summary> /// Returns the requested flattiverse resource object. /// </summary> /// <param name="kind">The kind of the resource object.</param> /// <returns>The resource object.</returns> public FlattiverseResource GetResource(FlattiverseResourceKind kind) { if (kind < 0 || kind >= FlattiverseResourceKind.None) { return(null); } return(resources[(int)kind]); }
public mMeteoroid(Unit unit) : base(unit) { if (!(unit is Meteoroid)) { throw new Exception("mMeteoroid can be created only based on Buoy"); } Meteoroid meteoroid = (Meteoroid)unit; Gravity = meteoroid.Gravity; Radiation = meteoroid.Radiation; ResourceKind = meteoroid.Resource; }
public mPlanet(Unit unit) : base(unit) { if (!(unit is Planet)) { throw new Exception("mPlanet can be created only based on Planet"); } Planet planet = (Planet)unit; Gravity = planet.Gravity; Radiation = planet.Radiation; ResourceKind = planet.Resource; }
public mMoon(Unit unit) : base(unit) { if (!(unit is Moon)) { throw new Exception("mMoon can be created only based on Moon"); } Moon moon = (Moon)unit; Gravity = moon.Gravity; Radiation = moon.Radiation; ResourceKind = moon.Resource; }
public mSun(Unit unit) : base(unit) { if (!(unit is Sun)) { throw new Exception("mSun can be created only based on Sun"); } Sun sun = (Sun)unit; Gravity = sun.Gravity; Radiation = sun.Radiation; PowerOutput = sun.PowerOutput; ResourceKind = sun.Resource; }
internal Shot(Universe universe, Galaxy galaxy, ref BinaryMemoryReader reader) : base(universe, galaxy, ref reader) { Ammunition = (FlattiverseResourceKind)reader.ReadByte(); }
internal FlattiverseResource(FlattiverseResourceKind kind) { Kind = kind; }
internal CommodityUnit(Universe universe, Galaxy galaxy, ref BinaryMemoryReader reader) : base(universe, galaxy, ref reader) { Resource = (FlattiverseResourceKind)reader.ReadByte(); }