Beispiel #1
0
 public Agent(string name, Color color, Point startPoint, int senseOfPurpose, Purpose purpose, int worship, Temper temper, int lifeCircle, Engine engine, int timeToStart)
 {
     _active     = true;
     _name       = name;
     _color      = color;
     _startPoint = startPoint;
     InitTimeStep();
     _senseOfPurpose = senseOfPurpose;
     _purpose        = purpose;
     _worship        = worship;
     _temper         = temper;
     LifeCircle      = lifeCircle;
     _timeToStart    = timeToStart;
     Engine          = engine;
     EndOfLife       = false;
     _startTime      = DateTime.Now;
     _idMessage      = 0;
     _oldMessage     = null;
     _newMessage     = null;
     _registred      = false;
     _space          = new List <PointState>();
     Length          = 10;
     CalculateResponceTime();
     InitCountAttempt();
     Environment.EnvironmentMessage += ReceiveMessage;
 }
Beispiel #2
0
 public void Clear()
 {
     _space.Clear();
     _name           = "";
     _color          = new Color();
     _senseOfPurpose = 0;
     _purpose        = null;
     _worship        = 0;
     _temper         = Temper.Сангвінік;
     _lifeCircle     = 0;
     _timePause      = 0;
     responceTime.Clear();
     responceTime  = null;
     _countAttempt = 0;
     _id           = 0;
     _endOfLife    = true;
     _engine       = null;
     _startTime    = DateTime.Now;
     _startPoint   = new Point();
     _space.Clear();
     _space           = null;
     _idMessage       = 0;
     _oldMessage      = null;
     _newMessage      = null;
     _env             = null;
     _registred       = false;
     _denyEnvironment = true;
     _length          = 0;
     listConfig.Clear();
     listConfig = null;
     queue.Clear();
     queue = null;
     GC.Collect();
 }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Info")] Temper temper)
        {
            if (id != temper.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(temper);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TemperExists(temper.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(temper));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Info")] Temper temper)
        {
            if (ModelState.IsValid)
            {
                _context.Add(temper);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(temper));
        }
Beispiel #5
0
    public static CharacterHandler GetCharacterHandlerPrefabFromTemper(Temper searchedTemper)
    {
        CharacterHandler theCharacterPrefab = null;

        switch (searchedTemper)
        {
        case Temper.Decisive:
            theCharacterPrefab = decisiveCharaPrefab;
            break;

        case Temper.OpenMinded:
            theCharacterPrefab = openMindedCharaPrefab;
            break;
        }
        return(theCharacterPrefab);
    }
Beispiel #6
0
 public AgentConfig(string name, Color color, int senseOfPurpose, Purpose purpose, int worship, Temper temper, double lifeCircle,
                    int attempt, SortedList <TypeMessege, int> responceTime, Point startPoint, int length, List <List <Point> > listConfig)
 {
     Name           = name;
     Color          = color;
     SenseOfPurpose = senseOfPurpose; // Целеустремленность. Диапазон (0..100). Измеряется в процентах
     Purpose        = purpose;        // Цель, см. класс Purpose
     Worship        = worship;        // Вероисповедание. Диапазон (-100..100). -100 - агент антагонист любым вероучениям. 100 - полностью верующий агент.
     Temper         = temper;         // Характер. Значение по умолчанию Temper.Сангвінік
     LifeCircle     = lifeCircle;     // Время жизни агента. Если _lifeCircle = 0 - бессмертен. Время задается в милисекундах. Значение по умолчанию 0 - бессмертен.
     Attempt        = attempt;        // Количество попыток построить фигуру
     ResponceTime   = responceTime;   // Время выполнения (отклика) на каждое из действий агента
     StartPoint     = startPoint;     // Начальная точка фигуры
     Length         = length;         // Длина агента (линейки)
     ListConfig     = listConfig;
 }
Beispiel #7
0
 public Agent(string name, Color color, Point startPoint, int senseOfPurpose, Purpose purpose, int worship, Temper temper, int lifeCircle, Engine engine) : this(name, color, startPoint, senseOfPurpose, purpose, worship, temper, 0, new RealEngine(), 0)
 {
 }
Beispiel #8
0
 public Agent(string name, Color color, Point startPoint, int senseOfPurpose, Purpose purpose, int worship, Temper temper) : this(name, color, startPoint, senseOfPurpose, purpose, worship, temper, 0)
 {
 }
        public void LoyaltyInfluence(Temper temper, iLogicMapContainer owner)
        {
            Team team = null;

            if (owner is QuestTask)
            {
                team = ((QuestTask)owner).GetTeam();
            }
            Agency agency = Agency.GetInstantiate();
            float  mod    = 1f;

            foreach (Detective detective in agency.GetDetectives())
            {
                if (team.detectives.Contains(detective))
                {
                    mod = 1f;
                }
                else
                {
                    mod = 0.25f;
                }
                if (temper == Temper.RUDE)
                {
                    if (detective.temper == Temper.RUDE)
                    {
                        detective.ChangeCurLoyalty(mod * loyaltyInfluence);
                    }
                    else if (detective.temper == Temper.PRUDENT)
                    {
                        detective.ChangeCurLoyalty(-mod * loyaltyInfluence);
                    }
                }
                else if (temper == Temper.PRUDENT)
                {
                    if (detective.temper == Temper.PRUDENT)
                    {
                        detective.ChangeCurLoyalty(mod * loyaltyInfluence);
                    }
                    else if (detective.temper == Temper.RUDE)
                    {
                        detective.ChangeCurLoyalty(-mod * loyaltyInfluence);
                    }
                }
                else if (temper == Temper.MERCIFUL)
                {
                    if (detective.temper == Temper.MERCIFUL)
                    {
                        detective.ChangeCurLoyalty(mod * loyaltyInfluence);
                    }
                    else if (detective.temper == Temper.CRUEL)
                    {
                        detective.ChangeCurLoyalty(-mod * loyaltyInfluence);
                    }
                }
                else if (temper == Temper.CRUEL)
                {
                    if (detective.temper == Temper.CRUEL)
                    {
                        detective.ChangeCurLoyalty(mod * loyaltyInfluence);
                    }
                    else if (detective.temper == Temper.MERCIFUL)
                    {
                        detective.ChangeCurLoyalty(-mod * loyaltyInfluence);
                    }
                }
                else if (temper == Temper.MERCANTILE)
                {
                    if (detective.temper == Temper.MERCANTILE)
                    {
                        detective.ChangeCurLoyalty(mod * loyaltyInfluence);
                    }
                    else if (detective.temper == Temper.PRINCIPLED)
                    {
                        detective.ChangeCurLoyalty(-mod * loyaltyInfluence);
                    }
                }
                else if (temper == Temper.PRINCIPLED)
                {
                    if (detective.temper == Temper.PRINCIPLED)
                    {
                        detective.ChangeCurLoyalty(mod * loyaltyInfluence);
                    }
                    else if (detective.temper == Temper.MERCANTILE)
                    {
                        detective.ChangeCurLoyalty(-mod * loyaltyInfluence);
                    }
                }
            }
        }
Beispiel #10
0
 private void RealizeFunction(LogicFunction function, bool isTest = false)
 {
     if (function is LogicSplitter)
     {
         List <LogicFunction> outputs = ((LogicSplitter)function).actionOutputs;
         for (int i = 0; i < outputs.Count; i++)
         {
             ((LogicSplitter)function).realizeOutputs[i] = true;
             RealizeFunction(outputs[i], isTest);
         }
     }
     else if (function is DataSplitter)
     {
         DataSplitter dataSplitter = (DataSplitter)function;
         bool         result       = dataSplitter.GetResult();
         if (result)
         {
             dataSplitter.realizeTrue = true;
             RealizeFunction(dataSplitter.trueOutput, isTest);
         }
         else
         {
             dataSplitter.realizeFalse = true;
             RealizeFunction(dataSplitter.falseOutput, isTest);
         }
     }
     else if (function is LogicEffect)
     {
         ((LogicEffect)function).Realize(curOwner, team, isTest);
     }
     else if (function is WaitFunction)
     {
         ((WaitFunction)function).CreateWaitAction(delegate { RealizeFunction(((WaitFunction)function).actionOutput, isTest); });
     }
     else if (function is ChallengeFunction)
     {
         ChallengeFunction challengeFunction = (ChallengeFunction)function;
         challengeFunction.CreateWaitAction(curOwner, delegate
         {
             challengeFunction.realizeTrue  = true;
             challengeFunction.realizeFalse = false;
             if (challengeFunction.trueFileNote != null)
             {
                 curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                 curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(challengeFunction.trueFileNote, curOwner.GetTeam().transform));
             }
             RealizeFunction(challengeFunction.trueOutput, isTest);
         }, delegate {
             challengeFunction.realizeTrue  = false;
             challengeFunction.realizeFalse = true;
             if (challengeFunction.falseFileNote != null)
             {
                 curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                 curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(challengeFunction.falseFileNote, curOwner.GetTeam().transform));
             }
             RealizeFunction(challengeFunction.falseOutput, isTest);
         });
     }
     else if (function is ChooseMethodFunction)
     {
         ChooseMethodFunction methodFunction = (ChooseMethodFunction)function;
         if (methodFunction.dialog == null || !curOwner.GetTeam().GetLeader().IsObedient())
         {
             Method method = methodFunction.Realize(curOwner);
             Debug.Log(string.Format("ChooseMethod - {0}", method.ToString()), methodFunction);
             if (method == Method.Brutal)
             {
                 if (methodFunction.brutalFileNote != null)
                 {
                     curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                     curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(methodFunction.brutalFileNote, curOwner.GetTeam().transform));
                 }
                 RealizeFunction(methodFunction.brutalOutput, isTest);
             }
             else if (method == Method.Accuracy)
             {
                 if (methodFunction.carefulFileNote != null)
                 {
                     curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                     curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(methodFunction.carefulFileNote, curOwner.GetTeam().transform));
                 }
                 RealizeFunction(methodFunction.carefulOutput, isTest);
             }
             else if (method == Method.Diplomacy)
             {
                 if (methodFunction.diplomatFileNote != null)
                 {
                     curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                     curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(methodFunction.diplomatFileNote, curOwner.GetTeam().transform));
                 }
                 RealizeFunction(methodFunction.diplomatOutput, isTest);
             }
             else if (method == Method.Science)
             {
                 if (methodFunction.scienceFileNote != null)
                 {
                     curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                     curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(methodFunction.scienceFileNote, curOwner.GetTeam().transform));
                 }
                 RealizeFunction(methodFunction.scienceOutput, isTest);
             }
         }
         else
         {
             Debug.Log(string.Format("ChooseMethod start dialog"), methodFunction);
             UnityAction action = delegate
             {
                 int index = methodFunction.dialog.GetEnds().IndexOf(methodFunction.dialog.end);
                 if (methodFunction.dialogFileNotes[index] != null)
                 {
                     curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                     curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(methodFunction.dialogFileNotes[index], curOwner.GetTeam().transform));
                 }
                 RealizeFunction(methodFunction.dialogOutputs[index], isTest);
             };
             Dialog.DialogManager.GetInstantiate().StartDialog(methodFunction.dialog, curOwner.GetTeam(), ((iEffectsContainer)curOwner).GetQuest(), action);
         }
     }
     else if (function is ChooseTemperFunction)
     {
         ChooseTemperFunction temperFunction = (ChooseTemperFunction)function;
         if (temperFunction.dialog == null || !curOwner.GetTeam().GetLeader().IsObedient())
         {
             Temper temper = temperFunction.Realize(curOwner);
             Debug.Log(string.Format("ChooseTemper - {0}", temper.ToString()), temperFunction);
             if (temper == Temper.RUDE)
             {
                 if (temperFunction.rudeFileNote != null)
                 {
                     curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                     curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(temperFunction.rudeFileNote, curOwner.GetTeam().transform));
                 }
                 RealizeFunction(temperFunction.rudeOutput, isTest);
             }
             else if (temper == Temper.PRUDENT)
             {
                 if (temperFunction.prudentFileNote != null)
                 {
                     curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                     curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(temperFunction.prudentFileNote, curOwner.GetTeam().transform));
                 }
                 RealizeFunction(temperFunction.prudentOutput, isTest);
             }
             else if (temper == Temper.MERCIFUL)
             {
                 if (temperFunction.mercifulFileNote != null)
                 {
                     curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                     curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(temperFunction.mercifulFileNote, curOwner.GetTeam().transform));
                 }
                 RealizeFunction(temperFunction.mercifulOutput, isTest);
             }
             else if (temper == Temper.CRUEL)
             {
                 if (temperFunction.cruelFileNote != null)
                 {
                     curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                     curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(temperFunction.cruelFileNote, curOwner.GetTeam().transform));
                 }
                 RealizeFunction(temperFunction.cruelOutput, isTest);
             }
             else if (temper == Temper.MERCANTILE)
             {
                 if (temperFunction.mercantileFileNote != null)
                 {
                     curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                     curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(temperFunction.mercantileFileNote, curOwner.GetTeam().transform));
                 }
                 RealizeFunction(temperFunction.mercantileOutput, isTest);
             }
             else if (temper == Temper.PRINCIPLED)
             {
                 if (temperFunction.principledFileNote != null)
                 {
                     curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                     curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(temperFunction.principledFileNote, curOwner.GetTeam().transform));
                 }
                 RealizeFunction(temperFunction.principledOutput, isTest);
             }
         }
         else
         {
             Debug.Log(string.Format("ChooseTemper start dialog"), temperFunction);
             UnityAction action = delegate
             {
                 int index = temperFunction.dialog.GetEnds().IndexOf(temperFunction.dialog.end);
                 temperFunction.LoyaltyInfluence(temperFunction.dialogTemper[index], curOwner);
                 if (temperFunction.dialogFileNotes[index] != null)
                 {
                     curOwner.GetTeam().reportQuest.Add(((iEffectsContainer)curOwner).GetQuest());
                     curOwner.GetTeam().reportNotes.Add(FileNoteContainer.Create(temperFunction.dialogFileNotes[index], curOwner.GetTeam().transform));
                 }
                 RealizeFunction(temperFunction.dialogOutputs[index], isTest);
             };
             Dialog.DialogManager.GetInstantiate().StartDialog(temperFunction.dialog, curOwner.GetTeam(), ((iEffectsContainer)curOwner).GetQuest(), action);
         }
     }
 }