Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        if (MyEntityId.IsNullId)
        {
            MyEntityId = new EntityId(1, Random.Range(0, 9999), (ushort)Random.Range(0, 255));
        }

        if (ReflectedEntities == null)
        {
            ReflectedEntities = FindObjectOfType <ReflectedEntities>();
        }
        if (IgnoreSelf)
        {
            ReflectedEntities.AddToIgnore(MyEntityId);
        }
        if (ExerciseConnection == null)
        {
            ExerciseConnection = FindObjectOfType <ExerciseConnection>();
        }
        entityPublisher = ExerciseConnection.CreateEntityPublisher(
            this, PlayerEntityType,
            publishLocation, publishHeading, publishPitch, publishRoll, publishVelocity);

        SetPrimaryWeaponState(WeaponState.WeaponDeployed);
    }
    IEnumerator Start()
    {
        for (int i = 0; i < UnityEngine.SceneManagement.SceneManager.sceneCount; i++)
        {
            UnityEngine.SceneManagement.Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i);
            if (scene.name == "Infantry")
            {
                DeployedInInfantryScene = true;
            }
        }
        while (!gameObject.scene.isLoaded)
        {
            yield return(null);
        }
        yield return(null);

        ExerciseConnection  = FindObjectOfType <ExerciseConnection>();
        EventReportsManager = ExerciseConnection.GetComponent <EventReportsManager>();
        yield return(new WaitForSeconds(0.5f));

        if (EventReportsManager != null)
        {
            EventReportsManager.Subscribe <DeployFoldDevice>(DeployFoldDeviceCallback);
        }

        ReflectedEntities = ExerciseConnection.GetComponent <ReflectedEntities>();

        StartCoroutine(FindOperatorEntityId());
    }
      public void GetTime(Object source, ElapsedEventArgs e)
      {
          string timeString = ExerciseConnection.secondsTommss(this.Time);

          ExerciseConnection.SendTimeBike(timeString, MachineName);
          ExerciseConnection.SendTimeDoctor(timeString, MachineName);
          this.Time--;
      }
Beispiel #4
0
 public override void Event(Context context)
 {
     Console.WriteLine("In finished state");
     base.AllowData = false;
     ExerciseConnection.SendTimeBike("00:00", MachineName);
     ExerciseConnection.SendTimeDoctor("00:00", MachineName);
     base.ExerciseConnection.SendChangeTime("0000", base.MachineName);
     base.ExerciseConnection.SendInfoDoctor("De test is afgelopen!", base.MachineName, 1);
     base.ExerciseConnection.SendInfoBike("De test is afgelopen!", 1);
     base.ExerciseConnection.sendChangePower(25, base.MachineName);
 }
      public override void ChangeSession(object source, ElapsedEventArgs e)
      {
          Console.WriteLine("CHANGING THE SESSION");
          this.TimerInfo.Stop();
          this.PulseTimer.Stop();
          this.Timer.Stop();
          this.BuildToTargetTimer.Stop();
          //Check if the steady state is reached if yes it goes to the else, otherwise the training state will take 2 min longer.
          if (CheckValues() && RetrySteadyState)
          {
              Console.WriteLine("AVERAGE IS TOO LOW");
              this.PulseMinute         = new List <int>();
              this.PulseSecond         = new List <int>();
              this.PulseTimer          = new Timer(15000);
              this.Timer               = new Timer(120000);
              this.Timer.Elapsed      += new ElapsedEventHandler(ChangeSession);
              this.Timer.Enabled       = true;
              this.PulseTimer.Elapsed += new ElapsedEventHandler(DataRetriever);
              this.PulseTimer.Enabled  = true;

              this.RetrySteadyState = false;
              base.ExerciseConnection.SendChangeTime("0400", base.MachineName);
              this.Time = 120;
              this.TimerInfo.Start();
              this.Timer.Start();
              this.PulseTimer.Start();
              base.ExerciseConnection.SendInfoDoctor("De steady state is niet gehaald, de training gaat door met een extra 2 minuten!", base.MachineName, 1);
              base.ExerciseConnection.SendInfoBike("De steady state is niet gehaald, de training gaat door met een extra 2 minuten", 1);
          }
          else if (CheckValues())
          {
              base.ExerciseConnection.WriteSessionToFile(this.Session);
              base.ExerciseConnection.SendInfoDoctor($"Er kan geen Vo2Max berekend worden, het verschil tussen de hartslag was te groot. Max hartslag: {this.PulseSecond.Min()} Min hartslag {this.PulseSecond.Max()}", base.MachineName, 1);
              base.ExerciseConnection.SendInfoBike($"Er kan geen Vo2Max berekend worden, het verschil tussen de hartslag was te groot. Max hartslag: {this.PulseSecond.Min()} Min hartslag {this.PulseSecond.Max()}", 1);
              this.Context.State = new CoolDownState(base.ExerciseConnection.BikeStream, base.ExerciseConnection.DoctorStream, base.Patient, base.MachineName);
              this.Context.Request();
              Console.WriteLine(DateTime.Now + " Changed To Cooldown");
          }
          else
          {
              ExerciseConnection.SendVo2(CalculateVO2Max(PulseSecond.Average()), MachineName);
              this.Session.VO2 = CalculateVO2Max(PulseSecond.Average());
              base.ExerciseConnection.WriteSessionToFile(this.Session);
              Console.WriteLine("MINUTE: " + this.PulseMinute.Count);
              Console.WriteLine("SECOND: " + this.PulseSecond.Count);
              Console.WriteLine(CalculateVO2Max(PulseSecond.Average()));

              this.Context.State = new CoolDownState(base.ExerciseConnection.BikeStream, base.ExerciseConnection.DoctorStream, base.Patient, base.MachineName);
              this.Context.Request();
              Console.WriteLine(DateTime.Now + " Changed To Cooldown");
          }
      }
Beispiel #6
0
    private void Start()
    {
        exerciseConnection = FindObjectOfType <ExerciseConnection>();
        reflectedEntity    = GetComponent <ReflectedEntity>();

        if (exerciseConnection == null || reflectedEntity == null)
        {
            Destroy(this);
        }

        entityId = reflectedEntity.EntityId;
        exerciseConnection.SubscribeFireInteraction(FireInteractionHandler);
    }
Beispiel #7
0
 void OnDestroy()
 {
     if (null == ExerciseConnection)
     {
         ExerciseConnection = FindObjectOfType <ExerciseConnection>();
     }
     if (null != ExerciseConnection)
     {
         ExerciseConnection.RemovePublishedEntity(this);
     }
     if (entityPublisher != null)
     {
         entityPublisher.Destroy();
     }
 }
 public void Init(ExerciseConnection ExerciseConnection, FireInteraction Fire)
 {
     if (!ShowOnLocal)
     {
         foreach (PublishedEntity entity in ExerciseConnection.LocalPublishedEntities)
         {
             if (entity.MyEntityId == Fire.attacker)
             {
                 Destroy(gameObject);
                 return;
             }
         }
     }
     rigidbody          = GetComponent <Rigidbody>();
     rigidbody.velocity = Fire.linVelocity;
     Destroy(gameObject, 12);
 }
 /// <summary>
 /// Looks for the relevant references when adding this script to the scene/using the Reset option
 /// </summary>
 void Reset()
 {
     // TerrainLoader = FindObjectOfType<TerrainLoader>();
     ExerciseConnection = FindObjectOfType<ExerciseConnection>();
     NightLoader = FindObjectOfType<NightLoader>();
     TerrainLoaderFull = FindObjectOfType<TerrainLoader_Full>();
     TerrainLoaderDynamic = FindObjectOfType<TerrainLoader_Dynamic>();
     SetEditorConfig(true, new Configuration()
     {
         ExerciseId = ExerciseConnection ? ExerciseConnection.exerciseId : 0,
         FullTerrain = true,
         ImprovedTerrain = TerrainLoaderFull.ImprovedTerrain,
         ImprovedTerrainBundlePath = TerrainLoaderFull.ImprovedTerrainBundlePath,
         LoadingRadius = TerrainLoaderDynamic.DynamicLoadingRadius,
         NightMode = NightLoader.Mode.DayOnly,
         OriginalsBundlePath = TerrainLoaderDynamic.TerrainOriginalsBundlePath,
         TerrainPath = TerrainLoaderFull.TerrainBundlePath
     });
 }
 void Reset()
 {
     ExerciseConnection = FindObjectOfType <ExerciseConnection>();
 }
        override protected void ApplyConfiguration(bool GotConfiguration)
        {
            //Try finding references
            if (!ExerciseConnection)
                ExerciseConnection = FindObjectOfType<ExerciseConnection>();
            if (!NightLoader)
                NightLoader = FindObjectOfType<NightLoader>();
            if (!TerrainLoaderFull)
                TerrainLoaderFull = FindObjectOfType<TerrainLoader_Full>();
            if (!TerrainLoaderDynamic)
                TerrainLoaderDynamic = FindObjectOfType<TerrainLoader_Dynamic>();

            //Load command line arguments as overrides
            PutArg("FullTerrain", ref Config.FullTerrain, "FullTerrain");
            PutArg("LoadingRadius", ref Config.LoadingRadius, "LoadingRadius");
            PutArg("ImprovedTerrain", ref Config.ImprovedTerrain, "ImprovedTerrain");
            PutArg("TerrainPath", ref Config.TerrainPath, "TerrainPath");
            PutArg("NavMeshBundlePath", ref Config.TerrainPath, "NavMeshBundlePath");
            PutArg("ImprovedTerrainBundlePath", ref Config.ImprovedTerrainBundlePath, "ImprovedTerrainBundlePath");
            PutArg("ExerciseId", ref Config.ExerciseId, "ExerciseId");
            PutArg("NightMode", ref Config.NightMode, EnumParser<NightLoader.Mode>(), "NightMode");

            //forces improved terrain on TerrainName
            if (GotConfiguration && null != Config.TerrainPath)
            {
                string lowerTerrainPath = Config.TerrainPath.ToLower();
                if (lowerTerrainPath.Contains("terrainname"))
                    Config.ImprovedTerrain = true;
            }

            //Apply ExerciseId
            if (ExerciseConnection)
                TryApplyTo(Config.ExerciseId, ref ExerciseConnection.exerciseId, "ExerciseId");

            //Override if in editor
            if (Application.isEditor)
                Config.FullTerrain = FullTerrain;
            
            //Apply terrain values, destroy the loader that wasn't picked 
            if (Config.FullTerrain)
            {
                Destroy(TerrainLoaderDynamic);
                TerrainLoader.Instance = TerrainLoaderFull;

                TryApplyTo(Config.ImprovedTerrain, ref TerrainLoaderFull.ImprovedTerrain, "ImprovedTerrain");
            }
            else
            {
                Destroy(TerrainLoaderFull);
                TerrainLoader.Instance = TerrainLoaderDynamic;

                TryApplyTo(Config.LoadingRadius, ref TerrainLoaderDynamic.DynamicLoadingRadius, "LoadingRadius");
                TryApplyTo(Config.ImprovedTerrain, ref TerrainLoaderDynamic.ImprovedTerrain, "ImprovedTerrain");
            }
            //apply NightMode, add "_night" to terrain path
            if (NightLoader && WasConfigured("NightMode"))
            {
                /*switch (Config.NightMode)
                {
                    case "DayOnly":
                    {
                        NightLoader.NightLoadingMode = NightLoader.Mode.DayOnly;
                        break;
                    }
                    case "NightOnly":
                    {
                        if (!Config.TerrainPath.EndsWith("_night"))
                            Config.TerrainPath += "_night";
                        NightLoader.NightLoadingMode = NightLoader.Mode.NightOnly;
                        break;
                    }
                    case "Dual":
                    {
                        NightLoader.NightLoadingMode = NightLoader.Mode.Dual;
                        break;
                    }
                }*/
                NightLoader.NightLoadingMode = Config.NightMode;
            }

            //Apply paths
            if (TerrainLoader.Instance)
            {
                TryApplyTo(Config.TerrainPath, ref TerrainLoader.Instance.TerrainBundlePath, "TerrainPath");
                TryApplyTo(Config.NavMeshBundlePath, ref TerrainLoader.Instance.NavMeshBundlePath, "NavMeshBundlePath");
                TryApplyTo(Config.ImprovedTerrainBundlePath, ref TerrainLoader.Instance.ImprovedTerrainBundlePath, "ImprovedTerrainBundlePath");

                if (!Config.FullTerrain)
                {
                    PutArg("OriginalsBundlePath", ref Config.OriginalsBundlePath, "OriginalsBundlePath");
                    TryApplyTo(Config.OriginalsBundlePath, ref TerrainLoaderDynamic.TerrainOriginalsBundlePath, "OriginalsBundlePath");
                }
            }

        }