private void CreateBoat(Erg givenErg)
    {
        Vector3    newPos;
        Quaternion newRot = new Quaternion();

        if (givenErg.playertype == EasyErgsocket.PlayerType.HUMAN)
        {
            newPos      = playerLane;
            playerIndex = givenErg.ergId;
        }
        else
        {
            newPos = GetFreeBotLane();
        }

        //if we just created the player boat we need to attach the camera
        if (givenErg.playertype == EasyErgsocket.PlayerType.HUMAN)
        {
            boats[givenErg.ergId] = Instantiate(playerBoatType, newPos, newRot) as GameObject;
            if (cameraManager != null)
            {
                cameraManager.SetParent(boats[givenErg.ergId].transform);
            }
        }
        else
        {
            boats[givenErg.ergId] = Instantiate(otherBoatType, newPos, newRot) as GameObject;
        }


        Debug.Log("Created new Boat " + givenErg.ergId);

        //update the boats name etc
        boats[givenErg.ergId].GetComponent <Boat>().BoatName = givenErg.name;
    }
    private void UpdateErg(Erg givenErg)
    {
        //if the boat does not exist yet, add it
        if (!boats.ContainsKey(givenErg.ergId))
        {
            CreateBoat(givenErg);
        }

        Boat boat = boats[givenErg.ergId].GetComponentInChildren <Boat>();

        boat.UpdatePosition((float)givenErg.distance, (float)givenErg.exerciseTime);

        //update the stats on the track
        if (givenErg.playertype == EasyErgsocket.PlayerType.HUMAN)
        {
            if (statDisplayManager != null)
            {
                statDisplayManager.UpdateStats(givenErg);
            }

            //update all the trackparts
            if (trackManager != null)
            {
                trackManager.SetDistance((float)givenErg.distance);
            }
        }
    }
Exemple #3
0
        public void Update(double timePassed, Erg givenParent = null)
        {
            thisErg.exerciseTime = timePassed;
            double strokesPerSecond = thisErg.cadence / 60.0;
            double velocity         = 500.0 / thisErg.paceInSecs;

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

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