예제 #1
0
    public void SetMasterFitnessComponentList()       // Looks at player's brain and Trial's miniGame instance to assemble a combined FitnessComponentList
    //DebugBot.DebugFunctionCall("SetMasterFitnessComponentList: " + playerRef.masterTrialsList.Count.ToString (), true);
    //BrainBase currentBrainRef = playerRef.masterPopulation.templateBrain; // OR TEMPLATE BRAIN???
    {
        MiniGameBase  currentMiniGameRef = playerRef.masterTrialsList[playerRef.currentTrialForEdit].miniGameManager.miniGameInstance;
        BrainSettings brainSettings      = playerRef.masterPopulation.brainSettings;

        brainFitnessComponentList = brainSettings.brainFitnessComponentList;
        if (currentMiniGameRef != null)
        {
            //if (currentMiniGameRef.gameInitialized) {
            gameFitnessComponentList = currentMiniGameRef.fitnessComponentList;

            masterFitnessCompList = new List <FitnessComponent>();
            for (int i = 0; i < brainSettings.brainFitnessComponentList.Count; i++)    // grab fitnessComponents from current brain type
            {
                masterFitnessCompList.Add(brainSettings.brainFitnessComponentList[i]);
            }
            for (int j = 0; j < currentMiniGameRef.fitnessComponentList.Count; j++)
            {
                masterFitnessCompList.Add(currentMiniGameRef.fitnessComponentList[j]);
            }
            //}
        }
    }
예제 #2
0
    /// <summary>
    /// Called by SetPlayerExitCube when a player completes or fails a mini game.
    /// </summary>
    /// <param name="timer_id"></param>
    /// <param name="args"></param>
    void OnSetPlayerExitCubeTimeout(int timer_id, object args)
    {
        PlayerTrans_.position = playerStartPos_;
        //PlayerTrans_.eulerAngles = Vector3.zero;
        EnableRayCast_ = true;
        Messenger.Broadcast(GameEvent.OnPlayerExitCube.ToString(), MessengerMode.DONT_REQUIRE_LISTENER);

        if (currentMiniGame_ != null)
        {
            if (mainState_ == MainState.MINIGAMESUCCESSED)   //If the player is exiting the cube and has completed the game, this will be true, and we will increase the miniGameIndex to get a new mini game
            {
                ++currentMiniGameIndex_;
                OnPointsChange(GameData_.EachGamePointsWin_);
            }
            else if (mainState_ == MainState.MINIGAMEFAILED)
            {
                OnPointsChange(GameData_.EachGamePointsLose_);
            }

            currentMiniGame_.DestroyGame();
            currentMiniGame_ = null;
        }

        if (GetLives <= 0) //When lives are all gone, call the GameFailed() function that displays Game Failed UI
        {
            GameFailed();
        }
        else
        {
            PrepareMiniGame();
        }
    }
예제 #3
0
    void PrepareMiniGame()
    {
        //If the current game index is greater than the length of the MiniGame array, then the player has successfully completed the game.
        if (currentMiniGameIndex_ >= MiniGames_.Length)
        {
            GameSuccessful();
            return;
        }

        //Gets in here once you click start at teh beginning of the game
        GameObject create_mini_game = GameObject.Instantiate(MiniGames_[currentMiniGameIndex_]);  //MiniGames_ stores an array of all the games

        if (create_mini_game != null)
        {
            currentMiniGame_ = create_mini_game.GetComponent <MiniGameBase> ();
            if (currentMiniGame_ == null)
            {
                LogSystem.LogError("Mini game " + create_mini_game.name + " error, can't find the class <MiniGameBase>");
                return;
            }
        }

        usingCard_ = UsingCard.NONE;
        Messenger <string, string> .Broadcast(UIMsg.SetGameInfo.ToString(), currentMiniGame_.GameName_, currentMiniGame_.GameDescription_, MessengerMode.DONT_REQUIRE_LISTENER);

        Messenger.Broadcast(GameEvent.SetupMiniGame.ToString(), MessengerMode.DONT_REQUIRE_LISTENER);
        EnableRayCast_ = true;

        //test
        //MiniGameStart ();
    }
예제 #4
0
    /// <summary>
    ///
    /// </summary>
    public void SwitchGame()
    {
        if (currentMiniGame_ != null)
        {
            currentMiniGame_.DestroyGame();
            currentMiniGame_ = null;
        }

        int rnd_index = Random.Range(0, listUnusedGames_.Count);

        MiniGames_[currentMiniGameIndex_] = listUnusedGames_[rnd_index];
        GameObject create_mini_game = GameObject.Instantiate(listUnusedGames_[rnd_index]);

        if (create_mini_game != null)
        {
            currentMiniGame_ = create_mini_game.GetComponent <MiniGameBase>();
            if (currentMiniGame_ == null)
            {
                LogSystem.LogError("Mini game " + create_mini_game.name + " error, can't find the class <MiniGameBase>");
                return;
            }
        }

        usingCard_ = UsingCard.NONE;
        Messenger <string, string> .Broadcast(UIMsg.SetGameInfo.ToString(), currentMiniGame_.GameName_, currentMiniGame_.GameDescription_, MessengerMode.DONT_REQUIRE_LISTENER);

        Messenger.Broadcast(GameEvent.SetupMiniGame.ToString(), MessengerMode.DONT_REQUIRE_LISTENER);
    }
예제 #5
0
 void Start()
 {
     chosen = mainGame.GetMiniGame();
     chosen.Create();
     slider.value = slider.maxValue = chosen.timer;
     win.enabled  = lose.enabled = false;
     timer        = 2;
 }
예제 #6
0
    public MiniGameBase GetMiniGame()
    {
        MiniGameBase mini = System.Activator.CreateInstance(System.Type.GetType(type)) as MiniGameBase;

        mini.sprites = sprites;
        mini.notes   = notes;
        return(mini);
    }
예제 #7
0
    void Chose()
    {
        chosen?.Clear();
        int i = id;

        do
        {
            id = Random.Range(0, miniGames.Length);
        }while (id == i);
        chosen = miniGames[id].GetMiniGame();
        chosen.Create();
        slider.value = slider.maxValue = chosen.timer;
        win.enabled  = lose.enabled = false;
        timer        = 2;
    }
예제 #8
0
    public void ApplyTrainingModifierEffectsTarget(Trainer trainer, MiniGameBase minigame)
    {
        int currentGen = trainer.PlayingCurGeneration; // + trainer.PlayerList[0].masterPopulation.trainingGenerations;

        if (trainer.loadedTrainingSave != null)
        {
            currentGen += trainer.loadedTrainingSave.endGeneration;
        }
        int numModifiers   = activeTrainingModifierList.Count;
        int numRounds      = 0;
        int gameRoundIndex = 0;

        // v v v SUPER HACKY!!! v v v
        MiniGameCritterWalkBasic game = (MiniGameCritterWalkBasic)minigame;

        // Clear existing Lists:
        if (game.targetPositionList == null)
        {
            game.targetPositionList = new List <Vector3>();
        }
        else
        {
            game.targetPositionList.Clear();
        }
        if (game.endGameTimesList == null)
        {
            game.endGameTimesList = new List <int>();
        }
        else
        {
            game.endGameTimesList.Clear();
        }
        if (game.initialForceList == null)
        {
            game.initialForceList = new List <Vector3>();
        }
        else
        {
            game.initialForceList.Clear();
        }

        if (numModifiers > 0)
        {
            int numTargetModifiers = 0;
            for (int i = numModifiers - 1; i >= 0; i--)    // iterate through all modifiers
            {
                float t = 0f;
                switch (activeTrainingModifierList[i].modifierType)
                {
                case TrainingModifier.TrainingModifierType.LinkExplosion:

                    break;

                case TrainingModifier.TrainingModifierType.MutationBlast:

                    break;

                case TrainingModifier.TrainingModifierType.BodyMutationBlast:

                    break;

                case TrainingModifier.TrainingModifierType.PruneBrain:

                    break;

                case TrainingModifier.TrainingModifierType.TargetCone:
                    numTargetModifiers++;
                    numRounds += activeTrainingModifierList[i].numRounds;

                    t = ((float)currentGen - (float)activeTrainingModifierList[i].startGen) / (float)activeTrainingModifierList[i].duration;
                    if (t > 1f)
                    {
                        t = 1f;
                    }

                    for (int c = 0; c < activeTrainingModifierList[i].numRounds; c++)
                    {
                        float horAngle = 0f;
                        float verAngle = 0f;
                        float minAngle = Mathf.Lerp(activeTrainingModifierList[i].beginMinAngle, activeTrainingModifierList[i].endMinAngle, t);
                        float maxAngle = Mathf.Lerp(activeTrainingModifierList[i].beginMaxAngle, activeTrainingModifierList[i].endMaxAngle, t);
                        if (activeTrainingModifierList[i].horizontal)
                        {
                            horAngle = UnityEngine.Random.Range(minAngle, maxAngle) * Mathf.PI / 180f;
                            // Flip to negative axis check
                            if (UnityEngine.Random.Range(0f, 1f) < 0.5f)
                            {
                                horAngle *= -1f;
                            }
                        }
                        if (activeTrainingModifierList[i].vertical)
                        {
                            verAngle = UnityEngine.Random.Range(minAngle, maxAngle) * Mathf.PI / 180f;
                            if (UnityEngine.Random.Range(0f, 1f) < 0.5f)
                            {
                                verAngle *= -1f;
                            }
                        }

                        float minDist = Mathf.Lerp(activeTrainingModifierList[i].beginMinDistance, activeTrainingModifierList[i].endMinDistance, t);
                        float maxDist = Mathf.Lerp(activeTrainingModifierList[i].beginMaxDistance, activeTrainingModifierList[i].endMaxDistance, t);
                        float dist    = UnityEngine.Random.Range(minDist, maxDist);

                        Vector2 hor = new Vector2(Mathf.Sin(horAngle) * dist, Mathf.Cos(horAngle) * dist).normalized;
                        float   x   = Mathf.Sin(horAngle) * dist * Mathf.Cos(verAngle);
                        float   z   = Mathf.Cos(horAngle) * dist * Mathf.Cos(verAngle);
                        float   y   = Mathf.Sin(verAngle) * dist;

                        game.targetPositionList.Add(new Vector3(x, y, z));
                        int randEndTime = Mathf.RoundToInt(UnityEngine.Random.Range(trainer.PlayerList[0].masterTrialsList[0].minEvaluationTimeSteps, trainer.PlayerList[0].masterTrialsList[0].maxEvaluationTimeSteps));
                        game.endGameTimesList.Add(randEndTime);
                        gameRoundIndex++;

                        Vector3 forceDir = UnityEngine.Random.onUnitSphere;
                        float   forceMag = UnityEngine.Random.Range(game.customSettings.initForceMin[0], game.customSettings.initForceMax[0]);
                        game.initialForceList.Add(new Vector3(forceDir.x * forceMag, forceDir.y * forceMag, forceDir.z * forceMag));
                    }

                    break;

                case TrainingModifier.TrainingModifierType.TargetForward:
                    numTargetModifiers++;
                    numRounds += activeTrainingModifierList[i].numRounds;

                    t = ((float)currentGen - (float)activeTrainingModifierList[i].startGen) / (float)activeTrainingModifierList[i].duration;
                    if (t > 1f)
                    {
                        t = 1f;
                    }

                    for (int c = 0; c < activeTrainingModifierList[i].numRounds; c++)
                    {
                        float minDist = Mathf.Lerp(activeTrainingModifierList[i].beginMinDistance, activeTrainingModifierList[i].endMinDistance, t);
                        float maxDist = Mathf.Lerp(activeTrainingModifierList[i].beginMaxDistance, activeTrainingModifierList[i].endMaxDistance, t);
                        float dist    = UnityEngine.Random.Range(minDist, maxDist);

                        game.targetPositionList.Add(new Vector3(0f, 0f, dist));
                        int randEndTime = Mathf.RoundToInt(UnityEngine.Random.Range(trainer.PlayerList[0].masterTrialsList[0].minEvaluationTimeSteps, trainer.PlayerList[0].masterTrialsList[0].maxEvaluationTimeSteps));
                        game.endGameTimesList.Add(randEndTime);
                        gameRoundIndex++;

                        Vector3 forceDir = UnityEngine.Random.onUnitSphere;
                        float   forceMag = UnityEngine.Random.Range(game.customSettings.initForceMin[0], game.customSettings.initForceMax[0]);
                        game.initialForceList.Add(new Vector3(forceDir.x * forceMag, forceDir.y * forceMag, forceDir.z * forceMag));
                    }

                    break;

                case TrainingModifier.TrainingModifierType.TargetOmni:
                    numTargetModifiers++;
                    numRounds += activeTrainingModifierList[i].numRounds;

                    t = ((float)currentGen - (float)activeTrainingModifierList[i].startGen) / (float)activeTrainingModifierList[i].duration;
                    if (t > 1f)
                    {
                        t = 1f;
                    }

                    for (int c = 0; c < activeTrainingModifierList[i].numRounds; c++)
                    {
                        float randX = 0f;
                        float randY = 0f;
                        float randZ = 0f;
                        if (activeTrainingModifierList[i].horizontal)
                        {
                            randX = UnityEngine.Random.Range(-1f, 1f);
                        }
                        if (activeTrainingModifierList[i].vertical)
                        {
                            randY = UnityEngine.Random.Range(-1f, 1f);
                        }
                        if (activeTrainingModifierList[i].forward)
                        {
                            randZ = UnityEngine.Random.Range(-1f, 1f);
                        }
                        Vector3 randDir = new Vector3(randX, randY, randZ).normalized;

                        float minDist = Mathf.Lerp(activeTrainingModifierList[i].beginMinDistance, activeTrainingModifierList[i].endMinDistance, t);
                        float maxDist = Mathf.Lerp(activeTrainingModifierList[i].beginMaxDistance, activeTrainingModifierList[i].endMaxDistance, t);
                        float dist    = UnityEngine.Random.Range(minDist, maxDist);

                        game.targetPositionList.Add(new Vector3(randDir.x * dist, randDir.y * dist, randDir.z * dist));
                        int randEndTime = Mathf.RoundToInt(UnityEngine.Random.Range(trainer.PlayerList[0].masterTrialsList[0].minEvaluationTimeSteps, trainer.PlayerList[0].masterTrialsList[0].maxEvaluationTimeSteps));
                        game.endGameTimesList.Add(randEndTime);
                        gameRoundIndex++;

                        Vector3 forceDir = UnityEngine.Random.onUnitSphere;
                        float   forceMag = UnityEngine.Random.Range(game.customSettings.initForceMin[0], game.customSettings.initForceMax[0]);
                        game.initialForceList.Add(new Vector3(forceDir.x * forceMag, forceDir.y * forceMag, forceDir.z * forceMag));
                    }

                    break;

                case TrainingModifier.TrainingModifierType.VariableTrialTimes:

                    break;

                case TrainingModifier.TrainingModifierType.WideSearch:

                    break;

                default:
                    Debug.Log("Modifier type not found!!! SWITCH DEFAULT CASE");
                    break;
                }
            }
            if (numTargetModifiers == 0)
            {
                // proceed as default
                minigame.ResetTargetPositions(trainer.PlayerList[0].masterTrialsList[0].numberOfPlays, trainer.PlayerList[0].masterTrialsList[0].minEvaluationTimeSteps, trainer.PlayerList[0].masterTrialsList[0].maxEvaluationTimeSteps);
            }
            else
            {
                trainer.PlayerList[0].masterTrialsList[0].numberOfPlays = numRounds;
            }
        }
        else    // No Modifiers!
        {
            minigame.ResetTargetPositions(trainer.PlayerList[0].masterTrialsList[0].numberOfPlays, trainer.PlayerList[0].masterTrialsList[0].minEvaluationTimeSteps, trainer.PlayerList[0].masterTrialsList[0].maxEvaluationTimeSteps);
        }
    }
    public void ApplyTrainingModifierEffectsTarget(Trainer trainer, MiniGameBase minigame) {
        int currentGen = trainer.PlayingCurGeneration; // + trainer.PlayerList[0].masterPopulation.trainingGenerations;
        if (trainer.loadedTrainingSave != null) {
            currentGen += trainer.loadedTrainingSave.endGeneration;
        }
        int numModifiers = activeTrainingModifierList.Count;
        int numRounds = 0;
        int gameRoundIndex = 0;

        // v v v SUPER HACKY!!! v v v 
        MiniGameCritterWalkBasic game = (MiniGameCritterWalkBasic)minigame;
        // Clear existing Lists:
        if (game.targetPositionList == null) {
            game.targetPositionList = new List<Vector3>();
        }
        else {
            game.targetPositionList.Clear();
        }
        if (game.endGameTimesList == null) {
            game.endGameTimesList = new List<int>();
        }
        else {
            game.endGameTimesList.Clear();
        }
        if (game.initialForceList == null) {
            game.initialForceList = new List<Vector3>();
        }
        else {
            game.initialForceList.Clear();
        }

        if (numModifiers > 0) {
            int numTargetModifiers = 0;
            for (int i = numModifiers - 1; i >= 0; i--) {  // iterate through all modifiers
                float t = 0f;
                switch (activeTrainingModifierList[i].modifierType) {
                    case TrainingModifier.TrainingModifierType.LinkExplosion:

                        break;

                    case TrainingModifier.TrainingModifierType.MutationBlast:
                        
                        break;

                    case TrainingModifier.TrainingModifierType.BodyMutationBlast:

                        break;

                    case TrainingModifier.TrainingModifierType.PruneBrain:
                        
                        break;

                    case TrainingModifier.TrainingModifierType.TargetCone:
                        numTargetModifiers++;
                        numRounds += activeTrainingModifierList[i].numRounds;

                        t = ((float)currentGen - (float)activeTrainingModifierList[i].startGen) / (float)activeTrainingModifierList[i].duration;
                        if(t > 1f) {
                            t = 1f;
                        }
                        
                        for (int c = 0; c < activeTrainingModifierList[i].numRounds; c++) {
                            float horAngle = 0f;
                            float verAngle = 0f;
                            float minAngle = Mathf.Lerp(activeTrainingModifierList[i].beginMinAngle, activeTrainingModifierList[i].endMinAngle, t);
                            float maxAngle = Mathf.Lerp(activeTrainingModifierList[i].beginMaxAngle, activeTrainingModifierList[i].endMaxAngle, t);
                            if (activeTrainingModifierList[i].horizontal) {
                                horAngle = UnityEngine.Random.Range(minAngle, maxAngle) * Mathf.PI / 180f;
                                // Flip to negative axis check
                                if (UnityEngine.Random.Range(0f, 1f) < 0.5f) {
                                    horAngle *= -1f;
                                }
                            }
                            if (activeTrainingModifierList[i].vertical) {
                                verAngle = UnityEngine.Random.Range(minAngle, maxAngle) * Mathf.PI / 180f;
                                if (UnityEngine.Random.Range(0f, 1f) < 0.5f) {
                                    verAngle *= -1f;
                                }
                            }
                            
                            float minDist = Mathf.Lerp(activeTrainingModifierList[i].beginMinDistance, activeTrainingModifierList[i].endMinDistance, t);
                            float maxDist = Mathf.Lerp(activeTrainingModifierList[i].beginMaxDistance, activeTrainingModifierList[i].endMaxDistance, t);
                            float dist = UnityEngine.Random.Range(minDist, maxDist);

                            Vector2 hor = new Vector2(Mathf.Sin(horAngle) * dist, Mathf.Cos(horAngle) * dist).normalized;
                            float x = Mathf.Sin(horAngle) * dist * Mathf.Cos(verAngle);
                            float z = Mathf.Cos(horAngle) * dist * Mathf.Cos(verAngle);
                            float y = Mathf.Sin(verAngle) * dist;

                            game.targetPositionList.Add(new Vector3(x, y, z));
                            int randEndTime = Mathf.RoundToInt(UnityEngine.Random.Range(trainer.PlayerList[0].masterTrialsList[0].minEvaluationTimeSteps, trainer.PlayerList[0].masterTrialsList[0].maxEvaluationTimeSteps)); 
                            game.endGameTimesList.Add(randEndTime);
                            gameRoundIndex++;

                            Vector3 forceDir = UnityEngine.Random.onUnitSphere;
                            float forceMag = UnityEngine.Random.Range(game.customSettings.initForceMin[0], game.customSettings.initForceMax[0]);
                            game.initialForceList.Add(new Vector3(forceDir.x * forceMag, forceDir.y * forceMag, forceDir.z * forceMag));
                        }

                        break;

                    case TrainingModifier.TrainingModifierType.TargetForward:
                        numTargetModifiers++;
                        numRounds += activeTrainingModifierList[i].numRounds;

                        t = ((float)currentGen - (float)activeTrainingModifierList[i].startGen) / (float)activeTrainingModifierList[i].duration;
                        if (t > 1f) {
                            t = 1f;
                        }

                        for (int c = 0; c < activeTrainingModifierList[i].numRounds; c++) {
                            
                            float minDist = Mathf.Lerp(activeTrainingModifierList[i].beginMinDistance, activeTrainingModifierList[i].endMinDistance, t);
                            float maxDist = Mathf.Lerp(activeTrainingModifierList[i].beginMaxDistance, activeTrainingModifierList[i].endMaxDistance, t);
                            float dist = UnityEngine.Random.Range(minDist, maxDist);

                            game.targetPositionList.Add(new Vector3(0f, 0f, dist));
                            int randEndTime = Mathf.RoundToInt(UnityEngine.Random.Range(trainer.PlayerList[0].masterTrialsList[0].minEvaluationTimeSteps, trainer.PlayerList[0].masterTrialsList[0].maxEvaluationTimeSteps));
                            game.endGameTimesList.Add(randEndTime);
                            gameRoundIndex++;

                            Vector3 forceDir = UnityEngine.Random.onUnitSphere;
                            float forceMag = UnityEngine.Random.Range(game.customSettings.initForceMin[0], game.customSettings.initForceMax[0]);
                            game.initialForceList.Add(new Vector3(forceDir.x * forceMag, forceDir.y * forceMag, forceDir.z * forceMag));
                        }

                        break;

                    case TrainingModifier.TrainingModifierType.TargetOmni:
                        numTargetModifiers++;
                        numRounds += activeTrainingModifierList[i].numRounds;

                        t = ((float)currentGen - (float)activeTrainingModifierList[i].startGen) / (float)activeTrainingModifierList[i].duration;
                        if (t > 1f) {
                            t = 1f;
                        }

                        for (int c = 0; c < activeTrainingModifierList[i].numRounds; c++) {

                            float randX = 0f;
                            float randY = 0f;
                            float randZ = 0f;
                            if(activeTrainingModifierList[i].horizontal) {
                                randX = UnityEngine.Random.Range(-1f, 1f);
                            }
                            if (activeTrainingModifierList[i].vertical) {
                                randY = UnityEngine.Random.Range(-1f, 1f);
                            }
                            if (activeTrainingModifierList[i].forward) {
                                randZ = UnityEngine.Random.Range(-1f, 1f);
                            }                         
                            Vector3 randDir = new Vector3(randX, randY, randZ).normalized;
                            
                            float minDist = Mathf.Lerp(activeTrainingModifierList[i].beginMinDistance, activeTrainingModifierList[i].endMinDistance, t);
                            float maxDist = Mathf.Lerp(activeTrainingModifierList[i].beginMaxDistance, activeTrainingModifierList[i].endMaxDistance, t);
                            float dist = UnityEngine.Random.Range(minDist, maxDist);
                            
                            game.targetPositionList.Add(new Vector3(randDir.x * dist, randDir.y * dist, randDir.z * dist));
                            int randEndTime = Mathf.RoundToInt(UnityEngine.Random.Range(trainer.PlayerList[0].masterTrialsList[0].minEvaluationTimeSteps, trainer.PlayerList[0].masterTrialsList[0].maxEvaluationTimeSteps));
                            game.endGameTimesList.Add(randEndTime);
                            gameRoundIndex++;

                            Vector3 forceDir = UnityEngine.Random.onUnitSphere;
                            float forceMag = UnityEngine.Random.Range(game.customSettings.initForceMin[0], game.customSettings.initForceMax[0]);
                            game.initialForceList.Add(new Vector3(forceDir.x * forceMag, forceDir.y * forceMag, forceDir.z * forceMag));
                        }

                        break;

                    case TrainingModifier.TrainingModifierType.VariableTrialTimes:
                        
                        break;

                    case TrainingModifier.TrainingModifierType.WideSearch:
                        
                        break;

                    default:
                        Debug.Log("Modifier type not found!!! SWITCH DEFAULT CASE");
                        break;
                }
            }
            if(numTargetModifiers == 0) {
                // proceed as default
                minigame.ResetTargetPositions(trainer.PlayerList[0].masterTrialsList[0].numberOfPlays, trainer.PlayerList[0].masterTrialsList[0].minEvaluationTimeSteps, trainer.PlayerList[0].masterTrialsList[0].maxEvaluationTimeSteps);
            }
            else {
                trainer.PlayerList[0].masterTrialsList[0].numberOfPlays = numRounds;
            }            
        }
        else {  // No Modifiers!
            minigame.ResetTargetPositions(trainer.PlayerList[0].masterTrialsList[0].numberOfPlays, trainer.PlayerList[0].masterTrialsList[0].minEvaluationTimeSteps, trainer.PlayerList[0].masterTrialsList[0].maxEvaluationTimeSteps);
        }
    }
예제 #10
0
    public void SetMiniGameType(MiniGameManager.MiniGameType newGameType)
    {
        // Change game type and re-instantiate miniGameInstance
        DebugBot.DebugFunctionCall("Trial; SetMiniGameType(); " + gameType.ToString(), debugFunctionCalls);
        miniGameInstance = null;
        gameType = newGameType;  // Update GameType to new Type!

        // CREATE mini-game instance!  !!!!!!!!!!!!! Come back to this for Improvement Later!!!!!!!
        if(newGameType == MiniGameType.None) {
            miniGameInstance = new MiniGameBase();
            //miniGameInstance = newGameInstance as MiniGame;
        }
        else if(newGameType == MiniGameType.MoveToTarget1D) {
            MiniGameMoveToTarget1D newGameInstance = new MiniGameMoveToTarget1D();
            miniGameInstance = newGameInstance as MiniGameMoveToTarget1D;
        }
        else if(newGameType == MiniGameType.MoveToTarget2D) {
            MiniGameMoveToTarget2D newGameInstance = new MiniGameMoveToTarget2D();
            miniGameInstance = newGameInstance;
        }
        else if(newGameType == MiniGameType.MoveToTarget3D) {
            MiniGameMoveToTarget3D newGameInstance = new MiniGameMoveToTarget3D();
            miniGameInstance = newGameInstance;
        }
        else if(newGameType == MiniGameType.RobotArmFantasy) {
            MiniGameRobotArm newGameInstance = new MiniGameRobotArm();
            miniGameInstance = newGameInstance;
        }
        else if(newGameType == MiniGameType.PhysXTests) {
            MiniGamePhysXTests newGameInstance = new MiniGamePhysXTests();
            miniGameInstance = newGameInstance;
        }
        else if(newGameType == MiniGameType.PhysXWorm) {
            MiniGamePhysXWorm newGameInstance = new MiniGamePhysXWorm();
            miniGameInstance = newGameInstance;
        }

        SetInputOutputArrays();
    }
    public void SetMiniGameType(MiniGameManager.MiniGameType newGameType, MiniGameSettingsBase gameSettings)        // Change game type and re-instantiate miniGameInstance
    {
        DebugBot.DebugFunctionCall("Trial; SetMiniGameType(); " + gameType.ToString(), debugFunctionCalls);
        miniGameInstance = null;
        gameType         = newGameType;  // Update GameType to new Type!

        // CREATE mini-game instance!  !!!!!!!!!!!!! Come back to this for Improvement Later!!!!!!!
        if (newGameType == MiniGameType.None)
        {
            miniGameInstance = new MiniGameBase();
            //miniGameInstance = newGameInstance as MiniGame;
        }

        /*else if(newGameType == MiniGameType.MoveToTarget3D) {
         *      MiniGameMoveToTarget3D newGameInstance = new MiniGameMoveToTarget3D();
         *      miniGameInstance = newGameInstance;
         * }
         * else if(newGameType == MiniGameType.CreatureSwimBasic) {
         * // SHOULD the input/output Lists depend on the Agent's full Genome, or should the minigame have control over hookups?
         * // ... Maybe eventually the Agent's genome should dictate, but for now, to avoid a complete re-write, will leave the ability
         * // ... of miniGame's to choose which input/output neurons to hook up. Save that change for the big NEAT update where creature
         * // ... topologies can morph and differ within a population.
         * Debug.Log("BROKEN!! MiniGameManager public void SetMiniGameType(MiniGameManager.MiniGameType newGameType)");
         *      CritterGenome templateBody = playerRef.masterPopulation.templateGenome;
         *      //MiniGameCreatureSwimBasic newGameInstance = new MiniGameCreatureSwimBasic(templateBody);
         *      //miniGameInstance = newGameInstance;
         * }*/
        else if (newGameType == MiniGameType.CritterWalkBasic)
        {
            CritterGenome templateBody = playerRef.masterPopulation.templateGenome;
            //Debug.Log("playerRef.masterPopulation.templateBodyGenome: " + playerRef.masterPopulation.templateBodyGenome.creatureBodySegmentGenomeList[0].addOn1.ToString());
            //Debug.Log("templateBody: " + templateBody.creatureBodySegmentGenomeList[0].addOn1.ToString());
            MiniGameCritterWalkBasic newGameInstance = new MiniGameCritterWalkBasic(templateBody);
            newGameInstance.UseSettings((MiniGameCritterWalkBasicSettings)gameSettings);
            newGameInstance.InitializeGame();
            miniGameInstance = newGameInstance;
            Debug.Log("miniGameInstance.inputChannelsList.Count: " + miniGameInstance.inputChannelsList.Count.ToString() + "miniGameInstance.outputChannelsList.Count: " + miniGameInstance.outputChannelsList.Count.ToString());
        }

        /*else if(newGameType == MiniGameType.RobotArmSimple) {
         *      MiniGameRobotArm newGameInstance = new MiniGameRobotArm();
         *      miniGameInstance = newGameInstance;
         * }
         * else if(newGameType == MiniGameType.PhysXWorm) {
         *      MiniGamePhysXWorm newGameInstance = new MiniGamePhysXWorm();
         *      miniGameInstance = newGameInstance;
         * }
         * else if(newGameType == MiniGameType.BallCatch) {
         *      MiniGameBallCatch newGameInstance = new MiniGameBallCatch();
         *      miniGameInstance = newGameInstance;
         * }
         * else if(newGameType == MiniGameType.ObstacleNavigation) {
         *      MiniGameObstacleNavigation newGameInstance = new MiniGameObstacleNavigation();
         *      miniGameInstance = newGameInstance;
         * }
         * else if(newGameType == MiniGameType.PoleBalancing2D) {
         *      MiniGamePoleBalancing2D newGameInstance = new MiniGamePoleBalancing2D();
         *      miniGameInstance = newGameInstance;
         * }
         * else if(newGameType == MiniGameType.SpaceshipShooter) {
         *      MiniGameSpaceshipShooter newGameInstance = new MiniGameSpaceshipShooter();
         *      miniGameInstance = newGameInstance;
         * }*/

        SetInputOutputArrays();         // Haven't set input/output lists for the minigame yet....
    }
	public void SetMiniGameType(MiniGameManager.MiniGameType newGameType, MiniGameSettingsBase gameSettings) {  // Change game type and re-instantiate miniGameInstance
		DebugBot.DebugFunctionCall("Trial; SetMiniGameType(); " + gameType.ToString(), debugFunctionCalls);
		miniGameInstance = null;
		gameType = newGameType;  // Update GameType to new Type!
		
		// CREATE mini-game instance!  !!!!!!!!!!!!! Come back to this for Improvement Later!!!!!!!
		if(newGameType == MiniGameType.None) {
			miniGameInstance = new MiniGameBase();
			//miniGameInstance = newGameInstance as MiniGame;
		}
		/*else if(newGameType == MiniGameType.MoveToTarget3D) {
			MiniGameMoveToTarget3D newGameInstance = new MiniGameMoveToTarget3D();
			miniGameInstance = newGameInstance;
		}
		else if(newGameType == MiniGameType.CreatureSwimBasic) {
            // SHOULD the input/output Lists depend on the Agent's full Genome, or should the minigame have control over hookups?
            // ... Maybe eventually the Agent's genome should dictate, but for now, to avoid a complete re-write, will leave the ability
            // ... of miniGame's to choose which input/output neurons to hook up. Save that change for the big NEAT update where creature
            // ... topologies can morph and differ within a population.
            Debug.Log("BROKEN!! MiniGameManager public void SetMiniGameType(MiniGameManager.MiniGameType newGameType)");
			CritterGenome templateBody = playerRef.masterPopulation.templateGenome;
			//MiniGameCreatureSwimBasic newGameInstance = new MiniGameCreatureSwimBasic(templateBody);
			//miniGameInstance = newGameInstance;
		}*/
		else if(newGameType == MiniGameType.CritterWalkBasic) {
            CritterGenome templateBody = playerRef.masterPopulation.templateGenome;
            //Debug.Log("playerRef.masterPopulation.templateBodyGenome: " + playerRef.masterPopulation.templateBodyGenome.creatureBodySegmentGenomeList[0].addOn1.ToString());
            //Debug.Log("templateBody: " + templateBody.creatureBodySegmentGenomeList[0].addOn1.ToString());
			MiniGameCritterWalkBasic newGameInstance = new MiniGameCritterWalkBasic(templateBody);
            newGameInstance.UseSettings((MiniGameCritterWalkBasicSettings)gameSettings);
            newGameInstance.InitializeGame();
			miniGameInstance = newGameInstance;
            Debug.Log("miniGameInstance.inputChannelsList.Count: " + miniGameInstance.inputChannelsList.Count.ToString() + "miniGameInstance.outputChannelsList.Count: " + miniGameInstance.outputChannelsList.Count.ToString());
		}
		/*else if(newGameType == MiniGameType.RobotArmSimple) {
			MiniGameRobotArm newGameInstance = new MiniGameRobotArm();
			miniGameInstance = newGameInstance;
		}
		else if(newGameType == MiniGameType.PhysXWorm) {
			MiniGamePhysXWorm newGameInstance = new MiniGamePhysXWorm();
			miniGameInstance = newGameInstance;
		}
		else if(newGameType == MiniGameType.BallCatch) {
			MiniGameBallCatch newGameInstance = new MiniGameBallCatch();
			miniGameInstance = newGameInstance;
		}
		else if(newGameType == MiniGameType.ObstacleNavigation) {
			MiniGameObstacleNavigation newGameInstance = new MiniGameObstacleNavigation();
			miniGameInstance = newGameInstance;
		}
		else if(newGameType == MiniGameType.PoleBalancing2D) {
			MiniGamePoleBalancing2D newGameInstance = new MiniGamePoleBalancing2D();
			miniGameInstance = newGameInstance;
		}
		else if(newGameType == MiniGameType.SpaceshipShooter) {
			MiniGameSpaceshipShooter newGameInstance = new MiniGameSpaceshipShooter();
			miniGameInstance = newGameInstance;
		}*/

		SetInputOutputArrays(); // Haven't set input/output lists for the minigame yet....
	}