コード例 #1
0
    private void onAnswerClickListener(AnswerState answer)
    {
        Debug.Log("Actions count: " + answer.actionsList.Count);

        nextPhraseId = answer.getNextPhraseId();

        if (answer.isAutohide())
        {
            answer.isActive = false;
        }

        foreach (QuestAction action in answer.actionsList)
        {
            if (action.isCounterAction)
            {
                continue;
            }

            try {
                runAction(action);
            } catch (Exception e) {
                Debug.LogException(e);
                Debug.LogError("Invalid Action: " + answer.ToString());
            }
        }

        Debug.Log("Clicked: " + nextPhraseId);
        GoToNextPhrase(nextPhraseId);
    }
コード例 #2
0
 internal SurveyAnswerDelta(string key, object current, object incoming, AnswerState state)
 {
     Key      = key;
     Current  = current;
     Incoming = incoming;
     State    = state;
 }
コード例 #3
0
        public KerdesKartya(GameTable parent)
        {
            InitializeComponent();
            this.Left = parent.Left + 75;
            this.Top = parent.Top + 100;
            /*
            ImageBrush myBrush = new ImageBrush();
            myBrush.ImageSource = new BitmapImage(new Uri(".\\Resources\\keret.png", UriKind.Relative));
            this.Background = myBrush;
             */
            answer = AnswerState.Null;

            timeoutworker = new BackgroundWorker();
            timeoutworker.WorkerReportsProgress = true;
            timeoutworker.WorkerSupportsCancellation = true;
            timeoutworker.DoWork += getTime;
            timeoutworker.ProgressChanged += tick;
            timeoutworker.RunWorkerCompleted += timeout;

            Question kerdes = Client.getQuestion(User);

            kerdess.Text = kerdes.Questionn;
            valasz1.Content = kerdes.GoodAnswer;
            valasz2.Content = kerdes.BadAnswer1;
            valasz3.Content = kerdes.BadAnswer2;
            valasz4.Content = kerdes.BadAnswer3;
        }
コード例 #4
0
    private void AddAnswerToContainer(AnswerState answerState, int answerIndex)
    {
        GameObject currAnswerObj = Instantiate(answerItemPrefab, new Vector3(), new Quaternion()) as GameObject;

        // Реакция на нажатие
        GameObject answButton = currAnswerObj.transform.FindChild("Button").gameObject;

        answButton.GetComponent <Button> ().onClick.AddListener(() => onAnswerClickListener(answerState));

        // Текст
        GameObject answText         = answButton.transform.FindChild("Text").gameObject;
        string     answerHiddenMark = answerState.isActive ? "" : "[*] ";
        Text       answerTextComp   = answText.GetComponent <Text> ();

        answerTextComp.text = answerHiddenMark + answerState.getText();

        // Позиционирование
        RectTransform answRT = currAnswerObj.GetComponent <RectTransform> ();

        answRT.SetParent(answersContainer);
        answRT.localScale = new Vector3(1, 1, 1);
        answRT.anchorMin  = new Vector2(0, 0);
        answRT.anchorMax  = new Vector2(1, 1);
        answRT.offsetMax  = new Vector2(0, 0);
        answRT.offsetMin  = new Vector2(0, 0);

        Canvas.ForceUpdateCanvases();
        answerCoefList.Add(new AnswerHeightInfo(answerCoefFirstLine + answerCoefPerLine * (answerTextComp.cachedTextGenerator.lineCount - 1), answRT));
    }
コード例 #5
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.ContainTag("HorizontalPipe"))
     {
         _currentState = AnswerState.SHIFTING;
     }
 }
コード例 #6
0
 public void Done(AnswerState state)
 {
     if (state == AnswerState.Right)
     {
         SetBuilding();
     }
     else
     {
         End();
     }
 }
コード例 #7
0
    void Start()
    {
        _currentState = AnswerState.SHOWING;
        _baloon       = GetComponentInChildren <SpriteRenderer>();
        _answerImage  = GetComponentInChildren <Image>();
        _answerText   = GetComponentInChildren <Text>();
        SetAlpha(0f);
        _delta = 0f;

        gameObject.AddComponent <DestroyOnPlayerEnterInHorizontalPipeB>();
        gameObject.AddComponent <DestroyOnMatchEnd>();
    }
コード例 #8
0
        public AnswerState IsAnswerCorrect(Question question)
        {
            var answerState = new AnswerState
            {
                CorrectAnswer = question.Answers.FirstOrDefault(x => x.IsCorrect),
                GivenAnswer   = question.Answers.FirstOrDefault(x => x.Text == question.ChosenAnswer?.Text),
                Question      = question
            };

            answerState.Correct = answerState.GivenAnswer == answerState.CorrectAnswer;
            return(answerState);
        }
コード例 #9
0
 private void ShowingUpdate()
 {
     if (_delta < AnswersSettings.Instance.appearTime)
     {
         _delta += Time.deltaTime;
         float t = _delta / AnswersSettings.Instance.appearTime;
         SetAlpha(Mathf.Lerp(0f, 1f, t));
         if (t >= 1f)
         {
             _currentState = AnswerState.WAITING_HORIZONTAL_PIPE;
         }
     }
 }
コード例 #10
0
    public void SetQuiz(Action <AnswerState> end)
    {
        Solve.SetActive(false);

        state = AnswerState.Ready;

        act = end;

        ButtonOn();

        Question.SetActive(true);

        gameObject.SetActive(true);
    }
コード例 #11
0
        public void CreateAnswer(int questionId, string answer, int answererId, AnswerState answerState)
        {
            Validation.IdCheck(answererId);
            Validation.IdCheck(questionId);
            Validation.StringCheck(answer);

            using (var ctx = new IntelliCloudContext())
            {

                AnswerEntity answerEntity = new AnswerEntity();

                answerEntity.AnswerState = answerState;
                answerEntity.Content = answer;
                answerEntity.CreationTime = DateTime.UtcNow;

                UserEntity user = ctx.Users.SingleOrDefault(ld => ld.Id == answererId);

                if (user == null)
                    throw new NotFoundException("No user entity exists with the specified ID.");

                answerEntity.User = user;
                // TODO link answer to question and generate a feedbackToken using GUID (can both be set in the question).
                // TODO set IsPrivate based on private settings in question.
                answerEntity.IsPrivate = false;

                // TODO determine real language 
                LanguageDefinitionEntity languageDefinition = ctx.LanguageDefinitions.SingleOrDefault(ld => ld.Name.Equals("English"));

                if (languageDefinition == null)
                    throw new NotFoundException("No languageDefinition entity exists with the specified ID.");

                answerEntity.LanguageDefinition = languageDefinition;

                ctx.Answers.Add(answerEntity);

                ctx.SaveChanges();

            }

            // TODO put the SendAnswerFactory in the BaseManager.
            // TODO send the answer using the this.SendAnswerFactory.LoadPlugin(question.Source.Source.SourDefinition).SendAnswer(question, answer) method.
        }
コード例 #12
0
        public void InsertQuestion(int UserId, string page, string controlId, int answer)
        {
            db = new SenseiPortalEntities2();
            AnswerState answerState = new AnswerState();
            var         ans         = db.AnswerStates.Where(v => v.UserId == UserId && v.Page == page && v.ControlId == controlId).FirstOrDefault();

            if (ans != null)
            {
                ans.Answer = answer;
            }
            else
            {
                answerState.Answer    = answer;
                answerState.Page      = page;
                answerState.ControlId = controlId;
                answerState.UserId    = UserId;
                db.AnswerStates.Add(answerState);
            }
            db.SaveChanges();
        }
コード例 #13
0
        /// <summary>
        /// Retrieves all the available answers and optionally filtering them using the answer state or employee 
        /// identifier.
        /// </summary>
        /// <param name="answerState">The optional answer state, only answers with this state will be returned.
        /// </param>
        /// <param name="employeeId">The optional employee identifier, only answers about which the employee has 
        /// knowledge are returned (keywords between user and answer match).</param>
        /// <returns>Returns the answers that match the filters.</returns>
        public IList<Answer> GetAnswers(AnswerState answerState, int employeeId)
        {
            Validation.IdCheck(employeeId);

            List<Answer> answers = new List<Answer>();

            using (var ctx = new IntelliCloudContext())
            {

                List<AnswerEntity> answerentities = (from a in ctx.Answers
                                                         .Include(a => a.User)
                                                         .Include(a => a.User.Sources)
                                                         .Include(a => a.User.Sources.Select(s => s.SourceDefinition))
                                                     where a.AnswerState == answerState
                                                     select a).ToList();

                answers = ConvertEntities.AnswerEntityListToAnswerList(answerentities);

            }

            return answers;

        }
コード例 #14
0
    public void SetQuiz(Action <AnswerState> end, bool AI)
    {
        Solve.SetActive(false);

        state = AnswerState.Ready;

        act = end;


        if (AI)
        {
            ButtonOff();
            Invoke("RightAnswer", 2);
        }
        else
        {
            ButtonOn();
        }

        Question.SetActive(true);

        gameObject.SetActive(true);
    }
コード例 #15
0
    private void GoToNextPhrase(uint phraseId)
    {
        if (phraseId == 0)
        {
            ReturnToLocation();
            return;
        }

        PhraseState phrase = currentNpc.GetPhrase(phraseId);

        if (phrase == null)
        {
            Debug.LogWarning("Current dialog phrase is null!");
            return;
        }
        Debug.Log("Goto Phrase: " + phrase.ToString());

        npcPhraseText.text = phrase.getText();

        List <AnswerState> answers = phrase.getAnswers();

        ClearContainer();
        for (int answInd = 0; answInd < answers.Count; answInd++)
        {
            AnswerState answer = answers [answInd];
            if ((answer.isActive) || (showHiddenAnswers))
            {
                AddAnswerToContainer(answer, answInd);
                Debug.Log("Answer: " + answer.ToString());
            }
            else
            {
                Debug.Log("Skip hidden answer: " + answer.ToString());
            }
        }
        ResizeContainer();
    }
コード例 #16
0
 void getTime(object sender, DoWorkEventArgs e)
 {
     int last = 30;
     int prev = 30;
     BackgroundWorker bw = (sender as BackgroundWorker);
     while (!bw.CancellationPending && (last = Client.getTimeLeft(User)) > 0)
     {
         if (prev != last)
         {
             prev = last;
             bw.ReportProgress(last);
         }
         Thread.Sleep(PingPeriod);
     }
     if (last == 0)
     {
         answer = AnswerState.Timeout;
     }
 }
コード例 #17
0
        /// <summary>
        /// Updates the answer with the given identifier.
        /// </summary>
        /// <param name="id">The identifier of the answer that is updated.</param>
        /// <param name="answerState">The new state of the answer.</param>
        /// <param name="answer">The new content of the given answer.</param>
        public void UpdateAnswer(string id, AnswerState answerState, string answer)
        {
            Validation.IdCheck(id);
            Validation.StringCheck(answer);

            using (var ctx = new IntelliCloudContext())
            {
                int iId = Convert.ToInt32(id);

                AnswerEntity answerEntity = (from a in ctx.Answers
                                                 .Include(a => a.User)
                                                 .Include(a => a.LanguageDefinition)
                                             where a.Id == iId
                                             select a).SingleOrDefault();

                if (answerEntity == null)
                    throw new NotFoundException("No answer entity exists with the specified ID.");

                answerEntity.AnswerState = answerState;
                answerEntity.Content = answer;

                ctx.SaveChanges();

            }
        }
コード例 #18
0
    private void runAction(QuestAction action)
    {
        switch (action.actionType)
        {
        case ActionType.ACT_TYPE_ADD_MEMBER:         // [ MAKE IT! ]
        {
            //member id
            Debug.Log("Action: Add member");
            break;
        }

        case ActionType.ACT_TYPE_CHANGE_QUEST:
        {
            GlobalData.resourcesManager.getById <QuestState>(uint.Parse(action.actionVariables [0]))
            .status = (QuestStatus)uint.Parse(action.actionVariables [1]);
            Debug.Log("Action: Change quest");
            break;
        }

        case ActionType.ACT_TYPE_CHANGE_RESOURCE:         // [ MAKE IT! ]
        {
            //res id
            //res change
            Debug.Log("Action: Change resource");
            break;
        }

        case ActionType.ACT_TYPE_CHANGE_SPEECH:
        {
            GlobalData.resourcesManager.getById <NPCState>(uint.Parse(action.actionVariables [0]))
            .GetPhrase(uint.Parse(action.actionVariables [1]))
            .getAnswer(uint.Parse(action.actionVariables [2]))
            .isActive = bool.Parse(action.actionVariables [3]);
            Debug.Log("Action: Change speech");
            break;
        }

        case ActionType.ACT_TYPE_CHANGE_SUBQUEST:         // [ MAKE IT! ]
        {
            //quest id
            //subquest id
            //subquest change
            Debug.Log("Action: Change subquest");
            break;
        }

        case ActionType.ACT_TYPE_ENDGAME:         // [ MAKE IT! ]
        {
            //hero is dead
            Debug.Log("Action: End game");
            break;
        }

        case ActionType.ACT_TYPE_GOTO_DIALOG:
        {
            uint nextNpcId = uint.Parse(action.actionVariables [0]);
            nextPhraseId = uint.Parse(action.actionVariables [1]);
            SelectNPC(nextNpcId);
            Debug.Log("Action: Goto dialog (npc id: " + nextNpcId + "; phrase id: " + nextPhraseId + ")");
            break;
        }

        case ActionType.ACT_TYPE_LOC_VISIBLE:
        {
            uint          changedLocId = uint.Parse(action.actionVariables [0]);
            LocationState locState     = GlobalData.resourcesManager.getById <LocationState> (changedLocId);
            if (locState != null)
            {
                locState.isVisible = bool.Parse(action.actionVariables [1]);
            }
            Debug.Log("Action: Location visibility change");
            break;
        }

        case ActionType.ACT_TYPE_MOVE_NPC:
        {
            uint          changedLocId = uint.Parse(action.actionVariables [1]);
            LocationState locState     = GlobalData.resourcesManager.getById <LocationState> (changedLocId);
            locState.firstPhraseNpcId = uint.Parse(action.actionVariables [0]);
            locState.firstPhraseId    = uint.Parse(action.actionVariables [2]);

            Debug.Log("Action: Move NPC");
            break;
        }

        case ActionType.ACT_TYPE_REMOVE_RANDOM_MEMBER:         // [ MAKE IT! ]
        {
            // N/A
            Debug.Log("Action: Remove random member");
            break;
        }

        case ActionType.ACT_TYPE_SECT_VISIBLE:
        {
            uint        changedSecId = uint.Parse(action.actionVariables [0]);
            SectorState secState     = GlobalData.resourcesManager.getById <SectorState> (changedSecId);
            if (secState != null)
            {
                secState.isVisible = bool.Parse(action.actionVariables [1]);
            }
            Debug.Log("Action: Sector visibility change");
            break;
        }

        case ActionType.ACT_TYPE_CHANGE_COUNTER:
        {
            AnswerState changedAnswer = GlobalData.resourcesManager.getById <NPCState> (uint.Parse(action.actionVariables [0]))
                                        .GetPhrase(uint.Parse(action.actionVariables [1]))
                                        .getAnswer(uint.Parse(action.actionVariables [2]));
            changedAnswer.decreaseCounter();

            if (changedAnswer.getCounter() <= 0)
            {
                foreach (QuestAction cntAction in changedAnswer.actionsList)
                {
                    if (!cntAction.isCounterAction)
                    {
                        continue;
                    }

                    try {
                        runAction(cntAction);
                    } catch (Exception e) {
                        Debug.LogException(e);
                        Debug.LogError("Invalid Counter Action: " + changedAnswer.ToString());
                    }
                }
            }

            Debug.Log("Action: Change counter");
            break;
        }
        }
    }
コード例 #19
0
 public IList<Answer> GetAnswers(AnswerState answerState, int employeeId)
 {
     return manager.GetAnswers(answerState, employeeId);
 }
コード例 #20
0
 public void CreateAnswer(int questionId, string answer, int answererId, AnswerState answerState)
 {
     manager.CreateAnswer(questionId, answer, answererId, answerState);
 }
コード例 #21
0
 public void UpdateAnswer(string id, AnswerState answerState, string answer)
 {
     manager.UpdateAnswer(id, answerState, answer);
 }
コード例 #22
0
 public void WrongAnswer()
 {
     state = AnswerState.Wrong;
     Question.SetActive(false);
     Solve.SetActive(true);
 }
コード例 #23
0
 public void RightAnswer()
 {
     state = AnswerState.Right;
     Question.SetActive(false);
     Solve.SetActive(true);
 }
コード例 #24
0
ファイル: Game.cs プロジェクト: Zanion/Ascent_of_Numrock
    void Start()
    {
        PlayerAutomate = false;

        AutomateSpeed = 0.01f;
        AnswerCount = 0;

        DebugScript = GameObject.Find("DebugObject").GetComponent<GameDebugScript>();

        Basic = GameObject.Find("Basic");
        Strong = GameObject.Find("Strong");
        Special = GameObject.Find("Special");

        NoCombatState   = new NoCombatState(this);
        AttackState     = new AttackState(this);
        DefenseState    = new DefenseState(this);
        AnswerState     = new AnswerState(this);
        AnimatingState  = new AnimatingState(this);

        Camera = new CameraController(GameObject.Find("Main Camera"));
        Waypoint = new Waypoint();
        Waypoint.CurrentPosition = new Vector3(-1.65f, 0.9f, -1.0f);
        Waypoint.WaypointPosition = new Vector3(0.9f, 0.9f, -1.0f);
        MonsterWaypoint = new Vector3(3.1f, 1.05f, -1.0f);
        Camera.WaypointPosition = Waypoint.WaypointPosition + new Vector3(1.1f, 0f, -10.0f);
        WaypointCounter = 0;

        UIView = GameObject.Find("GameController").GetComponent<UIView>();

        PlayerFactory = new PlayerFactory();
        EnemyFactory = new EnemyFactory();

        // Player Factory
        Player = PlayerFactory.CreatePlayer("Wizard", Application.loadedLevel, GameObject.Find("Player"));

        Player.WaypointPosition = Waypoint.WaypointPosition;

        State = NoCombatState;
    }
コード例 #25
0
 public void SetAnswerState(AnswerState state)
 {
     quizConfig.answerState = state;
 }
コード例 #26
0
        private void valasz(object sender, RoutedEventArgs e)
        {
            int i = 0;
            if (valasz1.IsChecked == true) i = 0;
            else if (valasz2.IsChecked == true) i = 1;
            else if (valasz3.IsChecked == true) i = 2;
            else if (valasz4.IsChecked == true) i = 3;

            if (Client.answerQuestion(User, i)) answer = AnswerState.Good;
            else answer = AnswerState.Bad;

            timeoutworker.CancelAsync();
        }
コード例 #27
0
    /// <summary>
    /// Applies proper boost to the required room if the player gives the correct responses in a character event
    /// Also marks this event as having been played once already
    /// </summary>
    public void EndCharacterEvent()
    {
        print("Ending this character event");

        if (characterApproval >= 0)
        {
            answersState = AnswerState.POSITIVE;
        }
        else if (characterApproval < 0)
        {
            answersState = AnswerState.NEGATIVE;
        }
        else
        {
            answersState = AnswerState.NEUTRAL;
        }

        switch (answersState)
        {
        case AnswerState.POSITIVE:
            MoraleManager.instance.CrewMorale += positiveMoraleBoost;
            switch (thisCharacter)
            {
            case CharacterStats.Characters.Kuon:         //Kuon boosts security and weapons
                thisShip.Security    += Mathf.RoundToInt(securityBoost * campMan.GetMultiplier(ResourceDataTypes._Security));
                thisShip.ShipWeapons += Mathf.RoundToInt(weaponsBoost * campMan.GetMultiplier(ResourceDataTypes._ShipWeapons));

                SpawnStatChangeText(securityBoost, GameManager.instance.GetResourceData((int)ResourceDataTypes._Security).resourceIcon);
                SpawnStatChangeText(weaponsBoost, GameManager.instance.GetResourceData((int)ResourceDataTypes._ShipWeapons).resourceIcon);
                break;

            case CharacterStats.Characters.Mateo:         //Boosts energy
                int newEnergy = Mathf.RoundToInt(energyBoost * campMan.GetMultiplier(ResourceDataTypes._Energy));
                thisShip.Energy += new Vector3(newEnergy, 0, 0);
                SpawnStatChangeText(newEnergy, GameManager.instance.GetResourceData((int)ResourceDataTypes._Energy).resourceIcon);
                break;

            case CharacterStats.Characters.Lanri:         //boosts Food

                thisShip.Food += Mathf.RoundToInt(foodBoost * campMan.GetMultiplier(ResourceDataTypes._Food));
                SpawnStatChangeText(foodBoost, GameManager.instance.GetResourceData((int)ResourceDataTypes._Food).resourceIcon);
                break;
            }
            break;

        case AnswerState.NEUTRAL:
            MoraleManager.instance.CrewMorale += neutralMoraleBoost;
            break;

        case AnswerState.NEGATIVE:
            MoraleManager.instance.CrewMorale += moraleLoss;
            switch (thisCharacter)
            {
            case CharacterStats.Characters.Kuon:         //loses security and weapons by 10
                thisShip.Security    += Mathf.RoundToInt(securityLoss * campMan.GetMultiplier(ResourceDataTypes._Security));
                thisShip.ShipWeapons += Mathf.RoundToInt(weaponsLoss * campMan.GetMultiplier(ResourceDataTypes._ShipWeapons));

                SpawnStatChangeText(securityLoss, GameManager.instance.GetResourceData((int)ResourceDataTypes._Security).resourceIcon);
                SpawnStatChangeText(weaponsLoss, GameManager.instance.GetResourceData((int)ResourceDataTypes._ShipWeapons).resourceIcon);
                break;

            case CharacterStats.Characters.Mateo:         //Loses energy
                int newEnergy = Mathf.RoundToInt(energyLoss * campMan.GetMultiplier(ResourceDataTypes._Energy));
                thisShip.Energy += new Vector3(newEnergy, 0, 0);
                SpawnStatChangeText(newEnergy, GameManager.instance.GetResourceData((int)ResourceDataTypes._Energy).resourceIcon);
                break;

            case CharacterStats.Characters.Lanri:         //loses Food
                thisShip.Food += Mathf.RoundToInt(foodLoss * campMan.GetMultiplier(ResourceDataTypes._Food));
                SpawnStatChangeText(foodLoss, GameManager.instance.GetResourceData((int)ResourceDataTypes._Food).resourceIcon);
                break;
            }
            break;
        }
    }
コード例 #28
0
 public void __TEST__SetState(AnswerState newState)
 {
     _currentState = newState;
 }