Beispiel #1
0
 public DataModule(GameData gameData, DbRepository context)
 {
     _gameData            = gameData;
     _gameState           = GameState.Initialized;
     _currentGameQuestion = null;
     _context             = context;
     GuessedGamePerson    = null;
 }
Beispiel #2
0
        //operate on database, take answers for this GamePerson and add them to QuestionSet
        private void prepareSummaries(GamePerson gamePerson, GameData gameData)
        {
            if (gamePerson == null)
            {
                return;
            }
            var answers = _context.GetAnswers(x => x.PersonId == gamePerson.PersonId);

            foreach (var question in gameData.QuestionSet)
            {
                var answer = answers.SingleOrDefault(x => x.QuestionId == question.QuestionId);
                question.SystemAnswer = answer == default(Answer) ? AnswerType.Unknown : calculateDominatingAnswer(answer.YesCount, answer.NoCount);
            }
        }
    // Spawn a person
    public static void SpawnPerson(GamePerson p)
    {
        GameObject obj = Instantiate(p.gender == Gender.Male ? Instance.manPrefab : Instance.womanPrefab, p.GetPosition(), p.GetRotation(), Instance.peopleParentTransform);

        obj.AddComponent <PersonScript>().SetPerson(p);

        Node personNode = Grid.GetNodeFromWorld(p.GetPosition());

        if (personNode != null)
        {
            personNode.SetPeopleOccupied(true);
        }

        if (PersonScript.allPeople.Count >= 15 && !Building.IsUnlocked("Grosse Feuerstelle"))
        {
            GameManager.UnlockBuilding(Building.Get("Grosse Feuerstelle"));
        }
        GameManager.UpdateAchievementPerson();
    }
Beispiel #4
0
        //take the best person that we can ask for
        private Tuple <GamePerson, string> retrieveGuessingQuestion()
        {
            GamePerson bestMatch = null;
            double     maxCoeff  = double.MinValue;

            foreach (var person in _gameData.PeopleSet.Where(x => x.DontKnowAnswers != _gameData.QuestionsAsked))
            {
                var coeff = fuzzyCoeff(person);
                if (coeff > maxCoeff || (Math.Round(coeff, 2) == Math.Round(maxCoeff, 2) && bestMatch?.DontKnowAnswers > person.DontKnowAnswers))
                {
                    bestMatch = person;
                    maxCoeff  = coeff;
                }
            }
            if (bestMatch == null)
            {
                throw new Exception("Something wrong in getting guessing question");
            }

            return(new Tuple <GamePerson, string>(bestMatch, $"Zgadywanie: czy to {bestMatch.Name}?"));
        }
Beispiel #5
0
 public void Spawn(out GamePerson person)
 {
     throw new System.NotImplementedException();
 }
Beispiel #6
0
 public override void SpecialAttack(GamePerson enemy)
 {
     Console.WriteLine("No weapon!");
     enemy.Weapon = null;
 }
 public abstract void SpecialAttack(GamePerson enemy);
Beispiel #8
0
 public override void SpecialAttack(GamePerson enemy)
 {
     Console.WriteLine("Venom!");
     enemy.HealthPoints -= 15;
 }
Beispiel #9
0
 //some probability of this person being what we're looking for, basing on real info in system
 private double fuzzyCoeff(GamePerson x)
 {
     return((double)x.CorrectAnswers / (double)(_gameData.QuestionsAsked - x.DontKnowAnswers));
 }
Beispiel #10
0
    public static void CommitMsg()
    {
        if (!IsChatActive())
        {
            return;
        }

        string msgText = Instance.chatInput.text;

        if (msgText.Length == 0)
        {
            return;
        }
        MessageType type = MessageType.PlayerChat;

        if (msgText.StartsWith("/") && GameManager.IsDebugging())
        {
            // command
            type    = MessageType.Debug;
            msgText = msgText.Substring(1);
            string[] arguments = new string[0];
            if (msgText.Contains(" "))
            {
                arguments = msgText.Substring(msgText.IndexOf(' ') + 1).Split(' ');
                msgText   = msgText.Substring(0, msgText.IndexOf(' '));
            }
            switch (msgText.ToLower())
            {
            case "help":
                string resText = "";
                for (int i = 0; i < ResourceData.allResources.Count; i++)
                {
                    resText += i + "=" + ResourceData.allResources[i].name + " ,";
                }
                resText = resText.Substring(0, resText.Length - 2);
                msgText =
                    "Spielgeschwindigkeit verändern = /speed [faktor]" +
                    "\nJahre vergehen lassen = /years [jahre]" +
                    "\nRessourcen an ausgewählte Person = /give [resNr] [anzahl]\n" + resText +
                    "\nMännlichen Bewohner spawnen = /bornman [alter]" +
                    "\nWeiblichen Bewohner spawnen = /bornwoman [alter]" +
                    "\nGebäudekosten (de)aktivieren = /tcost";
                break;

            case "speed":
                try
                {
                    float fact = float.Parse(arguments[0]);
                    fact = Mathf.Clamp(fact, 0.1f, 5000);
                    GameManager.speedFactor = fact;
                    msgText = "Spielgeschwindigkeit auf " + fact + " gesetzt";
                }
                catch
                {
                    msgText = "Falsche Argumente!";
                    type    = MessageType.Error;
                }
                break;

            case "years":
                try
                {
                    int yrs = int.Parse(arguments[0]);
                    yrs = Mathf.Clamp(yrs, 1, 100);
                    GameManager.PassYears(yrs);
                    msgText = yrs + " Jahre sind vergangen";
                }
                catch
                {
                    msgText = "Falsche Argumente!";
                    type    = MessageType.Error;
                }
                break;

            case "give":
                try
                {
                    int id = int.Parse(arguments[0]);
                    int am = int.Parse(arguments[1]);
                    am = Mathf.Clamp(am, 0, 1000);
                    PersonScript ps = PersonScript.FirstSelectedPerson();
                    if (ps)
                    {
                        ps.SetInventory(new GameResources(id, am));
                        msgText = am + "x " + ps.InventoryMaterial.Name + " wurden " + ps.FirstName + "s Inventar hinzugefügt";
                    }
                    else
                    {
                        msgText = "Keine Person ausgewählt";
                        type    = MessageType.Error;
                    }
                }
                catch
                {
                    msgText = "Falsche Argumente!";
                    type    = MessageType.Error;
                }
                break;

            case "bornman":
            case "bornwoman":
                try
                {
                    Gender Gender = (msgText.ToLower() == "bornman") ? Gender.Male : Gender.Female;
                    int    age    = int.Parse(arguments[0]);
                    age = Mathf.Clamp(age, 0, 80);
                    GamePerson p = GameManager.village.PersonBirth(-1, Gender, age);
                    msgText = "Bewohner gespawnt: Name=" + p.firstName + ",Alter=" + p.age;
                }
                catch
                {
                    msgText = "Falsche Argumente!";
                    type    = MessageType.Error;
                }
                break;

            case "tcost":
                GameManager.noCost = !GameManager.noCost;
                msgText            = "Gebäudekosten " + (GameManager.noCost ? "de" : "") + "aktiviert";
                break;

            default:
                msgText = "Falscher Befehl!";
                type    = MessageType.Error;
                break;
            }
        }
        else
        {
            msgText = GameManager.Username + ": " + msgText;
        }

        Msg(msgText, type);
        Instance.chatInput.text = "";
        Instance.chatShowTime   = 0;
    }