void ExecAction(SingleAction actionInfo)
    {
        if (_mMCtrl && actionInfo.ActionType != MonsterAction.None)
        {
            switch (actionInfo.ActionType)
            {
            case MonsterAction.Forward:
                _mMCtrl.Forward(ActionCallBack, actionInfo.ExecTime, actionInfo.Speed);
                break;

            case MonsterAction.Back:
                _mMCtrl.Back(ActionCallBack, actionInfo.ExecTime, actionInfo.Speed);
                break;

            case MonsterAction.Left:
                _mMCtrl.Left(ActionCallBack, actionInfo.ExecTime, actionInfo.Speed);
                break;

            case MonsterAction.Right:
                _mMCtrl.Right(ActionCallBack, actionInfo.ExecTime, actionInfo.Speed);
                break;

            case MonsterAction.Jump:
                _mMCtrl.Jump(ActionCallBack);
                break;

            case MonsterAction.MoveDirtion:
                _mMCtrl.MoveDirtion(actionInfo.Dirtion, ActionCallBack, actionInfo.ExecTime, actionInfo.Speed);
                break;
            }
        }
    }
Example #2
0
 public SystemTimeValidator(INtpClient ntpClient, IModals modals, ILogger logger)
 {
     _ntpClient      = ntpClient;
     _modals         = modals;
     _logger         = logger;
     _validateAction = new SingleAction(ValidateTime);
 }
Example #3
0
        public DnsClient(IDnsClients dnsClients, INetworkInterfaces networkInterfaces)
        {
            _dnsClients = dnsClients;

            _refreshDnsClient = new SingleAction(RefreshDnsClient);
            networkInterfaces.NetworkAddressChanged += NetworkAddressChanged;
        }
 public AlternativeHostHandler(
     DohClients dohClients,
     MainHostname mainHostname,
     IAppSettings appSettings,
     string apiHost)
 {
     _mainHostname      = mainHostname;
     _dohClients        = dohClients;
     _appSettings       = appSettings;
     _apiHost           = apiHost;
     _activeBackendHost = apiHost;
     _fetchProxies      = new SingleAction(FetchProxies);
 }
Example #5
0
 public StreamingServicesUpdater(
     StreamingServicesStorage streamingServicesStorage,
     IApiClient apiClient,
     IScheduler scheduler,
     Common.Configuration.Config config)
 {
     _streamingServicesStorage = streamingServicesStorage;
     _apiClient      = apiClient;
     _timer          = scheduler.Timer();
     _timer.Interval = config.StreamingServicesUpdateInterval.RandomizedWithDeviation(0.2);
     _timer.Tick    += Timer_OnTick;
     _updateAction   = new SingleAction(UpdateStreamingServices);
 }
Example #6
0
 public ClientConfig(
     IAppSettings appSettings,
     IScheduler scheduler,
     IApiClient apiClient,
     Common.Configuration.Config config)
 {
     _appSettings    = appSettings;
     _apiClient      = apiClient;
     _timer          = scheduler.Timer();
     _timer.Interval = config.ClientConfigUpdateInterval.RandomizedWithDeviation(0.2);
     _timer.Tick    += Timer_OnTick;
     _updateAction   = new SingleAction(UpdateAction);
 }
Example #7
0
        public UserLocationService(
            IApiClient api,
            IUserStorage userStorage,
            INetworkInterfaces networkInterfaces)
        {
            _api         = api;
            _userStorage = userStorage;

            _updateAction        = new SingleAction(UpdateAction);
            _delayedUpdateAction = new SingleAction(DelayedUpdateAction);

            networkInterfaces.NetworkAddressChanged += NetworkInterfaces_NetworkAddressChanged;
        }
    /// <summary>
    /// Implements transport callback
    /// </summary>
    /// <param name="requestArgs"></param>
    /// <param name="callback"></param>
    public void SendAsynchronous(TransferData.ContentMode contentMode, HttpRequestArgs requestArgs, SingleAction<HttpResponseArgs> callback)
    {
        ShowDebugInfo(System.Reflection.MethodBase.GetCurrentMethod(), contentMode, requestArgs);

        TransferData td = new TransferData(false)
                              {
                                  m_contentMode = contentMode,
                                  m_synchronous = false,
                                  m_requestArgs = requestArgs,
                                  m_callback = callback
                              };

        AddToTransferData(td);
    }
Example #9
0
 public AnnouncementService(
     IAppSettings appSettings,
     IScheduler scheduler,
     IApiClient apiClient,
     IAnnouncementCache announcementCache,
     TimeSpan updateInterval)
 {
     _appSettings       = appSettings;
     _announcementCache = announcementCache;
     _apiClient         = apiClient;
     _timer             = scheduler.Timer();
     _timer.Interval    = updateInterval.RandomizedWithDeviation(0.2);
     _timer.Tick       += Timer_OnTick;
     _updateAction      = new SingleAction(Fetch);
 }
Example #10
0
 public AlternativeHostHandler(
     ILogger logger,
     DohClients dohClients,
     MainHostname mainHostname,
     IAppSettings appSettings,
     GuestHoleState guestHoleState,
     string apiHost)
 {
     _logger            = logger;
     _guestHoleState    = guestHoleState;
     _mainHostname      = mainHostname;
     _dohClients        = dohClients;
     _appSettings       = appSettings;
     _apiHost           = apiHost;
     _activeBackendHost = apiHost;
     _fetchProxies      = new SingleAction(FetchProxies);
 }
Example #11
0
        public ServerUpdater(
            IScheduler scheduler,
            Config appConfig,
            ServerManager serverManager,
            ApiServers apiServers,
            ICollectionStorage <LogicalServerContract> serverCache)
        {
            _serverManager = serverManager;
            _apiServers    = apiServers;
            _serverCache   = serverCache;

            _timer          = scheduler.Timer();
            _timer.Interval = appConfig.ServerUpdateInterval.RandomizedWithDeviation(0.2);
            _timer.Tick    += Timer_OnTick;

            _updateAction = new SingleAction(UpdateServers);
        }
Example #12
0
        public ServersUpdater(
            ILogger logger,
            IScheduler scheduler,
            Config appConfig,
            ServerManager serverManager,
            CachedServersProvider serversProvider)
        {
            _logger          = logger;
            _serverManager   = serverManager;
            _serversProvider = serversProvider;

            _timer          = scheduler.Timer();
            _timer.Interval = appConfig.ServerUpdateInterval.RandomizedWithDeviation(0.2);
            _timer.Tick    += Timer_OnTick;

            _updateAction = new SingleAction(UpdateServers);
        }
Example #13
0
        public UserLocationService(
            IApiClient api,
            IUserStorage userStorage,
            INetworkInterfaces networkInterfaces,
            UserAuth userAuth,
            GuestHoleState guestHoleState)
        {
            _userAuth       = userAuth;
            _guestHoleState = guestHoleState;
            _api            = api;
            _userStorage    = userStorage;

            _updateAction        = new SingleAction(UpdateAction);
            _delayedUpdateAction = new SingleAction(DelayedUpdateAction);

            networkInterfaces.NetworkAddressChanged += NetworkInterfaces_NetworkAddressChanged;
        }
 void StartMonsterStruggle()
 {
     if (null == _struggleActions)
     {
         Debug.Log("AnalogMonsterStruggle: _struggleActions is null!");
         return;
     }
     if (_struggleActions.Count > 0)
     {
         _curActionInfo = _struggleActions.Dequeue();
         ExecAction(_curActionInfo);
         IsTameSucceed = false;
     }
     else
     {
         IsTameSucceed = true;
     }
 }
Example #15
0
        public OpenVpnConnection(
            ILogger logger,
            OpenVpnProcess process,
            ManagementClient managementClient)
        {
            _logger           = logger;
            _process          = process;
            _managementClient = managementClient;

            _managementClient.VpnStateChanged       += ManagementClient_StateChanged;
            _managementClient.TransportStatsChanged += ManagementClient_TransportStatsChanged;

            _managementPorts             = new OpenVpnManagementPorts();
            _randomStrings               = new RandomStrings();
            _connectAction               = new SingleAction(ConnectAction);
            _connectAction.Completed    += ConnectAction_Completed;
            _disconnectAction            = new SingleAction(DisconnectAction);
            _disconnectAction.Completed += DisconnectAction_Completed;
        }
    /// <summary> 生成模拟怪物挣扎行为时间轴 </summary>
    void GenerateStruggleActions()
    {
        if (null == _actionSeedDic)
        {
            return;
        }

        //怪物的Bounds
        Bounds bounds = GetMonsterBounds();
        //怪物体积
        float monsterBulk = bounds.size.x * bounds.size.y * bounds.size.z;

        //怪物体积Clamp
        monsterBulk = Mathf.Clamp(monsterBulk, TameMonsterConfig.instance.MonsterBulkRange.Min, TameMonsterConfig.instance.MonsterBulkRange.Max);
        //怪物体积占比
        float bulkProportion = (monsterBulk - TameMonsterConfig.instance.MonsterBulkRange.Min) / (TameMonsterConfig.instance.MonsterBulkRange.Max - TameMonsterConfig.instance.MonsterBulkRange.Min);
        //体积占比转换为行为数占比
        float actionSize = bulkProportion * TameMonsterConfig.instance.MonsterStruggleActionSizeRange.Max;

        //行为数Clamp
        StruggleActionTotal = (int)Mathf.Clamp(actionSize, TameMonsterConfig.instance.MonsterStruggleActionSizeRange.Min, TameMonsterConfig.instance.MonsterStruggleActionSizeRange.Max);

        _struggleActions = new Queue <SingleAction>();
        MonsterAction actionType;
        Vector3       dirtion = Vector3.one;

        for (int i = 0; i < StruggleActionTotal; i++)
        {
            actionType = GetRandomAction();
            if (_actionSeedDic.ContainsKey(actionType))
            {
                if (actionType == MonsterAction.MoveDirtion)
                {
                    dirtion = GetRandomDirtion();
                }
                SingleAction tempInfo = new SingleAction(actionType, _actionSeedDic[actionType].RandomTime, _actionSeedDic[actionType].RandomSpeed, dirtion);
                //随机挣扎行为时间轴加到队列
                _struggleActions.Enqueue(tempInfo);
            }
        }
    }
Example #17
0
 public WireGuardConnection(
     ILogger logger,
     ProtonVPN.Common.Configuration.Config config,
     IService wireGuardService,
     TrafficManager trafficManager,
     StatusManager statusManager,
     IX25519KeyGenerator x25519KeyGenerator)
 {
     _logger                      = logger;
     _config                      = config;
     _wireGuardService            = wireGuardService;
     _trafficManager              = trafficManager;
     _statusManager               = statusManager;
     _x25519KeyGenerator          = x25519KeyGenerator;
     _trafficManager.TrafficSent += OnTrafficSent;
     _statusManager.StateChanged += OnStateChanged;
     _connectAction               = new SingleAction(ConnectAction);
     _connectAction.Completed    += OnConnectActionCompleted;
     _disconnectAction            = new SingleAction(DisconnectAction);
     _disconnectAction.Completed += OnDisconnectActionCompleted;
 }
Example #18
0
        public ServerUpdater(
            IScheduler scheduler,
            Common.Configuration.Config appConfig,
            ServerManager serverManager,
            IApiServers apiServers,
            ICollectionStorage <LogicalServerContract> serverCache,
            ServerLoadUpdater serverLoadUpdater,
            IAppSettings appSettings)
        {
            _serverManager = serverManager;
            _apiServers    = apiServers;
            _serverCache   = serverCache;
            _appSettings   = appSettings;

            _timer          = scheduler.Timer();
            _timer.Interval = appConfig.ServerUpdateInterval.RandomizedWithDeviation(0.2);
            _timer.Tick    += Timer_OnTick;

            _updateAction = new SingleAction(UpdateServers);
            serverLoadUpdater.ServerLoadsUpdated += OnServerLoadsUpdated;
        }
Example #19
0
    public void Awake()
    {
        agentScript = this.gameObject.GetComponent <AgentActions>();

        //******************************************************************************************************************//
        //******************************************************************************************************************//

        // Declaring a decision and assigning it to a decision node
        // This process is repeated for the following decisions as well
        Decision     health_high          = new Decision(Decisions.IsHealthHigherThan25Percent);
        DecisionNode health_high_decision = new DecisionNode(health_high);

        Decision is_agent_in_sight = new Decision(Decisions.IsOpponentInSight);

        // Two nodes are created to perform 'Agent in Sight' decisions on both
        // situations: when the health is low and when it isn't
        DecisionNode in_sight_with_less_health_decision = new DecisionNode(is_agent_in_sight);

        DecisionNode in_sight_with_more_health_decision = new DecisionNode(is_agent_in_sight);

        // Child nodes are being added
        // This is how the tree expands
        health_high_decision.AddFalseChild(in_sight_with_less_health_decision);
        health_high_decision.AddTrueChild(in_sight_with_more_health_decision);

        //******************************************************************************************************************//
        //******************************************************************************************************************//

        Decision     is_health_kit_in_sight          = new Decision(Decisions.IsHealthKitInSight);
        DecisionNode is_health_kit_in_sight_decision = new DecisionNode(is_health_kit_in_sight);

        // An action is created and assigned to an action node
        // This process is repeated for the following actions as well
        SingleAction flee_from_opponent        = new SingleAction(Actions.FleeFromOpponent, 0);
        ActionNode   flee_from_opponent_action = new ActionNode(flee_from_opponent);

        // If our health is less and agent is in sight, flee.
        // Else, look for health kit
        in_sight_with_less_health_decision.AddFalseChild(is_health_kit_in_sight_decision);
        in_sight_with_less_health_decision.AddTrueChild(flee_from_opponent_action);

        //******************************************************************************************************************//
        //******************************************************************************************************************//

        SingleAction random_wander        = new SingleAction(Actions.RandomWander, 0);
        ActionNode   random_wander_action = new ActionNode(random_wander);

        SingleAction move_towards_health_kit        = new SingleAction(Actions.MoveTowardsHealthKit, 0);
        ActionNode   move_towards_health_kit_action = new ActionNode(move_towards_health_kit);

        // If health kit in in sight, move towards it. Else, execute random wander
        is_health_kit_in_sight_decision.AddFalseChild(random_wander_action);
        is_health_kit_in_sight_decision.AddTrueChild(move_towards_health_kit_action);

        //******************************************************************************************************************//
        //******************************************************************************************************************//

        Decision     is_power_up_picked          = new Decision(Decisions.IsPowerUpPicked);
        DecisionNode is_power_up_picked_decision = new DecisionNode(is_power_up_picked);

        Decision     is_opponent_fleeing          = new Decision(Decisions.IsOpponentFleeing);
        DecisionNode is_opponent_fleeing_decision = new DecisionNode(is_opponent_fleeing);

        // If we have more health and enemy is in sight, check if it's fleeing. If not,
        // then, check if we already picked a power up
        in_sight_with_more_health_decision.AddFalseChild(is_power_up_picked_decision);
        in_sight_with_more_health_decision.AddTrueChild(is_opponent_fleeing_decision);

        //******************************************************************************************************************//
        //******************************************************************************************************************//

        Decision     is_power_up_in_sight          = new Decision(Decisions.IsPowerUpInSight);
        DecisionNode is_power_up_in_sight_decision = new DecisionNode(is_power_up_in_sight);

        // If we haven't picked it up, then look for one. Else, execute random wander
        is_power_up_picked_decision.AddFalseChild(is_power_up_in_sight_decision);
        is_power_up_picked_decision.AddTrueChild(random_wander_action);

        //******************************************************************************************************************//
        //******************************************************************************************************************//

        SingleAction move_towards_power_up        = new SingleAction(Actions.MoveTowardsPowerUp, 0);
        ActionNode   move_towards_power_up_action = new ActionNode(move_towards_power_up);

        // If a pick up is in sight, then move towards it. Else, execute random wander
        is_power_up_in_sight_decision.AddFalseChild(random_wander_action);
        is_power_up_in_sight_decision.AddTrueChild(move_towards_power_up_action);

        //******************************************************************************************************************//
        //******************************************************************************************************************//

        Decision     is_attack_power_higher          = new Decision(Decisions.IsAttackPowerHigher);
        DecisionNode is_attack_power_higher_decision = new DecisionNode(is_attack_power_higher);

        // If the opponent is not fleeing, check if our attack power is higher. Else, execute random wander
        is_opponent_fleeing_decision.AddFalseChild(is_attack_power_higher_decision);
        is_opponent_fleeing_decision.AddTrueChild(random_wander_action);

        //******************************************************************************************************************//
        //******************************************************************************************************************//

        Decision     is_in_attack_distance          = new Decision(Decisions.IsInAttackDistance);
        DecisionNode is_in_attack_distance_decision = new DecisionNode(is_in_attack_distance);

        // If our attack power is equal or higher than the opponent, check if we're in attack range.
        // Else, flee from sight
        is_attack_power_higher_decision.AddFalseChild(flee_from_opponent_action);
        is_attack_power_higher_decision.AddTrueChild(is_in_attack_distance_decision);

        //******************************************************************************************************************//
        //******************************************************************************************************************//

        SingleAction move_towards_agent        = new SingleAction(Actions.MoveTowardsOpponent, 0);
        ActionNode   move_towards_agent_action = new ActionNode(move_towards_agent);

        SingleAction attack_opponent        = new SingleAction(Actions.AttackOpponent, 0.15f);
        ActionNode   attack_opponent_action = new ActionNode(attack_opponent);

        // If we're not in attack distance, then move towards opponent. Else, attack the
        // opponent
        is_in_attack_distance_decision.AddFalseChild(move_towards_agent_action);
        is_in_attack_distance_decision.AddTrueChild(attack_opponent_action);

        //******************************************************************************************************************//
        //******************************************************************************************************************//

        // Assigning the root node with the health check decision
        decision_tree = new DecisionTree(health_high_decision);

        // Assigning random wander as the default action
        action_executor = new ActionExecutor(random_wander);
    }
Example #20
0
 public StatusManager(ILogger logger, string logPath)
 {
     _logger            = logger;
     _ringLogger        = new RingLogger(logPath);
     _receiveLogsAction = new SingleAction(ReceiveLogsAction);
 }
Example #21
0
 public TrafficManager(string adapterName, ILogger logger)
 {
     _adapterName = adapterName;
     _logger      = logger;
     _updateBytesTransferredAction = new SingleAction(UpdateBytesTransferred);
 }
 // A function to add actions into the sequence
 public void AddAction(SingleAction s_act)
 {
     sequence.Add(s_act);
 }
 public override void SendTextAsync(HttpRequestArgs requestArgs, SingleAction<HttpResponseArgs> callback)
 {
     SendContentAsynchronous(TransferData.ContentMode.Text, requestArgs, callback);
 }
 /// <summary>
 /// Implements transport callback
 /// </summary>
 public new void SendAsync(HttpRequestArgs requestArgs, SingleAction<HttpResponseArgs> callback)
 {
     SendContentAsynchronous(TransferData.ContentMode.Binary, requestArgs, callback);
 }