Exemple #1
0
        public static void SetGameType(GameType gameType)
        {
            RaceData = new Race {
                game      = gameType,
                boats     = new List <BoatData>(),
                boatCount = 4,
                laps      = 3,
                type      = RaceType.Race
            };

            Debug.Log($"Game type set to:{RaceData.game}");
            switch (RaceData.game)
            {
            case GameType.Singleplayer:
                var b = new BoatData();
                b.human = true;                              // single player is human
                RaceData.boats.Add(b);                       // add player boat
                GenerateRandomBoats(RaceData.boatCount - 1); // add random AI
                break;

            case GameType.Spectator:
                GenerateRandomBoats(RaceData.boatCount);
                break;
            }
        }
Exemple #2
0
 private void LateUpdate()
 {
     if (_spectatorEnabled && _focusedBoat == null)
     {
         _focusedBoat = RaceManager.RaceData.boats[0];
         _focusPoint  = _focusedBoat.BoatObject.transform;
         SetReplayTarget(_focusPoint);
     }
 }
        public static void SetGameType(GameType gameType)
        {
            RaceData = new Race {
                game      = gameType,
                boats     = new List <BoatData>(),
                boatCount = 4,
                laps      = 3,
                type      = RaceType.Race
            };

            Debug.Log($"Game type set to:{RaceData.game}");
            switch (RaceData.game)
            {
            case GameType.Singleplayer:
                var b = new BoatData();
                b.human = true;                              // single player is human
                RaceData.boats.Add(b);                       // add player boat
                GenerateRandomBoats(RaceData.boatCount - 1); // add random AI
                break;

            case GameType.Spectator:
                GenerateRandomBoats(RaceData.boatCount);
                break;

            case GameType.LocalMultiplayer:
                Debug.LogError("Not Implemented");
                break;

            case GameType.Multiplayer:
                Debug.LogError("Not Implemented");
                break;

            case GameType.Benchmark:
                Debug.LogError("Not Implemented");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private static void GenerateRandomBoats(int count, bool ai = true)
        {
            for (var i = 0; i < count; i++)
            {
                var boat = new BoatData();
                Random.InitState(ConstantData.SeedNow + i);
                boat.boatName = ConstantData.AiNames[Random.Range(0, ConstantData.AiNames.Length)];
                BoatLivery livery = new BoatLivery
                {
                    primaryColor = ConstantData.GetRandomPaletteColor,
                    trimColor    = ConstantData.GetRandomPaletteColor
                };
                boat.livery     = livery;
                boat.boatPrefab = Instance.boats[Random.Range(0, Instance.boats.Length)];

                if (ai)
                {
                    boat.human = false;
                }

                RaceData.boats.Add(boat);
            }
        }
Exemple #5
0
 public void SetTarget(int boatIndex)
 {
     _focusedBoat = RaceManager.RaceData.boats[boatIndex];
     _focusPoint = _focusedBoat.BoatObject.transform;
     SetReplayTarget(_focusPoint);
 }