示例#1
0
        public AgarFoodManager(PluginLoadData pluginLoadData) : base(pluginLoadData)
        {
            Random r = new Random();

            for (ushort i = 0; i < 20; i++)
            {
                FoodItem foodItem = new FoodItem(
                    i,
                    (float)r.NextDouble() * MAP_WIDTH - MAP_WIDTH / 2,
                    (float)r.NextDouble() * MAP_WIDTH - MAP_WIDTH / 2,
                    (byte)r.Next(0, 200),
                    (byte)r.Next(0, 200),
                    (byte)r.Next(0, 200)
                    );

                food.Add(foodItem);
            }

            ClientManager.ClientConnected += ClientConnected;
        }
示例#2
0
        public void Eat(FoodItem foodItem)
        {
            foodItem.X = (float)this.random.NextDouble() * AgarPlayerManager.MAP_WIDTH - AgarPlayerManager.MAP_WIDTH / 2;
            foodItem.Y = (float)this.random.NextDouble() * AgarPlayerManager.MAP_WIDTH - AgarPlayerManager.MAP_WIDTH / 2;

            using (DarkRiftWriter foodWriter = DarkRiftWriter.Create())
            {
                foodWriter.Write(foodItem.ID);
                foodWriter.Write(foodItem.X);
                foodWriter.Write(foodItem.Y);

                using (Message playerMessage = Message.Create(Tags.MoveFoodTag, foodWriter))
                {
                    foreach (IClient client in ClientManager.GetAllClients())
                    {
                        client.SendMessage(playerMessage, SendMode.Reliable);
                    }
                }
            }
        }
示例#3
0
        public void Eat(FoodItem food)
        {
            Random r = new Random();

            food.X = (float)r.NextDouble() * MAP_WIDTH - MAP_WIDTH / 2.0f;
            food.Y = (float)r.NextDouble() * MAP_WIDTH - MAP_WIDTH / 2.0f;

            using (DarkRiftWriter foodWriter = DarkRiftWriter.Create())
            {
                foodWriter.Write(food.ID);
                foodWriter.Write(food.X);
                foodWriter.Write(food.Y);

                using (Message foodMessage = Message.Create(Tags.MoveFoodTag, foodWriter))
                {
                    foreach (IClient c in ClientManager.GetAllClients())
                    {
                        c.SendMessage(foodMessage, SendMode.Reliable);
                    }
                }
            }
        }