コード例 #1
0
ファイル: Bike.cs プロジェクト: mtringel/BikeRentals
 public Bike(
     int bikeId,
     BikeState bikeState,
     BikeModel bikeModel,
     Color color,
     Location currentLocation,
     string currentLocationName,
     DateTime availableFrom,
     float rateAverage,
     DateTime created,
     User createdBy,
     ContentFileFormat?imageFormat,
     int?imageSeq,
     bool isPartial
     )
 {
     this.BikeId              = bikeId;
     this.BikeState           = bikeState;
     this.BikeModel           = bikeModel;
     this.Color               = color;
     this.CurrentLocation     = currentLocation;
     this.AvailableFromUtc    = availableFrom;
     this.RateAverage         = rateAverage;
     this.CurrentLocationName = currentLocationName;
     this.CreatedUtc          = created;
     this.CreatedBy           = createdBy;
     this.IsActive            = true;
     this.ImageFormat         = imageFormat;
     this.ImageSeq            = imageSeq;
     this.IsPartial           = isPartial;
 }
コード例 #2
0
        static void client_GetBikeState(string userId, List <float> states)
        {
            if (myEvent.WaitOne())
            {
                myEvent.Reset();
                BikeState bikeState = new BikeState();
                CoMatrix(ref bikeState.Transform, states);
                bikeState.CompletionProgress = states[16];

                bikeState.Velocity.X = states[17];
                bikeState.Velocity.Y = states[18];
                bikeState.Velocity.Z = states[19];

                bikeState.ID = userId;

                netInterface.playersState[userId] = bikeState;
                myEvent.Set();
            }
        }
コード例 #3
0
        public void NotifyNewState(BikeState state)
        {
            this.state         = state;
            CompletionProgress = state.CompletionProgress;

            oldTransform = transform;
            newTransform = state.Transform;

            lerpPrg = 0;

            //if (firstSet)
            //{
            //    oldPos[3] = oldPos[2] = oldPos[1] = oldPos[0] = state.Transform.Translation;
            //    oldOri[0] = Quaternion.CreateFromRotationMatrix(state.Transform);
            //    oldOri[3] = oldOri[2] = oldOri[1] = oldOri[0];
            //}
            //else
            //{
            //    for (int i = 0; i < oldPos.Length - 1; i++)
            //    {
            //        oldPos[i] = oldPos[i + 1];
            //        oldOri[i] = oldOri[i + 1];
            //    }
            //    oldPos[3] = state.Transform.Translation;
            //    oldOri[3] = Quaternion.CreateFromRotationMatrix(state.Transform);

            //}

            //Vector3 pos = Vector3.Zero;


            //for (int i = 0; i < oldPos.Length; i++)
            //{
            //    pos += state.Transform.Translation * 0.25f;
            //}
            //Quaternion ori1 = Quaternion.Slerp(oldOri[0], oldOri[1], 0.5f);
            //Quaternion ori2 = Quaternion.Slerp(oldOri[2], oldOri[3], 0.5f);
            //Quaternion ori = Quaternion.Slerp(ori1, ori2, 0.5f);

            //transform = Matrix.CreateFromQuaternion(ori);
            //transform.Translation = pos;
        }
コード例 #4
0
        public BikeState[] DownloadBikeState()
        {
            if (myEvent.WaitOne())
            {
                myEvent.Reset();
                BikeState[] listbs = new BikeState[playersState.Count];
                int         i      = 0;
                foreach (BikeState bs in playersState.Values)
                {
                    listbs[i++] = bs;
                }
                myEvent.Set();
                if (listbs.Length <= 0)
                {
                    return(null);
                }
                return(listbs);
            }

            return(null);
        }
コード例 #5
0
        // TODO Dynamic spawn location.
        public void SetState(BikeState state, Vector3?pos = null, Quaternion?rot = null)
        {
            State = state;

            switch (state)
            {
            case BikeState.Reset:
                transform.position   = pos ?? defPos;
                transform.rotation   = rot ?? defRot;
                Body.velocity        = Vector3.zero;
                Body.angularVelocity = Vector3.zero;
                Body.drag            = defDrag;
                Body.angularDrag     = defAngDrag;
                Steer       = 0;
                Throttle    = 0;
                IsOffTrack  = false;
                IsColliding = false;
                locAngVeloY = 0;
                break;

            // TODO Spawn animation?
            case BikeState.Spawn:
                readyTime = Time.time + spawnTimeout;
                StopSmoke();
                break;

            case BikeState.Crash:
                readyTime        = Time.time + crashTimeout;
                Body.drag        = 0;
                Body.angularDrag = 0;
                // TBD crash force.
                Body.AddForce(transform.forward * 10f, ForceMode.VelocityChange);
                Body.AddTorque(transform.right * -25f, ForceMode.VelocityChange);
                audioSrc.PlayOneShot(crashClips[Random.Range(0, crashClips.Length)]);
                StartSmoke();
                break;
            }
        }
コード例 #6
0
ファイル: Bike.cs プロジェクト: raparicio6/BikeRental
 public void ChangeState(BikeState state)
 {
     this.State = state;
 }