void spawnResource()
    {
        GameObject obj = Instantiate(m_resource_prefab, Vector3Calc.randomDirection() * 8f, Quaternion.identity);

        obj.GetComponent <Resource>().Initalize(RandomCalc.Rand(new Range <float>(10f, 100f)));
        ObjectLogger.log(obj, "RESOURCE");
    }
示例#2
0
 public MonitorBot(
     ObjectLogger objectLogger,
     BotConversation conversation)
 {
     _objectLogger = objectLogger;
     _conversation = conversation;
 }
    private GameObject[] sense(string p_type)
    {
        GameObject[] all_of_type = ObjectLogger.getByType(p_type);

        List <GameObject> in_arc = new List <GameObject>();

        foreach (GameObject ob in all_of_type)
        {
            if (ob == null)
            {
                continue;
            }

            Vector3 diff = ob.transform.position - gameObject.transform.position;

            if (Vector2Calc.checkAngle(diff, m_forward, m_sense_angle) && diff.magnitude <= m_sense_proximity)
            {
                in_arc.Add(ob);
            }
        }

        // foreach(GameObject ob in in_arc){
        //  Debug.DrawLine(gameObject.transform.position, ob.transform.position, Color.cyan, 1f);
        // }

        return(in_arc.ToArray());
    }
示例#4
0
        internal Vice()
        {
            _employees = new Dictionary <string, Employee>();
            _lock      = new object();

            _logger = new ObjectLogger(this, null);
        }
        internal JobPropertiesHolder(string jobName)
        {
            _jobName = jobName;
            _routine = JobExtensions.IdleJobRoutine;
            _lock    = new object();

            _logger = new ObjectLogger(this, jobName);
        }
    void Start()
    {
        //Instantiate controller
        m_evolution = new DNABasedEvolutionManager <MindBodyDNDNA <ResourceFightDNCreature> >(
            new MindBodySpeciesDN <ResourceFightDNCreature>(0,
                                                            new TraitGenesSpecies(0, new HashSet <string> {
            "SPEED", "HEALTH", "DAMAGE", "ENERGY", "ATTACKSPEED"
        }, 1, new Range <float>(2f, 2f), 0, new Range <float>(0f, 0f)),
                                                            new DecisionNetSpecies <ResourceFightDNCreature>(0, ResourceFightDNCreature.getInputFactorys(), ResourceFightDNCreature.getOutputFactorys(), new Range <float>(0.8f, 1.2f))
                                                            ), 0.1f, 20, (float p_fitness) => { return(p_fitness * 0.95f); }, 1f
            );

        //Fill with 20 random
        for (int i = 0; i < 10; i++)
        {
            m_evolution.addRandom();
        }

        //Instantaite Interval and Listeners
        m_interval = new IntervalEventManager();

        for (int i = 0; i < 5; i++)
        {
            spawnResource();
        }

        for (int i = 0; i < 50; i++)
        {
            spawnCreature();
        }

        // spawnCreature();
        // spawnCreature();


        m_interval.addListener(5f, () => {
            for (int i = 0; i < 5; i++)
            {
                spawnCreature();
            }
        });

        m_interval.addListener(10f, () => {
            for (int i = 0; i < 1; i++)
            {
                spawnResource();
            }
        });

        m_interval.addListener(30f, () => {
            GameObject[] obs = ObjectLogger.getByType("CREATURE");

            foreach (GameObject ob in obs)
            {
                ob.GetComponent <ResourceFightDNCreature>().logFitness();
            }
        });
    }
示例#7
0
        internal DueTimeHolder(string jobName)
        {
            _jobName  = jobName;
            _schedule = NeverSchedule.Instance;
            _lock     = new object();
            this.UpdateScheduleDueTime();

            _logger = new ObjectLogger(this, _jobName);
        }
示例#8
0
        internal Employee(Vice vice, string name)
        {
            this.Name = name;

            _vice   = vice;
            _job    = new Job(this);
            _runner = new Runner(this.Name);

            _logger = new ObjectLogger(this, this.Name);
        }
示例#9
0
        public void ClearExpiredClaimsAync()
        {
            List <Claim> claims = _database.GetAllExpiredClaims();

            if (claims.Count == 0)
            {
                return;
            }
            _logger.LogError($"Clearing all these expired claims:\n{ObjectLogger.Dump(claims)}");
            _database.ClearAllExpiredClaims();
        }
示例#10
0
 public async Task CreateRefreshTokenAsync(TokenExtended token)
 {
     _logger.LogDebug($"Creating token for TokenExtended Object: {ObjectLogger.Dump(token)}");
     _logger.LogInformation($"Creating token for refresh token: {token.RefreshToken}");
     using (var connection = _context.CreateConnection())
     {
         var    parameters   = new { value = token.RefreshToken, created_at = token.CreatedAt, id_users = token.UserId };
         string processQuery = "INSERT INTO token (value,created_at,id_users) VALUES (@value,@created_at,@id_users)";
         await connection.ExecuteAsync(processQuery, parameters);
     }
 }
示例#11
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        IDamagable[] damageables = coll.gameObject.GetComponents <IDamagable>();

        foreach (IDamagable damagable in damageables)
        {
            damagable.damage(m_damage);
        }

        ObjectLogger.unlog(gameObject, "BULLET");
        Destroy(gameObject);
    }
示例#12
0
        internal Runner(string jobName)
        {
            this.JobName = jobName;

            this.JobPropertiesHolder = new JobPropertiesHolder(this.JobName);
            this.DueTimeHolder       = new DueTimeHolder(this.JobName);
            this.JobRunsHolder       = new JobRunsHolder();

            _lock = new object();

            _logger = new ObjectLogger(this, jobName);
        }
示例#13
0
 public BotController(
     ObjectLogger objectLogger,
     IAdapterIntegration botAdapter,
     IBotFrameworkHttpAdapter alexaAdapter,
     AlexaBot alexaBot,
     MonitorBot monitorBot)
 {
     _objectLogger = objectLogger;
     _botAdapter   = botAdapter;
     _alexaAdapter = alexaAdapter;
     _alexaBot     = alexaBot;
     _monitorBot   = monitorBot;
 }
示例#14
0
 public async Task InsertPeopleInEpisodeAsync(List <PeopleInEpisode> people, int episodeId)
 {
     _logger.LogInformation($"Inserting people into episode with id: {episodeId}");
     _logger.LogDebug($"Inserting people: {ObjectLogger.Dump(people)}");
     foreach (PeopleInEpisode person in people)
     {
         using (var connection = _context.CreateConnection())
         {
             var    parameters   = new { created_at = DateTime.Now, id_person = person.PersonId, id_episodes = episodeId };
             string processQuery = "INSERT INTO episode_person (created_at,id_person,id_episodes) VALUES (@created_at,@id_person,@id_episodes);";
             await connection.ExecuteAsync(processQuery, parameters);
         }
     }
 }
示例#15
0
 public void AddEpisodes(List <Episode> episodes)
 {
     using (var connection = _context.CreateConnection())
     {
         foreach (Episode item in episodes)
         {
             _logger.LogDebug($"Adding new episode: {ObjectLogger.Dump(item)}");
             _logger.LogInformation($"Adding new episode with EpisodeNumber: {item.EpisodeNumber}");
             var    parameters   = new { uuid = item.UUID, title = item.Title, episode_number = item.EpisodeNumber, subtitle = item.Subtitle, description = item.Description, media_file = item.MediaFile, spotify_file = item.SpotifyFile, duration = item.Duration, type = item.Type, image = item.Image, explicitItem = item.Explicit, published_at = item.PublishedAt, created_at = item.CreatedAt, updated_at = item.UpdatedAt, verified = item.Verified };
             string processQuery = "INSERT INTO episodes (uuid,title,episode_number,subtitle,description,media_file,spotify_file,duration,type,image,explicit,published_at,created_at,updated_at,verified) VALUES (@uuid,@title,@episode_number,@subtitle,@description,@media_file,@spotify_file,@duration,@type,@image,@explicitItem,@published_at,@created_at,@updated_at,@verified)";
             connection.Execute(processQuery, parameters);
         }
     }
 }
示例#16
0
        public static void LogInformation(string response, string objectChangeDetails, string methodName, string userID)
        {
            var _loggingItem = new ObjectLogger()
            {
                CreatedDate          = DateTime.Now,
                ResponseMessage      = response,
                ChangedObjectDetails = objectChangeDetails,
                IPAdress             = Network.GetLocalIPAddress(),
                MethodName           = methodName,
                UserID = userID //in future get userid from jwt
            };

            ElasticLogic <ObjectLogger> .AddToIndex(_loggingItem, _objectLoggerName);
        }
示例#17
0
    public void Initalize(Vector2 p_direction, float p_damage, GameObject p_shooter)
    {
        m_rb = gameObject.GetComponent <Rigidbody2D>();

        m_standard_velocity = p_direction * m_speed;
        m_damage            = p_damage;
        m_shooter           = p_shooter;

        ObjectLogger.log(gameObject, "BULLET");

        m_timeout = new TimeoutEventManager();

        m_timeout.addTimeout(2f, () => { ObjectLogger.unlog(gameObject, "BULLET"); Destroy(gameObject); });
    }
示例#18
0
 public AlexaBot(
     ObjectLogger objectLogger,
     BotConversation conversation,
     IAdapterIntegration botAdapter,
     IConfiguration configuration,
     BotStateAccessors accessors,
     IMediator mediator,
     ILogger <AlexaBot> logger)
 {
     _objectLogger  = objectLogger;
     _conversation  = conversation;
     _botAdapter    = botAdapter;
     _configuration = configuration;
     _accessors     = accessors;
     _mediator      = mediator;
     _logger        = logger;
 }
    //----------------------------------------------------------
    //Construction

    public void Initialize(MindBodyDNDNA <ResourceFightDNCreature> p_dna, ResourceFightGameController p_controller)
    {
        m_is_initialized = true;
        ObjectLogger.log(gameObject, "CREATURE");

        m_dna = p_dna.Clone();

        MindBodyDN mindbody = p_dna.express(this);

        m_traits = mindbody.m_body;
        InitializeBrain(mindbody.m_mind);

        m_health       = new LimitedNumber(m_traits["HEALTH"] * 5);
        m_energy       = new LimitedNumber(m_traits["ENERGY"] * 10);
        m_speed        = m_traits["SPEED"];
        m_damage       = m_traits["DAMAGE"];
        m_attack_speed = m_traits["ATTACKSPEED"];

        m_controller = p_controller;
    }
        protected override void ProcessRecord()
        {
            Logger.Log(ObjectLogger.GetLogFor(this), LogLevel.Info);

            var crm = new CrmOrganization(this.OrganizationService);

            using (FileStream solution = File.Open(this.SolutionFile, FileMode.Open))
            {
                var message = new ImportSolutionMessage(crm)
                {
                    SolutionFileStream           = solution,
                    OverwriteIfSameVersionExists = this.OverwriteIfSameVersionExists,
                    HoldingSolution  = this.HoldingSolution,
                    PublishWorkflows = this.PublishWorkflows,
                    ConvertToManaged = this.ConvertToManaged,
                    OverwriteUnmanagedCustomizations = this.OverwriteUnmanagedCustomizations,
                    SkipProductUpdateDependencies    = this.SkipProductUpdateDependencies,
                };

                var result = (ImportSolutionResult)crm.Execute(message);
                WriteObject(result);
            }
        }
示例#21
0
        public AlexaBot(
            ILogger <AlexaBot> logger,
            ObjectLogger objectLogger,
            IConfiguration configuration,
            IAdapterIntegration botAdapter,
            BotConversation conversation,
            BotStateAccessors accessors,
            QnAMakerEndpoint endpoint)
        {
            _logger        = logger;
            _objectLogger  = objectLogger;
            _configuration = configuration;

            // ** Bot adapter (to send proactive message)
            _botAdapter = botAdapter;

            // ** Bot state handling
            _conversation = conversation;
            _accessors    = accessors;

            // ** QnA endpoint
            AlexaBotQnA = new QnAMaker(endpoint);
        }
示例#22
0
        public async Task InsertTopicAsync(ProcessedTopicPostRequest topic, int episodeId, int userId)
        {
            _logger.LogDebug($"Topic contributed by user with id: {userId} in episode with id: {episodeId} to insert: {ObjectLogger.Dump(topic)}");
            _logger.LogInformation($"Inserting list of topics.");
            var parameters = new
            {
                name                  = topic.Name,
                timestamp_start       = topic.TimestampStart,
                timestamp_end         = topic.TimestampEnd,
                duration              = topic.Duration,
                community_contributed = topic.CommunityContributed,
                ad         = topic.Ad,
                created_at = DateTime.Now,
                epId       = episodeId,
                uId        = userId
            };

            using (var connection = _context.CreateConnection())
            {
                string processQuery = "INSERT INTO topic (name,timestamp_start,timestamp_end,duration,community_contributed,ad,created_at,id_episodes,id_user) " +
                                      "VALUES (@name,@timestamp_start,@timestamp_end,@duration,@community_contributed,@ad,@created_at,@epId,@uId); SELECT * FROM LASTVAL();";
                int topicId = await connection.ExecuteScalarAsync <int>(processQuery, parameters);

                for (int i = 0; i < topic.Subtopics.Count; i++)
                {
                    await InsertSubtopicAsync(topic.Subtopics[i], topicId, userId);
                }
            }
        }
示例#23
0
 private void LogObjectToFile(object objectToLog, string logFileName)
 {
     string logDirectory = GetLogDirectory();
     string logFilePath = Path.Combine(logDirectory, logFileName);
     ObjectLogger logger = new ObjectLogger(applicationConfiguration.RollOverLogFiles, applicationConfiguration.OldLogFileSets);
     logger.LogObjectToFile(objectToLog, logFilePath);
 }
 private void die()
 {
     ObjectLogger.unlog(gameObject, "RESOURCE");
     Destroy(gameObject);
 }
 //Log fitness and Destroy the game object
 private void die()
 {
     logFitness();
     ObjectLogger.unlog(gameObject, "CREATURE");
     Destroy(gameObject);
 }
示例#26
0
        internal RunContext(
            Runner initiator,
            JobStartReason startReason,
            CancellationToken?token)
        {
            _initiator = initiator;
            var jobProperties = _initiator.JobPropertiesHolder.ToJobProperties();

            _tokenSource = token.HasValue ?
                           CancellationTokenSource.CreateLinkedTokenSource(token.Value)
                :
                           new CancellationTokenSource();

            _systemWriter = new StringWriterWithEncoding(Encoding.UTF8);
            var writers = new List <TextWriter>
            {
                _systemWriter,
            };

            if (jobProperties.Output != null)
            {
                writers.Add(jobProperties.Output);
            }

            var multiTextWriter = new MultiTextWriter(Encoding.UTF8, writers);

            var dueTimeInfo          = _initiator.DueTimeHolder.GetDueTimeInfo();
            var dueTime              = dueTimeInfo.GetEffectiveDueTime();
            var dueTimeWasOverridden = dueTimeInfo.IsDueTimeOverridden();

            var now = TimeProvider.GetCurrentTime();

            _runInfoBuilder = new JobRunInfoBuilder(
                initiator.JobRunsHolder.Count,
                startReason,
                dueTime,
                dueTimeWasOverridden,
                now,
                JobRunStatus.Running,
                _systemWriter);

            _logger = new ObjectLogger(this, _initiator.JobName)
            {
                IsEnabled = _initiator.IsLoggingEnabled,
            };

            try
            {
                _task = jobProperties.Routine(
                    jobProperties.Parameter,
                    jobProperties.ProgressTracker,
                    multiTextWriter,
                    _tokenSource.Token);

                // todo: if routine returns null?

                if (_task.IsFaulted && _task.Exception != null)
                {
                    var ex = ExtractTaskException(_task.Exception);
                    multiTextWriter.WriteLine(ex);

                    _logger.Warning("Routine has thrown an exception.", "ctor", ex);
                    _task = Task.FromException(ex);
                }
            }
            catch (Exception ex)
            {
                // it is not an error if Routine throws, but let's log it as a warning.
                multiTextWriter.WriteLine(ex);

                _logger.Warning("Routine has thrown an exception.", "ctor", ex);
                _task = Task.FromException(ex);
            }
        }