예제 #1
0
        public API(string ip, FadeProxyClient proxy, Mode mode = Mode.BOT)
        {
            _ip = ip;

            this.mode = mode;

            // Depedency injection
            Account        = new Account(this);
            _proxy         = proxy;
            _remoteClient  = new RemoteClient(this);
            _vanillaClient = new VanillaClient(this, proxy, _remoteClient);

            Account.LoginSucceed += (s, e) => Connect();

            _vanillaClient.AuthFailed   += (s, e) => AuthFailed?.Invoke(s, e);
            _vanillaClient.Disconnected += (s, e) => Disconnected?.Invoke(s, e);
            _vanillaClient.HeroInited   += (s, e) =>
            {
                HeroInited?.Invoke(s, e);
                if (LoginTime == DateTime.MinValue)
                {
                    LoginTime = DateTime.Now;
                }
            };
            _vanillaClient.Attacked   += (s, e) => Attacked?.Invoke(s, e);
            _vanillaClient.ShipMoving += (s, e) => ShipMoving?.Invoke(s, e);
            _vanillaClient.Destroyed  += (s, e) => Destroyed?.Invoke(s, e);
        }