Пример #1
0
        /// <summary>
        /// Main constructor
        /// </summary>
        /// <param name="p">the client's process object</param>
        public Client(Process p)
        {
            Process         = p;
            Process.Exited += new EventHandler(process_Exited);
            Process.EnableRaisingEvents = true;

            // Wait until we can really access the process
            Process.WaitForInputIdle();

            while (Process.MainWindowHandle == IntPtr.Zero)
            {
                Process.Refresh();
                System.Threading.Thread.Sleep(5);
            }

            // Save a copy of the handle so the process doesn't have to be opened
            // every read/write operation
            Handle = Util.WinAPI.OpenProcess(Util.WinAPI.PROCESS_ALL_ACCESS, 0, (uint)Process.Id);

            PathFinder = new Pokemon.Util.AStarPathFinder(this);
            Inventory  = new Objects.Inventory(this);
            BattleList = new Objects.BattleList(this);
            Map        = new Objects.Map(this);
            Memory     = new MemoryHelper(this);
            Window     = new Window(this);
            IO         = new IOHelper(this);
            Login      = new LoginHelper(this);
            Dll        = new DllHelper(this);
            Input      = new InputHelper(this);
            Player     = new PlayerHelper(this);

            // Save the start time (it isn't changing)
            startTime = Memory.ReadInt32(Addresses.Client.StartTime);
        }
Пример #2
0
        public void Start()
        {
            UpTick   = 0;
            DownTick = 1800000;
            LastTick = -1;

            Objects.Map map       = Managers.MapManager.Instance.Get(Map);
            byte        flagCount = map.Flags;

            byte[] spawnFlags = map.SpawnFlags;
            this.Flags = new sbyte[flagCount];
            for (byte i = 0; i < 0; i++)
            {
                Flags[i] = -1;
            }

            Flags[spawnFlags[0]] = 0;
            Flags[spawnFlags[1]] = 1;


            foreach (Player p in Players.Values)
            {
                p.Reset();
                p.RoundStart();
            }

            switch (Mode)
            {
            case Enums.Mode.Explosive: {
                CurrentGameMode = new Modes.Explosive();
                break;
            }

            case Enums.Mode.Free_For_All: {
                CurrentGameMode = new Modes.FreeForAll();
                break;
            }

            case Enums.Mode.Team_Death_Match: {
                CurrentGameMode = new Modes.TeamDeathMatch();
                break;
            }
            }

            CurrentGameMode.Initilize(this);
            Running = false;
        }
Пример #3
0
        /*
         *  public void Send(byte[] buffer)
         * {
         *  foreach(Entities.Player Player in Players.Values)
         *  {
         *      if (Player != null)
         *          Player.Send(buffer);
         *  }
         *
         *  foreach(Entities.User Spectator in Spectators.Values)
         *  {
         *      if (Spectator != null)
         *          Spectator.Send(buffer);
         *  }
         * }
         */
        public void Start()
        {
            UpTick   = 0;
            DownTick = 1800000;
            LastTick = -1;

            Objects.Map map       = Managers.MapManager.Instance.Get(Map);
            byte        flagCount = map.Flags;

            byte[] spawnFlags = map.SpawnFlags;
            this.SpawnFlags = spawnFlags;
            this.Flags      = new sbyte[flagCount];
            for (byte i = 0; i < flagCount; i++)
            {
                Flags[i] = -1;
            }

            Flags[spawnFlags[0]] = 0;
            Flags[spawnFlags[1]] = 1;

            Vehicles = Managers.VehicleManager.Instance.BuildArray(map.Id, map.VehicleCount);

            for (byte i = 0; i < Vehicles.Count; i++)
            {
                List <Objects.VehicleSeat> SheetSeats = Managers.VehicleManager.Instance.GetSeatsFor(Vehicles[i].Code);

                foreach (Objects.VehicleSeat SheetSeat in SheetSeats)
                {
                    Objects.VehicleSeat NewSeat = new Objects.VehicleSeat(SheetSeat.ID, SheetSeat.SeatCode, SheetSeat.VehicleCode,
                                                                          SheetSeat.Weapon1Ammo, SheetSeat.Weapon2Ammo, SheetSeat.Weapon1Mag, SheetSeat.Weapon2Mag, SheetSeat.Weapons);

                    Vehicles[i].AddSeat(NewSeat);
                }
            }


            foreach (Player p in Players.Values)
            {
                p.Reset();
                p.RoundStart();
            }

            switch (Mode)
            {
            case Enums.Mode.Explosive: {
                CurrentGameMode = new Modes.Explosive();
                break;
            }

            case Enums.Mode.Free_For_All: {
                CurrentGameMode = new Modes.FreeForAll();
                break;
            }

            case Enums.Mode.Team_Death_Match: {
                CurrentGameMode = new Modes.TeamDeathMatch();
                break;
            }

            case Enums.Mode.Conquest:
            {
                CurrentGameMode = new Modes.Conquest();
                break;
            }
            }
            this.ItemsOnGround.Clear();
            CurrentGameMode.Initilize(this);
            Running = false;
        }
Пример #4
0
        /// <summary>
        /// Main constructor
        /// </summary>
        /// <param name="p">the client's process object</param>
        public Client(Process p)
        {
            Process = p;
            Process.Exited += new EventHandler(process_Exited);
            Process.EnableRaisingEvents = true;

            // Wait until we can really access the process
            Process.WaitForInputIdle();

            while (Process.MainWindowHandle == IntPtr.Zero)
            {
                Process.Refresh();
                System.Threading.Thread.Sleep(5);
            }

            // Save a copy of the handle so the process doesn't have to be opened
            // every read/write operation
            Handle = Util.WinAPI.OpenProcess(Util.WinAPI.PROCESS_ALL_ACCESS, 0, (uint)Process.Id);

            PathFinder = new Pokemon.Util.AStarPathFinder(this);
            Inventory = new Objects.Inventory(this);
            BattleList = new Objects.BattleList(this);
            Map = new Objects.Map(this);
            Memory = new MemoryHelper(this);
            Window = new Window(this);
            IO = new IOHelper(this);
            Login = new LoginHelper(this);
            Dll = new DllHelper(this);
            Input = new InputHelper(this);
            Player = new PlayerHelper(this);

            // Save the start time (it isn't changing)
            startTime = Memory.ReadInt32(Addresses.Client.StartTime);
        }