コード例 #1
0
ファイル: HighLowGame.cs プロジェクト: harko12/HighOrLow
 private void Start()
 {
     PlayerData.Pull();
     //PlayerData.Wipe();// for debugging until the ui is done
     if (PlayerData.myWallet.IsEmpty())
     {
         PlayerData.myWallet += new Wallet()
         {
             Coins = 0, Time = 60, Tokens = 10
         };                                                                         // for now, some starting capitol
     }
     if (PlayerData.Level == 0)
     {
         PlayerData.Level = 1;
     }
     if (PlayerData.Stage == 0)
     {
         PlayerData.Stage = 1;
     }
     PlayerData.Push();
     GameProgression.InitGameProgression(this.Levels);
     ProgressPanel.Init(this.Levels, PlayerData);
     currentTimeValues = new TimeUpdateInfo();
     ChooseMission();
 }
コード例 #2
0
 public override void Setup(Circuit circuit, CircuitTile tile)
 {
     this.circuit = circuit;
     this.tile    = tile;
     tile.obj     = this;
     if (gp == null)
     {
         gp = FindObjectOfType <GameProgression>();
     }
 }
コード例 #3
0
ファイル: TestRunner.cs プロジェクト: Aggrathon/LudumDare42
 public void StartTest()
 {
     if (gp == null)
     {
         gp = FindObjectOfType <GameProgression>();
     }
     if (circuit == null)
     {
         circuit = FindObjectOfType <Circuit>();
     }
     block.SetActive(true);
     aborting = false;
     gameObject.SetActive(true);
     RunTest(0);
     successfull = false;
 }
コード例 #4
0
 private void Start()
 {
     PlayerData.Pull();
     PlayerData.Wipe();// for debugging until the ui is done
     if (PlayerData.Level == 0)
     {
         PlayerData.Level = 1;
     }
     if (PlayerData.Stage == 0)
     {
         PlayerData.Stage = 1;
     }
     PlayerData.Push();
     GameProgression.InitGameProgression(this.Levels);
     ProgressPanel.Init(this.Levels);
 }
コード例 #5
0
ファイル: HighLowGame.cs プロジェクト: harko12/HighOrLow
        private IEnumerator Game()
        {
            var continueMission = true;
            var currentMission  = SetCurrentMission(currentMissionIndex);

            yield return(StartCoroutine(MissionChosen(currentMission)));

            // coroutine to show deducting the cost
            ProgressPanel.ToggleMenu();

            currentMission.OverallResult.Reset();
            if (currentMission.UseOverallTime)
            {
                currentMission.OverallResult.TimeRemaining = currentMission.TotalSeconds;
            }

            Debug.LogFormat("starting mission with {0} seconds.", currentMission.OverallResult.TimeRemaining);

            yield return(StartCoroutine(StageStart()));

            var roundResult = new RoundResultInfo(currentMission);

            switch (currentMission.MissionType)
            {
            case MissionTypes.Sprint:
                break;

            case MissionTypes.Survival:
                break;
            }
            Round = 1;
            while (continueMission)
            {
                mCurrentRoundData = GameProgression.GetRound(PlayerData.Level, PlayerData.Stage, Round, LED1.LEDArraySize);
                yield return(StartCoroutine(RoundStart(mCurrentRoundData)));

                var         highMessage  = mCurrentRoundData.High ? "     HIGHER!   " : "     LOWER!   "; // change this to an event or setter call
                ButtonState correctBtn   = mCurrentRoundData.Led1Right ? ButtonState.LEFT : ButtonState.RIGHT;
                ButtonState incorrectBtn = correctBtn == ButtonState.LEFT ? ButtonState.RIGHT : ButtonState.LEFT;
                LEDRendering.Graph(mCurrentRoundData.LEDInfo[0].graphType, LED1,
                                   mCurrentRoundData.LEDInfo[0].StartX, mCurrentRoundData.LEDInfo[0].StartY,
                                   mCurrentRoundData.LEDInfo[0].Count,
                                   mCurrentRoundData.LEDInfo[0].InvertX, mCurrentRoundData.LEDInfo[0].InvertY);

                LEDRendering.Graph(mCurrentRoundData.LEDInfo[1].graphType, LED2,
                                   mCurrentRoundData.LEDInfo[1].StartX, mCurrentRoundData.LEDInfo[1].StartY,
                                   mCurrentRoundData.LEDInfo[1].Count,
                                   mCurrentRoundData.LEDInfo[1].InvertX, mCurrentRoundData.LEDInfo[1].InvertY);

                float timeAdjustment = roundResult.TimeAdjustment;
                roundResult.Reset(Round);

                currentMission.OverallResult.StartTime = Time.time;
                var loop = true;
                ClearButtonState();
                var _gameState        = FinishState.None;
                int progressDashCount = 16;
                updateTimer = true;
                while (loop)
                {
                    //currentMission.TimerTick(mCurrentRoundData);

                    currentTimeValues.SetValues(currentMission.OverallResult.MissionTime, currentMission.OverallResult.Progress, currentMission.UseOverallTime);
                    yield return(StartCoroutine(TimerUpdate(currentTimeValues)));

                    progressDashCount = 16 - (Mathf.RoundToInt(16 * currentMission.OverallResult.Progress));
                    var progressMessage = progressDashCount > 0 ? new string('-', progressDashCount) : "";

                    //              Debug.LogFormat("progress: {0}", progress);
                    if (currentMission.OverallResult.Progress >= 1)
                    {
                        loop       = false;
                        _gameState = FinishState.Timeout;
                        continue;
                    }
                    if (_buttonState == ButtonState.MID)
                    {
                        //Debug.Log("exit");
                        loop       = false;
                        _gameState = FinishState.Quit;
                    }
                    else if (_buttonState == correctBtn)
                    {
                        //Debug.Log("right");
                        loop       = false;
                        _gameState = FinishState.Right;
                    }
                    else if (_buttonState == incorrectBtn)
                    {
                        //Debug.Log("wrong");
                        loop       = false;
                        _gameState = FinishState.Wrong;
                    }
                    yield return(null);
                }
                updateTimer       = false;
                _buttonState      = ButtonState.NONE;
                roundResult.State = _gameState;

                continueMission = currentMission.ProcessRoundResult(roundResult, ref Round);
                yield return(StartCoroutine(RoundComplete(currentMission, roundResult)));
            }
            if (currentMission.OverallResult.ResultType == MissionResultType._Unknown)
            {
                // if at this point it's still unknown, then nothing bad happened.  Success!
                currentMission.OverallResult.ResultType = MissionResultType.Complete;
            }
            yield return(StartCoroutine(StageComplete(currentMission, roundResult)));

            yield return(null);
        }
コード例 #6
0
ファイル: LevelManager.cs プロジェクト: hexmachina/gizmoids
    void HandleAction()
    {
        Act currentAct = currentLevel.actRoster[currentActIndex];

        switch (currentAct.action.actionType)
        {
        case ActionType.SpawnBigScrap:
            int spawnAmount = int.Parse(currentAct.action.argument);
            if (spawnAmount > 0)
            {
                for (int i = 0; i < spawnAmount; i++)
                {
                    CollectibleSpawner.Instance.SpawnBigScrap(false);
                }
            }
            else if (spawnAmount == -1)
            {
                CollectibleSpawner.Instance.SpawnBigScrap(false);
            }
            else
            {
                Debug.LogError("Invalid spawn amount: " + spawnAmount);
            }
            break;

        case ActionType.AddGizmoidButton:
            int gizmoidId = int.Parse(currentAct.action.argument);                     //Argument is gizmoid id
            if (!gameProfile.gizmoids.Contains(gizmoidId))
            {
                gameProfile.gizmoids.Add(gizmoidId);
            }
            //InterfaceController.Instance.CreateGizmoidButton(gizmoidId);
            //InterfaceController.Instance.gizmoidButtonsScripts[InterfaceController.Instance.gizmoidButtonsScripts.Count - 1].startCooled = false;

            break;
        //case ActionType.StartSpawning:

        //	switch (currentAct.action.argument)
        //	{
        //		case "all scrap":
        //			CollectibleSpawner.Instance.SpawningCollectibles = true;
        //			CollectibleSpawner.Instance.SpawningScrap = true;
        //			break;
        //		case "big scrap":
        //			CollectibleSpawner.Instance.SpawningCollectibles = true;
        //			break;
        //		case "small scrap":
        //			CollectibleSpawner.Instance.SpawningScrap = true;
        //			break;
        //		default:
        //			Debug.LogError("Invalid argument for start spawning: \"" + currentAct.action.argument + "\"");
        //			break;
        //	}
        //	break;
        //case ActionType.StopSpawning:
        //	switch (currentAct.action.argument)
        //	{
        //		case "all scrap":
        //			CollectibleSpawner.Instance.SpawningCollectibles = false;
        //			CollectibleSpawner.Instance.SpawningScrap = false;
        //			break;
        //		case "big scrap":
        //			CollectibleSpawner.Instance.SpawningCollectibles = false;
        //			break;
        //		case "small scrap":
        //			CollectibleSpawner.Instance.SpawningScrap = false;
        //			break;
        //		default:
        //			Debug.LogError("Invalid argument for start spawning: \"" + currentAct.action.argument + "\"");
        //			break;
        //	}
        //	break;
        case ActionType.SpawnSmallScrap:
            CollectibleSpawner.Instance.SpawnScrap(int.Parse(currentAct.action.argument), false);
            break;

        //case ActionType.StartEnemyScrapDrop:
        //	//EnemySpawner.Instance.allowEnemyScrapDrop = true;
        //	break;
        //case ActionType.StopEnemyScrapDrop:
        //	//EnemySpawner.Instance.allowEnemyScrapDrop = false;
        //	break;
        case ActionType.InsertGizmoid:
            string[] argumentStrings = Regex.Split(currentAct.action.argument, ";");
            int[]    argumentInts    = new int[3];
            for (int i = 0; i < argumentInts.Length; i++)
            {
                argumentInts[i] = int.Parse(argumentStrings[i]);
            }
            //TODO Fix!
            //BladeView targetBlade = PlayerBladeHandler.Instance.blades.Single(blade => blade.arenaTracker.aisle == argumentInts[1]);
            //GizmoidView gizmoidTracker = targetBlade.gizmoidHolder.AddGizmoid(argumentInts[0]);
            //int damage = gizmoidTracker.health.maxHitpoints - argumentInts[2];
            //Debug.Log("Damage: " + damage);
            //gizmoidTracker.health.TakeDamage(damage);
            break;

        case ActionType.Unlock:
            GameProgression gameProgression = (GameProgression)Enum.Parse(typeof(GameProgression), currentAct.action.argument, true);
            gameProfile.gameProgress.Add(gameProgression);
            //InterfaceController.Instance.UnlockPanel(gameProgression);
            break;

        //case ActionType.StartRarityDrops:
        //	//EnemySpawner.Instance.allowEnemyRareDrop = true;
        //	break;
        //case ActionType.StopRarityDrops:
        //	//EnemySpawner.Instance.allowEnemyRareDrop = false;
        //	break;
        default:
            Debug.LogError("Invalid action type: " + currentAct.action.actionType);
            break;
        }
        actIsInitialized = true;

        IncrementAct();
    }
コード例 #7
0
 public void RulesClicked()
 {
     parseValues();
     var gr = GameProgression.GetRound(lvl, stage, round, led.LEDArraySize);
 }
コード例 #8
0
ファイル: GalaxyTint.cs プロジェクト: Raelr/Game-Studio-1
 // Start is called before the first frame update
 public void ReTint()
 {
     render = GetComponent <Renderer>();
     prog   = GameProgression.instance;
     SetAlpha(map(GameProgression.instance.currentLevel, startLevel, endLevel, startA, endA));
 }
コード例 #9
0
ファイル: Panel.cs プロジェクト: Aggrathon/LudumDare42
 private void Awake()
 {
     gp = FindObjectOfType <GameProgression>();
     Uncollapse();
     if (levelSelect)
     {
         var list   = new List <TMP_Dropdown.OptionData>();
         var levels = gp.maps;
         for (int i = 0; i < levels.Count; i++)
         {
             list.Add(new TMP_Dropdown.OptionData(levels[i].title));
         }
         levelSelect.options = list;
         levelSelect.onValueChanged.AddListener(gp.LoadLevel);
         gp.onLevelChanged.AddListener((h) => { levelSelect.value = h; });
     }
     if (buildButtons)
     {
         mm = FindObjectOfType <MouseManager>();
         for (int i = buildButtons.childCount; i < mm.previews.Length; i++)
         {
             Instantiate(buildButtons.GetChild(0), buildButtons);
         }
         for (int i = 0; i < mm.previews.Length; i++)
         {
             int j = i;
             buildButtons.GetChild(i).GetComponent <Button>().onClick.AddListener(() => SetBuildType(j));
             buildButtons.GetChild(i).GetChild(1).GetComponent <Image>().sprite         = mm.previews[i].icon;
             buildButtons.GetChild(i).GetChild(0).GetComponent <TextMeshProUGUI>().text = mm.previews[i].name;
         }
         gp.onLevelChanged.AddListener((_) => {
             for (int k = 0; k < buildButtons.childCount; k++)
             {
                 buildButtons.GetChild(k).gameObject.SetActive((gp.currentMap.activeComponents & (1 << k)) > 0);
             }
             SetBuildType((int)ComponentType.Empty);
         });
     }
     if (stateButtons)
     {
         gp.onLevelChanged.AddListener((_) => {
             var map = gp.currentMap;
             for (int i = stateButtons.childCount; i < map.states.Length; i++)
             {
                 var b = Instantiate(stateButtons.GetChild(0), stateButtons).GetComponent <Button>();
                 int j = i;
                 b.onClick.RemoveAllListeners();
                 b.onClick.AddListener(() => SetState(j));
             }
             for (int i = map.states.Length; i < stateButtons.childCount; i++)
             {
                 stateButtons.GetChild(i).gameObject.SetActive(false);
             }
             for (int i = 0; i < map.states.Length; i++)
             {
                 var tr = stateButtons.GetChild(i);
                 tr.GetChild(0).GetComponent <TextMeshProUGUI>().text = "Status\n<color=blue>Unknown</color>";
                 tr.GetChild(1).GetComponent <Image>().sprite         = map.DrawState(i);
                 tr.gameObject.SetActive(true);
             }
         });
         gp.onStateChanged.AddListener(SetState);
         gp.onStateValidated.AddListener((l, b) => {
             stateButtons.GetChild(l).GetChild(0).GetComponent <TextMeshProUGUI>().text = b ? "Status:\n<color=green>Passed</color>" : "Status:\n<color=red>Failed</color>";
         });
     }
 }
コード例 #10
0
    private IEnumerator Game()
    {
        var playingRound = true;

        OnStageStart.Invoke();
        while (playingRound)
        {
            var roundData = GameProgression.GetRound(PlayerData.Level, PlayerData.Stage, Round, LED1.LEDArraySize);
            OnRoundStart.Invoke();
            if (Round == 1)
            {
                if (roundData.IntroText != null && roundData.IntroText.Any())
                {
                    int lastLcv = -1;
                    for (int lcv = 0, length = roundData.IntroText.Count; lcv < length; lcv++)
                    {
                        string s1, s2;
                        if (lastLcv < 0)
                        {
                            s1 = "";
                        }
                        else
                        {
                            s1 = roundData.IntroText[lastLcv];
                        }
                        s2 = roundData.IntroText[lcv];
                        LcdWrite(s1, s2);
                        lastLcv++;
                        yield return(new WaitForSeconds(2f));
                    }
                    yield return(new WaitForSeconds(2f));
                }
            }

            var         highMessage  = roundData.High ? "     HIGHER!   " : "     LOWER!   ";
            ButtonState correctBtn   = roundData.Led1Right ? ButtonState.LEFT : ButtonState.RIGHT;
            ButtonState incorrectBtn = correctBtn == ButtonState.LEFT ? ButtonState.RIGHT : ButtonState.LEFT;
            LEDRendering.Graph(roundData.LEDInfo[0].graphType, LED1,
                               roundData.LEDInfo[0].StartX, roundData.LEDInfo[0].StartY,
                               roundData.LEDInfo[0].Count,
                               roundData.LEDInfo[0].InvertX, roundData.LEDInfo[0].InvertY);

            LEDRendering.Graph(roundData.LEDInfo[1].graphType, LED2,
                               roundData.LEDInfo[1].StartX, roundData.LEDInfo[1].StartY,
                               roundData.LEDInfo[1].Count,
                               roundData.LEDInfo[1].InvertX, roundData.LEDInfo[1].InvertY);

            float startTime      = Time.time;
            var   currentSeconds = roundData.WaitSeconds;
            var   loop           = true;
            ClearButtonState();
            var _gameState        = FinishState.None;
            int progressDashCount = 16;
            while (loop)
            {
                currentSeconds = Time.time - startTime;
                float progress = currentSeconds / roundData.WaitSeconds;
                progressDashCount = 16 - (Mathf.RoundToInt(16 * progress));
                var progressMessage = progressDashCount > 0 ? new string('-', progressDashCount) : "";
                LcdWrite(highMessage, progressMessage);
                if (progressDashCount <= 0)
                {
                    loop       = false;
                    _gameState = FinishState.Timeout;
                    continue;
                }
                if (_buttonState == ButtonState.MID)
                {
                    Debug.Log("exit");
                    loop       = false;
                    _gameState = FinishState.Quit;
                }
                else if (_buttonState == correctBtn)
                {
                    Debug.Log("right");
                    loop       = false;
                    _gameState = FinishState.Right;
                }
                else if (_buttonState == incorrectBtn)
                {
                    Debug.Log("wrong");
                    loop       = false;
                    _gameState = FinishState.Wrong;
                }
                yield return(null);
            }
            _buttonState = ButtonState.NONE;
            Debug.Log("round complete");
            switch (_gameState)
            {
            case FinishState.Right:
                LcdWrite("Great job", "");
                var earnedPoints = 100;
                earnedPoints += (progressDashCount * 20);
                Round++;
                if (Round > GameProgression.ROUND_COUNT)     // TODO: make variable for max rounds
                {
                    //PlayerData.Stage++;  // for now, let's not auto progress the stage.
                    if (PlayerData.Stage > GameProgression.STAGE_COUNT)
                    {
                        PlayerData.Level++;
                        earnedPoints    += 5000;
                        PlayerData.Stage = 1;
                    }
                    earnedPoints      += 1000;
                    playingRound       = false;
                    PlayerData.Points += earnedPoints;
                    PlayerData.Push();
                    yield return(StartCoroutine(StageComplete(earnedPoints)));
                }
                break;

            case FinishState.Wrong:
                LcdWrite("you suck", "");
                playingRound = false;
                yield return(StartCoroutine(StageFailed()));

                break;

            case FinishState.Timeout:
                LcdWrite("Time's up", "");
                playingRound = false;
                yield return(StartCoroutine(StageFailed()));

                break;

            case FinishState.Quit:
                LcdWrite("Exiting", "");
                playingRound = false;
                yield return(StartCoroutine(StageQuit()));

                break;
            }
            OnRoundEnd.Invoke();
        }
        OnStageEnd.Invoke();
        yield return(null);
    }