示例#1
0
        public static void AsteroidMining(Client client, Player player)
        {
            List <Asteroid> asteroids = player.SolarSystem.Asteroids;
            Asteroid        hit       = null;
            Vector3         pos       = player.Pos;

            asteroids.Sort(new AsteroidComparer(pos));
            int count = 0;

            foreach (Asteroid a in asteroids)
            {
                Ray            ray    = new Ray(pos, Vector3.Transform(Vector3.Forward, player.Rotation));
                BoundingSphere sphere = new BoundingSphere(a.Pos, a.Size * Asteroid.SERVER_SIZE_MULTIPLIER);
                double?        result = ray.Intersects(sphere);
                if (result != null)
                {
                    hit = a;
                    break;
                }
                count++;
            }
            Console.WriteLine("Count:" + count);
            if (hit != null)
            {
                hit.Remaining -= player.Ship.MiningLaserPower;
                player.Ship.AddCargo(new Item(ItemType.IronOre, player.Ship.MiningLaserPower));
                Console.WriteLine("hit!:" + hit.Remaining);
                //    GalaxyServer.AddToSendQueue(client, hit);
                MiningMessage miningState = new MiningMessage();
                miningState.Add          = true;
                miningState.Item         = new Item(ItemType.IronOre, player.Ship.MiningLaserPower);
                miningState.AsteroidHash = hit.Hash;
                miningState.Remaining    = hit.Remaining;
                GalaxyServer.AddToSendQueue(client, miningState);
                if (hit.Remaining <= 0)
                {
                    asteroids.Remove(hit);
                }
                DataLayer.AddSystem(player.SolarSystem);
            }
        }
示例#2
0
 public void HandleMessage(MiningMessage msg, object extra = null)
 {
     throw new NotImplementedException();
 }