コード例 #1
0
        private Game()
        {
            GlobalStudentStats = new StudentStats();

            Display.InitDisplay();
            GotoMainMenu();
        }
コード例 #2
0
    private void OnTriggerEnter(Collider other)
    {
        Debug.Log("Collide");

        // Find the collider's rigidbody.
        Rigidbody targetRigidbody = other.GetComponent <Rigidbody> ();

        // If they don't have a rigidbody, go on to the next collider.
        if (!targetRigidbody)
        {
            return;
        }

        // Find the TankHealth script associated with the rigidbody.
        StudentStats targetHealth = targetRigidbody.GetComponent <StudentStats> ();

        // If there is no TankHealth script attached to the gameobject, go on to the next collider.
        if (!targetHealth)
        {
            return;
        }

        // Calculate the amount of damage the target should take based on it's distance from the shell.
        float damage = m_MaxDamage;

        //m_ExplosionAudio.Play();
        //StartCoroutine(m_Text.BroadcastMessage("A pixel"), 2);

        GUI.Box(new Rect(0, 0, 100, 100), "Well done!!");

        // Deal this damage to the tank.
        targetHealth.TakeDamage(damage);
    }
コード例 #3
0
    private void CopyClassValues(StudentStats sourceComp, StudentStats targetComp)
    {
        FieldInfo[] sourceFields = sourceComp.GetType().GetFields(BindingFlags.Public |
                                                                  BindingFlags.NonPublic |
                                                                  BindingFlags.Instance);
        int i = 0;

        for (i = 0; i < sourceFields.Length; i++)
        {
            var value = sourceFields[i].GetValue(sourceComp);
            sourceFields[i].SetValue(targetComp, value);
        }
    }
コード例 #4
0
    public void AddStudentsToPool(int numToAdd)
    {
        for (int i = 0; i < numToAdd; i++)
        {
            GameObject studentObject = Instantiate(pooledStudentPrefab, selectionPoolGameObject.transform);

            StudentStats studentStats = studentObject.GetComponent <StudentStats>();
            if (studentStats)
            {
                studentStats.RandomiseStats();
            }
        }
        studentInfoFrameManagerScript.RefreshStudentInfoUI();
    }
コード例 #5
0
ファイル: Confuse.cs プロジェクト: szhao13/cryleys_world
    private void OnTriggerEnter(Collider other)
    {
        // Collect all the colliders in a sphere from the shell's current position to a radius of the explosion radius.
        Collider[] colliders = Physics.OverlapSphere(transform.position, 5f, m_DamageMask);

        for (int i = 0; i < Math.Min(1, colliders.Length); i++)
        {
            Rigidbody targetRigidbody = gameObject.GetComponent <Rigidbody> ();
            if (!targetRigidbody)
            {
                return;
            }

            StudentStats targetHealth = targetRigidbody.GetComponent <StudentStats> ();
            if (!targetHealth)
            {
                return;
            }

            float damage = m_Damage;

            Debug.Log("Take damage");
            targetHealth.TakeDamage(damage);
            Destroy(colliders [i]);
            return;
        }

        colliders = Physics.OverlapSphere(transform.position, 2f, m_HealthMask);
        Debug.Log("Health colliders");
        Debug.Log(colliders.Length);
        for (int i = 0; i < Math.Min(1, colliders.Length); i++)
        {
            Rigidbody targetRigidbody = gameObject.GetComponent <Rigidbody> ();
            if (!targetRigidbody)
            {
                return;
            }

            StudentStats targetHealth = targetRigidbody.GetComponent <StudentStats> ();
            if (!targetHealth)
            {
                return;
            }
            Debug.Log("Gain Health");
            targetHealth.GainHealth(10);
            Destroy(colliders [i]);
        }
    }
コード例 #6
0
    public void EnrollStudent(StudentStats studentToEnroll)
    {
        GameObject   enrolledStudent = Instantiate(enrolledStudentPrefab, enrolledGameObject.transform);
        StudentStats enrolledStats   = enrolledStudent.GetComponent <StudentStats>();
        PolyNavAgent polyNavAgent    = enrolledStudent.GetComponent <PolyNavAgent>();


        if (enrolledStats)
        {
            CopyClassValues(studentToEnroll, enrolledStats);
        }

        if (polyNavAgent)
        {
            polyNavAgent.map     = navMesh;
            polyNavAgent.enabled = true;
        }

        Destroy(studentToEnroll.gameObject);
        StartCoroutine(RefreshAfterUpdate());
        OnEnrolledStudentChange(GetEnrolledStudentCount());
    }
コード例 #7
0
        public StudentStats StudentStats(int classGroupId, int studentId)
        {
            try
            {
                LoginController.checkOnAccess(this.Request.Headers);
            }
            catch (Exception ex)
            {
                throw ex;
            };

            var          db     = new DBModel();
            StudentStats sStats = new StudentStats
            {
                RDist = new List <LessonResDistribution>()
            };

            try
            {
                //Get all the records of the results in the class grouped by lesson, then grouped by student
                var results = from lc in db.LessonsToClasses
                              where lc.ClassId == classGroupId
                              join l in db.Lessons on lc.LessonId equals l.Id
                              join rl in db.ResultInLessons on l.Id equals rl.LessonId
                              where rl.StudentId == studentId
                              group rl by l.SeqNum into lRes
                              select lRes;

                if (results.Any())
                {
                    /*------------------------------------------------------------------------------------------
                     *                                 Lesson Results Distribution
                     *------------------------------------------------------------------------------------------*/
                    //Loop through each lesson and assign results
                    foreach (var lesson in results)
                    {
                        sStats.RDist.Add(new LessonResDistribution
                        {
                            LNum    = lesson.Key,
                            AvgRes  = lesson.Average(x => x.Result),
                            BestRes = lesson.Max(x => x.Result)
                        });
                    }
                    ;

                    //Adding empty lessons objects to fill up the list to 4
                    for (int i = sStats.RDist.Count; i < NUM_OF_LESSONS_IN_CLASS; i++)
                    {
                        sStats.RDist.Add(new LessonResDistribution()
                        {
                            LNum    = i + 1,
                            AvgRes  = 0,
                            BestRes = 0
                        });
                    }
                    ;

                    /*-------------------------------------------------------------------------------------------
                    *                               Course average result
                    *------------------------------------------------------------------------------------------*/
                    sStats.AvgRes = (from pc in db.ProgressInClasses
                                     where pc.ClassId == classGroupId && pc.StudentId == studentId
                                     select pc.Result).FirstOrDefault();
                }

                else
                {
                    sStats.AvgRes = 0;
                };

                return(sStats);
            }
            catch (Exception ex)
            {
                throw ex;
            };
        }