private void OnFeedbackReceived(FeedbackObject o)
 {
     if (FeedbackReceived != null)
     {
         FeedbackReceived(o);
     }
 }
 private void OnFeedbackCancelled(FeedbackObject o)
 {
     if (FeedbackCancelled != null)
     {
         FeedbackCancelled(o);
     }
 }
    public void DealDamage(IDamageReceiver damageReceiver, DamagesParameters damagesParameters)
    {
        damageReceiver.ReceiveDamage(this, damagesParameters, relatedProjectile.GetProjectileSpecialParameters);

        if (relatedProjectile.GetProjectileSpecialParameters.GetPiercingParameters.GetNumberOfPiercing > 0)
        {
            relatedProjectile.GetProjectileSpecialParameters.GetPiercingParameters.DecreamentPiercing();

            FeedbackObject woodProjection = GameManager.gameManager.PoolManager.GetFeedbackObject(FeedbackObjectPoolTag.WoodDestruction, PoolInteractionType.GetFromPool);
            if (woodProjection != null)
            {
                woodProjection.transform.position = transform.position;
                woodProjection.StartFeedback(2, 0.2f, specialSound);
            }
        }
        else if (relatedProjectile.GetProjectileSpecialParameters.GetSkeweringParameters.Skewering)
        {
            FeedbackObject woodProjection = GameManager.gameManager.PoolManager.GetFeedbackObject(FeedbackObjectPoolTag.WoodDestruction, PoolInteractionType.GetFromPool);
            if (woodProjection != null)
            {
                woodProjection.transform.position = transform.position;
                woodProjection.StartFeedback(2, 0.2f, specialSound);
            }
        }
        else
        {
            relatedProjectile.ExplodeOnContact();
        }
    }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            //cancel clicked
            IsOpen = false;
            FeedbackObject feedObject = new FeedbackObject(tbFacultyName.Text, tbCourseName.Text, 0, string.Empty);

            OnFeedbackCancelled(feedObject);
        }
    public void ReturnFeedbackObject(FeedbackObject fdbckObj)
    {
        if (!feedbackObjectsPoolsDisctionary.ContainsKey(fdbckObj.GetFeedbackPoolTag))
        {
            return;
        }

        feedbackObjectsPoolsDisctionary[fdbckObj.GetFeedbackPoolTag].AddObjectInPool(fdbckObj);
    }
 public void Die()
 {
     foreach (Transform pos in particlesPositions)
     {
         FeedbackObject onDestroyFeedbackObject = GameManager.gameManager.PoolManager.GetFeedbackObject(onDestroyParticleType, PoolInteractionType.GetFromPool);
         onDestroyFeedbackObject.gameObject.SetActive(true);
         onDestroyFeedbackObject.transform.position = pos.position;
         onDestroyFeedbackObject.StartFeedback(transform.localScale.x * particlesSize, soundVolume);
     }
     Destroy(gameObject);
 }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (rating.Value == 0)
            {
                await(new MessageDialog("Rating cannot be zero", "Error")).ShowAsync();
                return;
            }

            //submit clicked
            FeedbackObject feedObject = new FeedbackObject(tbFacultyName.Text,
                                                           tbCourseName.Text, rating.Value, tbComments.Text);

            IsOpen = false;
            OnFeedbackReceived(feedObject);
        }
        public MainWindow()
        {
            InitializeComponent();
            workingDirectory = Directory.GetCurrentDirectory();
            lastFeedbackSent = new FeedbackObject(DateTime.Now, "", "");
            myApps           = new List <ApplicationClass>();
            myEnabledApps    = new List <ApplicationClass>();

            myFeedbacks = new List <FeedbackApp>();
            myLAApps    = new List <LAApplication>();
            SetAppsTable();
            Loaded += MainWindow_Loaded;

            //System.Diagnostics.Process.Start(@"C:\Users\jan\source\repos\LearningHub\HubDesktop\bin\Debug\restart.bat");

            Closing += MainWindow_Closing;
        }
 private void Update()
 {
     if (Input.touchCount > 3)
     {
         if (!started)
         {
             started = true;
             FeedbackObject obj = GameManager.gameManager.PoolManager.GetFeedbackObject(testTag, PoolInteractionType.GetFromPool);
             obj.gameObject.SetActive(true);
             obj.transform.position = transform.position;
             //obj.StartFeedback();
         }
     }
     else
     {
         started = false;
     }
 }
        public async void HandleFeedback(string feedback)
        {
            foreach (FeedbackApp fapp in myFeedbacks)
            {
                fapp.SendUDP(feedback);
            }
            try
            {
                FeedbackObject feed = JsonConvert.DeserializeObject <FeedbackObject>(feedback);

                if (feed.verb.Equals(lastFeedbackSent.verb))
                {
                }
                else if (feed.verb.Contains("Good"))
                {
                    XAPIStuff.XAPIActor           actor    = new XAPIStuff.XAPIActor("id_" + lastFeedbackSent.applicationName, "application", lastFeedbackSent.applicationName);
                    XAPIStuff.XAPIVerb            verb     = new XAPIStuff.XAPIVerb("id", lastFeedbackSent.verb);
                    XAPIStuff.XAPIObject          myObject = new XAPIStuff.XAPIObject("student", "id_student");
                    XAPIStuff.XAPIDurationContext duration = new XAPIStuff.XAPIDurationContext(feed.frameStamp.Subtract(lastFeedbackSent.frameStamp));
                    XAPIStuff.XAPIContext         context  = new XAPIStuff.XAPIContext(duration);

                    XAPIStuff.XAPIStatement myStatement = new XAPIStuff.XAPIStatement(actor, verb, myObject, context);

                    string xapiString = JsonConvert.SerializeObject(myStatement, Newtonsoft.Json.Formatting.Indented);

                    try
                    {
                        foreach (LAApplication myLA in myLAApps)
                        {
                            string         url      = myLA.Path + xapiString;
                            HttpWebRequest request  = (HttpWebRequest)WebRequest.Create(url);
                            WebResponse    response = await request.GetResponseAsync();

                            Stream       resStream = response.GetResponseStream();
                            StreamReader sr99      = new StreamReader(resStream);
                            string       aa        = await sr99.ReadToEndAsync();
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        Console.WriteLine("error trying to post to server");
                    }
                    lastFeedbackSent = feed;
                }
                else
                {
                    lastFeedbackSent = feed;
                }
            }
            catch
            {
            }

            Dispatcher.Invoke(() =>
            {
                try
                {
                    myRecordingInterface.LabelFeedback.Content = feedback;
                }
                catch
                {
                }
            });
        }
Exemple #11
0
    public void SetRammingKnockback(Collision collision, ICollisionReceiver hitCollisionReceiver)
    {
        #region Calculates Redirection and Knockback
        Vector3 knockbackVector   = relatedShip.GetShipVelocity.normalized;
        Vector3 redirectionVector = hitCollisionReceiver.GetMovementDirection();

        Vector3 hitObjectDirection = Quaternion.Euler(-collision.transform.rotation.eulerAngles) * hitCollisionReceiver.GetMovementDirection();

        Vector3 hitNormal   = new Vector3();
        Vector3 hitPosition = new Vector3();
        Vector3 worldHitPosition;
        int     counter = 0;

        foreach (ContactPoint contact in collision.contacts)
        {
            hitNormal   += contact.normal;
            hitPosition += contact.point;
            counter++;
        }

        #region V1
        Vector3 hitObjectCenter = collision.collider.bounds.center;

        hitNormal /= counter;
        hitNormal  = Quaternion.Euler(-collision.transform.rotation.eulerAngles) * hitNormal;

        hitPosition     /= counter;
        worldHitPosition = hitPosition;
        hitPosition      = Quaternion.Euler(-collision.transform.rotation.eulerAngles) * (hitPosition - hitObjectCenter);

        float semiLenght = collision.collider.bounds.extents.z;
        float semiWidht  = collision.collider.bounds.extents.x;

        if (Mathf.Abs(Vector3.Dot(hitNormal, hitObjectDirection)) < 0.5f)
        {
            //latéral
            if (hitPosition.x > 0)
            {
                //par la droite
                if (hitPosition.z > 0)
                {
                    //à l'avant
                    if (Vector3.Dot(GetMovementDirection(), hitCollisionReceiver.GetMovementDirection()) > -0.45f)
                    {
                        knockbackVector   = -hitCollisionReceiver.GetMovementDirection();
                        redirectionVector = ((-hitCollisionReceiver.GetMovementDirection().normalized + hitCollisionReceiver.GetMovementDirection().GetLeftOrthogonalVectorXZ().normalized) / 2).normalized;
                        //Debug.Log("pas exception");
                    }
                    else if (Vector3.Dot(GetMovementDirection(), hitCollisionReceiver.GetMovementDirection()) < 0f)
                    {
                        knockbackVector   = hitCollisionReceiver.GetMovementDirection().GetLeftOrthogonalVectorXZ();
                        redirectionVector = ((hitCollisionReceiver.GetMovementDirection().normalized + hitCollisionReceiver.GetMovementDirection().GetLeftOrthogonalVectorXZ().normalized) / 2).normalized;
                        //Debug.Log("exception");
                    }
                    //Debug.Log("latéral avant droit");
                }
                else
                {
                    //à l'arrière
                    if (Vector3.Dot(GetMovementDirection(), hitCollisionReceiver.GetMovementDirection()) < 0.75f)
                    {
                        knockbackVector   = hitCollisionReceiver.GetMovementDirection();
                        redirectionVector = ((hitCollisionReceiver.GetMovementDirection().normalized + hitCollisionReceiver.GetMovementDirection().GetRightOrthogonalVectorXZ().normalized) / 2).normalized;
                        //Debug.Log("pas exception");
                    }
                    else
                    {
                        knockbackVector   = hitCollisionReceiver.GetMovementDirection().GetLeftOrthogonalVectorXZ();
                        redirectionVector = ((hitCollisionReceiver.GetMovementDirection().normalized + hitCollisionReceiver.GetMovementDirection().GetLeftOrthogonalVectorXZ().normalized) / 2).normalized;
                        //Debug.Log("exception");
                    }
                    //Debug.Log("latéral arrière droit");
                }
            }
            else
            {
                //par la gauche
                if (hitPosition.z > 0)
                {
                    //à l'avant
                    if (Vector3.Dot(GetMovementDirection(), hitCollisionReceiver.GetMovementDirection()) > -0.45f)
                    {
                        knockbackVector   = -hitCollisionReceiver.GetMovementDirection();
                        redirectionVector = ((-hitCollisionReceiver.GetMovementDirection().normalized + hitCollisionReceiver.GetMovementDirection().GetRightOrthogonalVectorXZ().normalized) / 2).normalized;
                        //Debug.Log("pas exception");
                    }
                    else
                    {
                        knockbackVector   = hitCollisionReceiver.GetMovementDirection().GetRightOrthogonalVectorXZ();
                        redirectionVector = ((hitCollisionReceiver.GetMovementDirection().normalized + hitCollisionReceiver.GetMovementDirection().GetRightOrthogonalVectorXZ().normalized) / 2).normalized;
                        //Debug.Log("exception");
                    }
                    //Debug.Log("latéral avant gauche");
                }
                else
                {
                    //à l'arrière
                    if (Vector3.Dot(GetMovementDirection(), hitCollisionReceiver.GetMovementDirection()) < 0.75f)
                    {
                        knockbackVector   = hitCollisionReceiver.GetMovementDirection();
                        redirectionVector = ((hitCollisionReceiver.GetMovementDirection().normalized + hitCollisionReceiver.GetMovementDirection().GetLeftOrthogonalVectorXZ().normalized) / 2).normalized;
                        //Debug.Log("pas exception");
                    }
                    else
                    {
                        knockbackVector   = hitCollisionReceiver.GetMovementDirection().GetRightOrthogonalVectorXZ();
                        redirectionVector = ((hitCollisionReceiver.GetMovementDirection().normalized + hitCollisionReceiver.GetMovementDirection().GetRightOrthogonalVectorXZ().normalized) / 2).normalized;
                        //Debug.Log("exception");
                    }
                    //Debug.Log("latéral arrière gauche");
                }
            }
        }
        else
        {
            //avant ou arrière
            if (hitPosition.x > 0)
            {
                // sur la droite
                //knockbackVector = ((hitCollisionReceiver.GetMovementDirection().normalized + hitCollisionReceiver.GetMovementDirection().GetLeftOrthogonalVectorXZ().normalized) / 2).normalized;
                knockbackVector   = hitCollisionReceiver.GetMovementDirection().GetLeftOrthogonalVectorXZ().normalized;
                redirectionVector = ((hitCollisionReceiver.GetMovementDirection().normalized + hitCollisionReceiver.GetMovementDirection().GetLeftOrthogonalVectorXZ().normalized) / 2).normalized;
                //Debug.Log("frontal droite");
            }
            else
            {
                // sur la gauche
                //knockbackVector = ((hitCollisionReceiver.GetMovementDirection().normalized + hitCollisionReceiver.GetMovementDirection().GetRightOrthogonalVectorXZ().normalized) / 2).normalized;
                knockbackVector   = hitCollisionReceiver.GetMovementDirection().GetRightOrthogonalVectorXZ().normalized;
                redirectionVector = ((hitCollisionReceiver.GetMovementDirection().normalized + hitCollisionReceiver.GetMovementDirection().GetRightOrthogonalVectorXZ().normalized) / 2).normalized;
                //Debug.Log("frontal gauche");
            }
        }
        #endregion

        #endregion

        DealKnockback(hitCollisionReceiver, relatedShip.ShipMvt.GetCurrentRammingParameters.GetInflictedKnockbackParameters, knockbackVector, redirectionVector);

        ReceiveKnockback(this, relatedShip.ShipMvt.GetCurrentRammingParameters.GetSustainedKnockbackParametersOnImpact, -relatedShip.GetShipVelocity.normalized, relatedShip.GetShipVelocity.normalized);

        #region Feedback
        if (waitBeforeRammingFeedback)
        {
            return;
        }

        if ((relatedShip as EnemyShip != null && collision.gameObject.GetComponent <PlayerShip>() != null) /* || (relatedShip as PlayerShip != null && collision.gameObject.GetComponent<EnemyShip>() != null)*/)
        {
            GameManager.gameManager.SlwMoManager.SetSlowMo(relatedShip.ShipMvt.GetCurrentRammingParameters.GetSlowMoParameters);
        }

        GameManager.gameManager.ScrshkManager.StartScreenshake(relatedShip.ShipMvt.GetCurrentRammingParameters.GetScreenshakeParameters);

        FeedbackObject woodProjection = GameManager.gameManager.PoolManager.GetFeedbackObject(FeedbackObjectPoolTag.WoodDestruction, PoolInteractionType.GetFromPool);
        if (woodProjection != null)
        {
            woodProjection.transform.position = worldHitPosition;
            woodProjection.StartFeedback(2, 0.2f);
        }
        StartCoroutine(WaitBeforeReplayRammingFeedback());
        #endregion
    }
Exemple #12
0
        /// <summary>
        /// ShowDashboard is the default action for a student. It collects the information
        /// that is relevant for the logged in student for the current date.
        /// </summary>
        /// <returns></returns>
        public ActionResult ShowDashboard(int?assignmentDocId)
        {
            ApplicationUser currentUser = db.Users
                                          .Where(u => u.UserName == User.Identity.Name)
                                          .FirstOrDefault();

            DashboardVM dashboard = new DashboardVM();

            dashboard.FilterHandIns = false;

            string activityType = " ";

            var courseId = currentUser.CourseId;

            var course = db.Courses.Find(courseId);

            var currentDate = DateTime.Now;

            dashboard.CourseName     = course.Name;
            dashboard.StudentName    = currentUser.FirstName + " " + currentUser.LastName;
            dashboard.TodaysDate     = currentDate;
            dashboard.ModuleExists   = true;
            dashboard.ActivityExists = true;

            List <Activity> activities = new List <Activity>();

            var module = db.Modules.Where(c => c.CourseId == courseId)
                         .Where(s => s.StartDate <= currentDate)
                         .Where(e => e.EndDate >= currentDate)
                         .FirstOrDefault();

            if (module != null)
            {
                dashboard.ModuleName = module.Name;

                var moduleId = module.Id;

                activities = db.Activities.Where(m => m.ModuleId == moduleId)
                             .ToList();

                List <Activity> dashboardActivities = new List <Activity>();

                //Filter for activities valid for the current date only
                if (activities != null)
                {
                    foreach (var item in activities)
                    {
                        if (item.StartDate.ToString("yyyy-MM-dd") == currentDate.ToString("yyyy-MM-dd"))
                        {
                            dashboardActivities.Add(item);
                        }
                    }
                }

                if (dashboardActivities.Count > 0)
                {
                    List <string> typenames = new List <string>();
                    foreach (var item in dashboardActivities)
                    {
                        //The following is only needed if activities are allowed to span more than one day. Not yet implemented.
                        //Check if the start date of the activity is less than the current date. If it is the set start time = 8:30.
                        //Check if the end date of the activity is greater than the current date. If it is the set end time = 17:00.

                        //Read activity type names into a List of strings
                        activityType = db.ActivityTypes.Find(item.ActivityTypeId).TypeName;
                        typenames.Add(activityType);
                    }
                    dashboard.ActivitiesForTodayList    = dashboardActivities;
                    dashboard.ActivityTypesForTodayList = typenames;
                }
                else
                {
                    dashboard.ActivityExists = false;
                }
            }
            else
            {
                dashboard.ModuleExists   = false;
                dashboard.ActivityExists = false;
            }

            //The code below populates the viewmodel properties related to documents
            //Check if the course has any documents

            var otherDocuments = new List <Document>();
            var assignmentDescriptionsAndRowEmphasis = new List <AssignmentAndRowEmphasis>();
            var handIns       = new List <Document>();
            var feedbacksList = new List <FeedbackObject>();

            if (course.Documents != null)
            {
                otherDocuments = course.Documents;
            }

            //Find current or past modules with documents
            var modulesUpToThisDate = db.Modules.Where(c => c.CourseId == courseId)
                                      .Where(s => s.StartDate <= currentDate)
                                      .ToList();

            foreach (var item in modulesUpToThisDate)
            {
                if (item.Documents != null)
                {
                    foreach (var document in item.Documents)
                    {
                        otherDocuments.Add(document);
                    }
                }
            }

            //Find curent or past activities with documents
            //First find all current and passed modules
            var modules = db.Modules.Where(c => c.CourseId == courseId)
                          .Where(s => s.StartDate <= currentDate)
                          .ToList();

            //Then, among the found modules, find all activities uo to this date with documents
            if (modules != null)
            {
                foreach (var item in modules)
                {
                    if (item.Activities != null)
                    {
                        foreach (var activity in item.Activities)
                        {
                            if (activity.Documents != null)
                            {
                                foreach (var document in activity.Documents)
                                {
                                    //Activity Descriptions
                                    if (document.PurposeId == 4)
                                    {
                                        otherDocuments.Add(document);
                                    }
                                    //Assignment Descriptions
                                    if (document.PurposeId == 5)
                                    {
                                        var assignmentAndEmphasisObject = new AssignmentAndRowEmphasis();
                                        assignmentAndEmphasisObject.AssignmentDescription = document;

                                        //Add logic here to decide the type of emphasis, for now everything will be "danger"
                                        if (DateTime.Now.Date.AddDays(2) >= document.DeadLine)
                                        {
                                            assignmentAndEmphasisObject.RowEmphasis = "warning";
                                        }
                                        else if (DateTime.Now.Date > document.DeadLine)
                                        {
                                            assignmentAndEmphasisObject.RowEmphasis = "danger";
                                        }

                                        assignmentDescriptionsAndRowEmphasis.Add(assignmentAndEmphasisObject);
                                    }
                                    //Assignment Descriptions
                                    if (document.PurposeId == 6)
                                    {
                                        otherDocuments.Add(document);
                                    }
                                    //Hand-ins
                                    if (document.PurposeId == 7 && document.Owner == currentUser)
                                    {
                                        if (assignmentDocId != null && assignmentDocId != 0)
                                        {
                                            dashboard.FilterHandIns = true;
                                            //Filtered on Assignment Description
                                            if (document.AssignmentDocId == assignmentDocId)
                                            {
                                                handIns.Add(document);
                                                dashboard.AssignmentDescriptionFilename = db.Documents.Where(d => d.Id == assignmentDocId).FirstOrDefault().Filename;
                                            }
                                        }
                                        else
                                        {
                                            handIns.Add(document);
                                        }
                                        //Look for any feedback to this document
                                        var            feedback       = db.FeedBacks.Where(d => d.DocumentId == document.Id).FirstOrDefault();
                                        FeedbackObject feedbackObject = new FeedbackObject();
                                        if (feedback != null)
                                        {
                                            feedbackObject.FeedbackExists = true;
                                            feedbackObject.FeedbackId     = feedback.Id;
                                        }
                                        else
                                        {
                                            feedbackObject.FeedbackExists = false;
                                        }
                                        feedbacksList.Add(feedbackObject);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (otherDocuments != null)
            {
                dashboard.OtherDocuments = otherDocuments;
            }
            else
            {
                dashboard.OtherDocuments = null;
            }

            if (assignmentDescriptionsAndRowEmphasis != null)
            {
                dashboard.AssignmentDescriptionAndEmphasis = assignmentDescriptionsAndRowEmphasis;
            }
            else
            {
                dashboard.AssignmentDescriptionAndEmphasis = null;
            }

            if (handIns != null)
            {
                dashboard.HandIns = handIns;
            }
            else
            {
                dashboard.HandIns = null;
            }
            if (feedbacksList != null)
            {
                dashboard.FeedbackList = feedbacksList;
            }
            else
            {
                dashboard.FeedbackList = null;
            }

            return(View("Dashboard", dashboard));
        }
Exemple #13
0
    public void Die()
    {
        OnDeath?.Invoke(this);

        ArenaManager arenaManager = ArenaManager.arenaManager;

        EnemyLootCrate lootCrate = lootManager.GenerateEnemyLootCrate();

        if (lootCrate != null)
        {
            lootCrate.transform.position = transform.position;
            lootCrate.SetUpFloatingMove();

            if (arenaManager != null)
            {
                arenaManager.DropManager.AddDropCrate(lootCrate);
            }
        }


        if (objectCollider != null)
        {
            objectCollider.enabled = false;
        }
        else if (GetComponent <Collider>() != null)
        {
            GetComponent <Collider>().enabled = false;
        }


        if (particlesToPlay != null)
        {
            particlesToPlay.Play();
        }

        foreach (Transform tr in woodProjectionPositions)
        {
            FeedbackObject woodProjection = GameManager.gameManager.PoolManager.GetFeedbackObject(FeedbackObjectPoolTag.WoodDestruction, PoolInteractionType.GetFromPool);
            if (woodProjection != null)
            {
                woodProjection.transform.position = tr.position;
                woodProjection.StartFeedback(2, 0.2f);
            }
        }

        if (particlesToPlay == null && woodProjectionPositions.Length == 0)
        {
            FeedbackObject woodProjection = GameManager.gameManager.PoolManager.GetFeedbackObject(FeedbackObjectPoolTag.WoodDestruction, PoolInteractionType.GetFromPool);
            if (woodProjection != null)
            {
                woodProjection.transform.position = transform.position;
                woodProjection.StartFeedback(2, 0.2f);
            }
        }


        if (targetAudioSource != null)
        {
            targetAudioSource.PlaySound(soundToPlayOnDestroy);
        }


        if (objectRenderer != null)
        {
            objectRenderer.enabled = false;
        }

        foreach (GameObject obj in objectRenderers)
        {
            obj.SetActive(false);
        }

        if (objectRenderer == null && objectRenderers.Length == 0)
        {
            Destroy(gameObject);
        }
    }