public JsonResult SubjectsQuestionesByClass(int id) { var sub = db.AspNetSubjects.Where(r => r.ClassID == id).Select(x => new { x.Id, x.SubjectName }).OrderByDescending(r => r.Id).ToList(); var SubjectQuestion = new SubjectQuestion(); SubjectQuestion.Subjects = new List <Subjects>(); foreach (var item in sub) { var subjects = new Subjects(); subjects.Id = item.Id; subjects.SubjectName = item.SubjectName; SubjectQuestion.Subjects.Add(subjects); } var questiones = db.AspNetAssessment_Question.Where(x => x.AspNetSubject.ClassID == id).Select(x => new { x.Id, x.Question, x.AspNetAssessment_Questions_Category.CategoryName, x.AspNetSubject.SubjectName, x.AspNetSubject.AspNetClass.ClassName }).ToList(); SubjectQuestion.Questiones = new List <Questiones>(); foreach (var item in questiones) { var Question = new Questiones(); Question.Id = item.Id; Question.QuestionCatageory = item.CategoryName; Question.Subjectname = item.SubjectName; Question.ClassName = item.ClassName; Question.Question = item.Question; SubjectQuestion.Questiones.Add(Question); } return(Json(SubjectQuestion, JsonRequestBehavior.AllowGet)); }
void main_attack_phase() { if (Input.GetMouseButtonDown(0)) { Debug.Log("had mouse click"); Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (attack_phases == 1) { Debug.Log("inside attack phase 1"); selected_country = Convert.ToInt32(hit.collider.gameObject.tag); if (obj.country_owner[selected_country] == currentplayer && obj.country_soliders[selected_country] > 1) { attack_phases++; coloring_near_by(selected_country, graph_obj.can_attack(selected_country, currentplayer)); talker.say_instruction("select country to attack"); } } if (attack_phases == 2) { attacked_country = Convert.ToInt32(hit.collider.gameObject.tag); if (graph_obj.can_attack(selected_country, currentplayer).Contains(attacked_country) == true) { attack_phases++; counter.SetActive(true); talker.say_instruction("Choose number of soldiers you attack with big number comes with a big Risk"); counter_attack = obj.country_soliders[selected_country]; } } } } if (Input.GetMouseButtonDown(1)) { Debug.Log("right click"); close_attack(); } if (attack_phases == 3) { if (counter.activeSelf == false) { soldiers = Convert.ToInt32(counter_text.GetComponent <TextMeshPro>().text); question_canvas.SetActive(true); Questiones objectt = GetComponent <Questiones>(); attack_phases++; talker.say_instruction("Answer Question if you answer correctly the enemy will lose the number you attacked with if your answer was wrong you will lose your soldiers"); } } if (attack_phases == 4) { if (!question_canvas.activeSelf) { if (question) { obj.country_soliders[attacked_country] -= soldiers; if (obj.country_soliders[attacked_country] <= 0) { Debug.Log(obj.country_owner[attacked_country]); obj.country_owner[attacked_country] = currentplayer; obj.country_soliders[selected_country]--; obj.country_soliders[attacked_country] = 1; } talker.say_instruction("attack success", question); } else { int xfailed = (soldiers * numberofcountriesOfenemy + 32) / 33; obj.country_soliders[selected_country] -= xfailed; if (obj.country_soliders[selected_country] <= 0) { obj.country_soliders[selected_country] = 1; } talker.say_instruction("Attack failed", question); numberofcountriesOfenemy = obj.players[obj.country_owner[attacked_country]].countries.Count; } obj.update_material(); attack_phases++; attack_more_canvas.SetActive(true); } } if (attack_phases == 5) { if (!attack_more_canvas.activeSelf) { if (attack_more_bool) { close_attack(); } } } }