예제 #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());
            }
        }
예제 #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]);
        }
예제 #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;
        }
예제 #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;
        }
예제 #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;
        }
예제 #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;
        }
예제 #7
0
 internal Shot(Universe universe, Galaxy galaxy, ref BinaryMemoryReader reader) : base(universe, galaxy, ref reader)
 {
     Ammunition = (FlattiverseResourceKind)reader.ReadByte();
 }
예제 #8
0
 internal FlattiverseResource(FlattiverseResourceKind kind)
 {
     Kind = kind;
 }
예제 #9
0
 internal CommodityUnit(Universe universe, Galaxy galaxy, ref BinaryMemoryReader reader)
     : base(universe, galaxy, ref reader)
 {
     Resource = (FlattiverseResourceKind)reader.ReadByte();
 }