Example #1
0
        /// <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());
            }
        }
Example #2
0
        /// <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]);
        }
Example #3
0
        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;
        }
Example #4
0
        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;
        }
Example #5
0
        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;
        }
Example #6
0
        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;
        }
Example #7
0
 internal Shot(Universe universe, Galaxy galaxy, ref BinaryMemoryReader reader) : base(universe, galaxy, ref reader)
 {
     Ammunition = (FlattiverseResourceKind)reader.ReadByte();
 }
Example #8
0
 internal FlattiverseResource(FlattiverseResourceKind kind)
 {
     Kind = kind;
 }
 internal CommodityUnit(Universe universe, Galaxy galaxy, ref BinaryMemoryReader reader)
     : base(universe, galaxy, ref reader)
 {
     Resource = (FlattiverseResourceKind)reader.ReadByte();
 }