Beispiel #1
0
        internal EvaluationContext(Evaluator evaluator, MatchElement evaluatedElement, EvaluationContext parentContext)
        {
            _evaluator = evaluator;

            _evaluatedElement = evaluatedElement;
            _parentContext    = parentContext;
        }
Beispiel #2
0
        public override MissionBase Generate()
        {
            List <MatchElement> matchElements = new List <MatchElement>
            {
                new MatchElement("exe", new[] { "Программы" }),
                new MatchElement("doc", new[] { "Документы" }),
                new MatchElement("xls", new[] { "Таблицы" }),
                new MatchElement("txt", new[] { "Текстовые документы" }),
                new MatchElement("ppt", new[] { "Презентации" }),
                new MatchElement("html", new[] { "Страницы из Интернета" }),
                new MatchElement("jpg", new[] { "Рисунок, фотография" }),
                new MatchElement("mp3", new[] { "Музыка" }),
                new MatchElement("avi", new[] { "Видео" }),
                new MatchElement("rar", new[] { "Архив" })
            };

            List <MatchElement> matchElementsInResult = new List <MatchElement>();

            for (int i = 0; i < matchElements.Count;)
            {
                MatchElement elToAdd = matchElements[rnd.Next(0, matchElements.Count)];
                if (!matchElementsInResult.Contains(elToAdd))
                {
                    matchElementsInResult.Add(elToAdd);
                    i++;
                }
            }
            matchElementsInResult = matchElementsInResult.OrderBy(x => rnd.Next()).ToList(); //shuffle array
            string[] terms  = new string[6];
            string[] defs   = new string[6];
            int[]    answer = new int[6];
            for (int i = 0; i < terms.Length; i++)
            {
                MatchElement currentElement = matchElementsInResult[i];

                terms[i] = currentElement.Term;
                defs[i]  = currentElement.Definitions.ToList().OrderBy(x => rnd.Next()).ToArray()[0]; //random element
                int currAnswer = i;
                currAnswer++;
                answer[i] = currAnswer;
            }
            //shuffle defs and answer
            for (int i = 0; i < defs.Length; i++)
            {
                int index1 = rnd.Next(0, defs.Length), index2 = rnd.Next(0, defs.Length);

                (defs[index1], defs[index2])     = (defs[index2], defs[index1]);
                (answer[index1], answer[index2]) = (answer[index2], answer[index1]);
            }
            MissionBase generated = new MatchMission(NumOfMission, MissionName, terms, defs, answer);

            return(generated);
        }
    /// <summary>
    /// Used for non player match element input.
    /// First set board untouchable. Send null match element and get explode event.
    /// If there wont be any explosion then we can set board touchable and return. If there will be any explosion then set these explosions.
    /// </summary>
    public void SetMatchElement()
    {
        SetBoardUnuouchable?.Invoke();
        MatchElement matchElement = new MatchElement();
        ExplodeEvent explodeEvent = hexagonLogic.Explode(matchElement);

        if (!explodeEvent.IsActionValid)
        {
            SetBoardTouchable?.Invoke();
            return;
        }
        SetExplosion(explodeEvent);
    }
Beispiel #4
0
        internal EvaluationResult Evaluate(MatchElement element, string question, EvaluationContext parentContext)
        {
            var context = new EvaluationContext(this, element, parentContext);

            var elementRepresentation = element.Pattern.Representation;
            var evaluationDescription = getEvaluationDescription(elementRepresentation, question, context);

            if (evaluationDescription == null)
            {
                //we can't do better than create explicit entity constraint and generate HowToEvaluateQ.
                return(new EvaluationResult(DbConstraint.Entity(element.Token), new DbConstraint(new ConstraintEntry(DbConstraint.Entity(element.Token), question, null))));
            }

            return(Evaluate(evaluationDescription, question, context));
        }
    /// <summary>
    /// Player match element input.
    /// Set boarch untouchable. create match element with selected coords and send it to the logic to see if match request is available or not.
    /// With return explode event set bomb texts. If any bomb explodes then game over.
    /// If action is valid turn hexagon gameobjects, explode them and deselect previous selected coords.
    /// If action is not valid, calculate the destinations of all hexagon gameobject to make it rotation move.
    /// </summary>
    /// <param name="isTurnClockWise"></param>
    public void SetMacthElement(bool isTurnClockWise)
    {
        if (selectedCoords == null)
        {
            return;
        }
        SetBoardUnuouchable?.Invoke();

        MatchElement matchElement = new MatchElement(selectedCoords);

        ExplodeEvent explodeEvent = hexagonLogic.Explode(matchElement, isTurnClockwise: isTurnClockWise);

        SetBombTexts(explodeEvent);

        if (explodeEvent.bombEvent.isBombeExploded)
        {
            Debug.Log("Bomb exploded! Game Over!");
            GameOver?.Invoke();
        }

        if (explodeEvent.IsActionValid)
        {
            Debug.Log("Player action is valid. Explosion and fill events are starting.");
            ChangeElementsCoordsAndPosiitons(selectedCoords, explodeEvent.turnNo, isTurnClockWise);
            SetExplosion(explodeEvent);
            DeselectHexagons();
        }
        else
        {
            Debug.Log("Player action is not valid. Turn selected coords and return to their coords.");
            List <List <Vector2> > destinations = TurnClockwise(selectedCoords, 3, isTurnClockWise);
            TurnGridComponents(destinations);
            StopAllCoroutines();
            StartCoroutine(Move());
        }
    }