예제 #1
0
        /// <summary>
        /// Register Racer to game manager and return racer array index for querying racer stuff later
        /// </summary>
        /// <param name="GamerDetail"></param>
        /// <returns></returns>
        public int RegisterToGame(Racer_Detail GamerDetail)
        {
            int rIndex = -1;

            if (GamerDetail != null)
            {
                ListRacers.Add(GamerDetail);
                rIndex = ListRacers.FindIndex(_racerNew => _racerNew.ID == GamerDetail.ID);
            }
            return(rIndex);
        }
예제 #2
0
        private void Start()
        {
            if (!this.enabled)
            {
                return;
            }

            GamerDistanceChecker = transform.FindChild("_DistancePoint");
            if (GamerDistanceChecker == null)
            {
                Debug.LogError(RGKMessages.DistanceCheckerMissing);
                Debug.DebugBreak();
            }

            if (RaceManager.CheckPoints != null) // If Checkoints speedtraps or sectors Implemented
            {
                CheckpointArray = GetChildTransforms(RaceManager.CheckPoints.transform);

                if (CheckpointArray.Length > 0)
                {
                    IsCheckPointSystemEnabled = true;

                    CheckpointArrow = GameObject.Find("CheckpointArrow");
                    if (CheckpointArrow != null && RaceManager.EnableCheckpointArrow)
                    {
                        CheckpointArrow.SetActiveRecursively(true);
                    }
                }
            }


            GameObject DistanceTransformContainer = RaceManager.DistanceTransformContainer;

            DistanceArray = GetChildTransforms(DistanceTransformContainer.transform);
            DistanceList.AddRange(DistanceArray);
            SortDPByDistance();
            DistanceArrayLenght = DistanceArray.Length;

            if (base.gameObject.transform.Find("_RacerTag") != null)
            {
                RacerTagName  = base.gameObject.transform.Find("_RacerTag/Name").GetComponent(typeof(TextMesh)) as TextMesh;
                RacerTagPlace = base.gameObject.transform.Find("_RacerTag/Place").GetComponent(typeof(TextMesh)) as TextMesh;
            }
            else
            {
                RacerTagNotFound = true;
                if (!IsPlayer)
                {
                    Debug.LogWarning(RGKMessages.RacerTagObjectsMissing);
                }
            }

            if (RaceManager != null)
            {
                RacerDetail    = new Racer_Detail();
                RacerDetail.ID = UnityEngine.Random.Range(1000, 50000).ToString();
                RacerID        = RacerDetail.ID;


                RacerDetail.RacerLap  = GamerCurrentLap;
                RaceManagerRacerIndex = RaceManager.RegisterToGame(RacerDetail);


                if (IsPlayer)
                {
                    RacerDetail.RacerName = RacerName;
                    RacerDetail.IsPlayer  = true;
                }
                else
                {
                    RacerDetail.RacerName = RaceManager.GetNameForRacer(RacerName);
                    RacerName             = RacerDetail.RacerName;
                }

                if (!RacerTagNotFound)
                {
                    if (RacerTagPlace != null)
                    {
                        RacerTagPlace.text = RaceManager.RegisteredRacers[RaceManagerRacerIndex].RacerStanding.ToString();
                    }
                    if (RacerTagPlace != null)
                    {
                        RacerTagName.text = RaceManager.RegisteredRacers[RaceManagerRacerIndex].RacerName.ToString();
                    }
                }
            }
        }