Ejemplo n.º 1
0
    public BotConstant(string config)
    {
        //read the config
        MemoryStream memStream = new MemoryStream();
        StreamWriter strWriter = new StreamWriter(memStream);

        strWriter.Write(config);
        strWriter.Flush();
        memStream.Position = 0;
        DataContractJsonSerializer playerSerializer = new DataContractJsonSerializer(typeof(BotConstantConfig));
        BotConstantConfig          botCfg           = (BotConstantConfig)playerSerializer.ReadObject(memStream);

        thisErg              = new EasyErgsocket.Erg();
        thisErg.cadence      = botCfg.spm;
        thisErg.calories     = 1;
        thisErg.distance     = 0.0;
        thisErg.ergtype      = EasyErgsocket.ErgType.ROW;
        thisErg.exerciseTime = 10.0;
        thisErg.heartrate    = 0;
        thisErg.name         = botCfg.name;
        thisErg.paceInSecs   = botCfg.pace;
        thisErg.playertype   = EasyErgsocket.PlayerType.BOT;
        thisErg.power        = 0;
        thisErg.ergId        = botCfg.name;

        originalPace = thisErg.paceInSecs;
    }
Ejemplo n.º 2
0
 public void UpdateStats(EasyErgsocket.Erg givenData)
 {
     if (Slot1 != null &&
         Slot2 != null &&
         Slot3 != null &&
         Slot4 != null &&
         Slot5 != null)
     {
         Slot1.text = givenData.distance.ToString("0.00") + "m";
         Slot2.text = getPaceStr(givenData.paceInSecs);
         Slot3.text = getPaceStr(givenData.paceInSecs);
         Slot4.text = givenData.cadence.ToString();
         Slot5.text = getTimeStr(givenData.exerciseTime);
     }
 }
Ejemplo n.º 3
0
        double offsetDist = 0.0; //needed if the boat changes its pace

        public BotConstant(string givenName = "BotConstant", uint givenPace = 120, uint spm = 18, double distance = 0.0)
        {
            thisErg              = new EasyErgsocket.Erg();
            thisErg.cadence      = spm;
            thisErg.calories     = 1;
            thisErg.distance     = distance;
            thisErg.ergtype      = EasyErgsocket.ErgType.ROW;
            thisErg.exerciseTime = 0.0;
            thisErg.heartrate    = 0;
            thisErg.name         = givenName;
            thisErg.paceInSecs   = givenPace;
            thisErg.playertype   = EasyErgsocket.PlayerType.BOT;
            thisErg.power        = 0;
            thisErg.ergId        = NameToId(givenName);

            originalPace = givenPace;
        }
Ejemplo n.º 4
0
    public void Update(EasyErgsocket.Erg givenParent = null)
    {
        if (givenParent == null)
        {
            //if there is no parent to give the time use the time that has passed since starting the application
            TimeSpan timeSinceStart = DateTime.Now - starttime;
            thisErg.exerciseTime = timeSinceStart.TotalSeconds;
        }
        else
        {
            thisErg.exerciseTime = givenParent.exerciseTime;
        }
        double strokesPerSecond = thisErg.cadence / 60.0;
        double velocity         = 500.0 / thisErg.paceInSecs;

        double timePassedOffset = (thisErg.exerciseTime - offsetTime); //apply the offset onto the time
        double timeCalc         = timePassedOffset + amplitude * -Math.Sin(timePassedOffset * strokesPerSecond * 2.0 * Math.PI);

        thisErg.distance = offsetDist + (velocity * timeCalc);
    }