Exemplo n.º 1
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.U))
     {
         PMWrapper.RaiseTaskError("Nu glömde du att göra något...");
     }
 }
Exemplo n.º 2
0
    public void OnPMCompilerStopped(HelloCompiler.StopStatus status)
    {
        PlayerMovement playerMovement = null;

        if (playerObject != null)
        {
            playerMovement = playerObject.GetComponent <PlayerMovement>();
        }

        if (status == HelloCompiler.StopStatus.Finished)
        {
            if (playerMovement != null && playerMovement.AtChargeStation)
            {
                if (!playerMovement.isCharging)
                {
                    PMWrapper.RaiseTaskError("Podden laddades inte. Kom ihåg att ladda().");
                }
            }
            else
            {
                PMWrapper.RaiseTaskError("Podden kom inte hela vägen fram.");
            }
        }
        if (playerMovement != null && !playerMovement.isCharging)
        {
            playerMovement.Reset();
        }
    }
Exemplo n.º 3
0
    public void OnPMCompilerStopped(HelloCompiler.StopStatus status)
    {
        if (status == HelloCompiler.StopStatus.Finished)
        {
            int itemsToUnload = 0;

            foreach (Section section in caseData.cars[0].sections)
            {
                itemsToUnload += section.itemCount;
            }

            if (itemsUnloaded < itemsToUnload)
            {
                int    itemsNotUnloaded      = itemsToUnload - itemsUnloaded;
                string itemsSingularOrPlural = itemsNotUnloaded == 1 ? "1 vara" : itemsNotUnloaded + " varor";
                PMWrapper.RaiseTaskError("Alla varor blev inte avlastade. Nu är det " + itemsSingularOrPlural + " som inte lastas av.");
            }

            if (itemsToUnload == itemsUnloaded)
            {
                PMWrapper.SetCaseCompleted();
            }
        }
        itemsUnloaded = 0;
    }
Exemplo n.º 4
0
    private bool CorrectNumberOfCarsInQueue(string correctType, List <GameObject> queue, string direction)
    {
        if (correctType != "none" && correctType != "whatever")
        {
            var correctNumberOfCars = 0;
            foreach (var car in LevelController.CaseData.cars)
            {
                var currentType = FindTypeFromDefinition(car.sections.First().type);

                if (currentType == correctType)
                {
                    correctNumberOfCars++;
                }
            }

            if (queue.Count < correctNumberOfCars)
            {
                PMWrapper.RaiseTaskError("För få varor sorterades " + direction);
                return(false);
            }
            if (queue.Count > correctNumberOfCars)
            {
                PMWrapper.RaiseTaskError("För många varor sorterade " + direction);
                return(false);
            }
        }
        return(true);
    }
Exemplo n.º 5
0
    private bool CorrectNumberOfCarsInQueue(CorrectSortedQueue bounds, List <GameObject> queue, string direction)
    {
        var correctNumberOfCars = 0;

        foreach (var car in LevelController.CaseData.cars)
        {
            var itemsInCar = 0;
            foreach (var carSection in car.sections)
            {
                itemsInCar += carSection.itemCount;
            }

            if (itemsInCar <= bounds.upperBound && itemsInCar >= bounds.lowerBound)
            {
                correctNumberOfCars++;
            }
        }

        if (queue.Count < correctNumberOfCars)
        {
            PMWrapper.RaiseTaskError("För få tåg sorterades " + direction);
            return(false);
        }
        if (queue.Count > correctNumberOfCars)
        {
            PMWrapper.RaiseTaskError("För många tåg sorterades " + direction);
            return(false);
        }
        return(true);
    }
Exemplo n.º 6
0
    private void CorrectCase()
    {
        int chargeBound = LevelController.CaseData.chargeBound;

        if (CorrectlyCharged == carsToCharge)
        {
            if (FalselyCharged > 0)
            {
                PMWrapper.RaiseTaskError("För många tåg laddades. Bara tåg med batterinivå < " + chargeBound + " ska laddas.");
            }
            else if (CheckChargeCounter < carsToCheck)
            {
                PMWrapper.RaiseTaskError("Alla tåg kollades inte. Se till att köra kolla_batterinivå() för varje tåg.");
            }
            else
            {
                PMWrapper.SetCaseCompleted();
            }
        }
        else
        {
            if (CorrectlyCharged + FalselyCharged == carsToCharge)
            {
                PMWrapper.RaiseTaskError("Fel tåg laddades.");
            }
            else if (CorrectlyCharged + FalselyCharged < carsToCharge)
            {
                PMWrapper.RaiseTaskError("För få tåg laddades. Alla tåg med batterinivå < " + chargeBound + " ska laddas.");
            }
            else
            {
                PMWrapper.RaiseTaskError("För många tåg laddades. Bara tåg med batterinivå < " + chargeBound + " ska laddas.");
            }
        }
    }
Exemplo n.º 7
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         // TODO play crash animation
         PMWrapper.RaiseTaskError("Podden kraschade. Undvik vägarbeten.");
         PMWrapper.StopCompiler();
     }
 }
    private void WinIfCarsUnloaded()
    {
        int carsToUnload = LevelController.CaseData.cars.Count;

        if (carsUnloaded < carsToUnload)
        {
            PMWrapper.RaiseTaskError("Alla tåg tömdes inte. Nu är det " + (carsToUnload - carsUnloaded) + " som inte töms.");
        }
        if (carsToUnload == carsUnloaded)
        {
            PMWrapper.SetCaseCompleted();
        }
    }
    public void OnPMTimeToCorrectCase()
    {
        CheckTooFewInputs();

        if (!string.IsNullOrEmpty(errorMessage))
        {
            PMWrapper.RaiseTaskError(errorMessage);
        }
        else
        {
            PMWrapper.SetCaseCompleted();
        }
    }
    public void OnPMWrongAnswer(string answer)
    {
        int correctAnswer = LevelController.CaseData.answer;
        int guess         = int.Parse(answer.Replace(".", ""));

        if (guess < correctAnswer)
        {
            PMWrapper.RaiseTaskError("Fel svar, rätt svar är större.");
        }
        else if (guess > correctAnswer)
        {
            PMWrapper.RaiseTaskError("Fel svar, rätt svar är mindre.");
        }
    }
Exemplo n.º 11
0
        public void OnPMCompilerStopped(HelloCompiler.StopStatus status)
        {
            if (LevelAnswer != null)
            {
                LevelAnswer.compilerHasBeenStopped = true;
            }

            if (status == HelloCompiler.StopStatus.Finished)
            {
                if (PMWrapper.levelShouldBeAnswered && UISingleton.instance.taskDescription.isActiveAndEnabled)
                {
                    PMWrapper.RaiseTaskError("Fick inget svar");
                }
            }
        }
Exemplo n.º 12
0
    private bool CorrectTypesInQueue(string correctType, List <GameObject> queue, string direction)
    {
        foreach (GameObject car in queue)
        {
            string cargoType = car.GetComponent <CarInfo>().CargoType;

            cargoType = FindTypeFromDefinition(cargoType);

            if ((cargoType != correctType && correctType != "whatever") || correctType == "none")
            {
                PMWrapper.RaiseTaskError("Något blev felsorterat i kön " + direction + ".");
                return(false);
            }
        }
        return(true);
    }
Exemplo n.º 13
0
    public void OnPMCompilerStopped(HelloCompiler.StopStatus status)
    {
        if (status == HelloCompiler.StopStatus.Finished)
        {
            if (CarsSorted < carsToSort)
            {
                PMWrapper.RaiseTaskError("Alla varor sorterades inte.");
            }
            else if (CorrectSorting())
            {
                PMWrapper.SetCaseCompleted();
            }
        }

        SortedQueue.ResetQueues();
    }
        public void OnPMCompilerStopped(PM.HelloCompiler.StopStatus status)
        {
            currentLevel.levelAnswer.compilerHasBeenStopped = true;

            if (status == HelloCompiler.StopStatus.RuntimeError)
            {
                currentLevel.caseHandler.CaseFailed();
            }

            if (status == HelloCompiler.StopStatus.Finished)
            {
                if (PMWrapper.levelShouldBeAnswered)
                {
                    PMWrapper.RaiseTaskError("Fick inget svar");
                }
            }
        }
Exemplo n.º 15
0
    private bool CorrectBoundsInQueue(CorrectSortedQueue bounds, List <GameObject> queue, string direction)
    {
        foreach (GameObject car in queue)
        {
            int itemsInCar = car.GetComponent <CarInfo>().ItemsInCar;

            if (itemsInCar > bounds.upperBound)
            {
                PMWrapper.RaiseTaskError("I tunneln " + direction + " hamnade tåg med för många varor");
                return(false);
            }

            if (itemsInCar < bounds.lowerBound)
            {
                PMWrapper.RaiseTaskError("I tunneln " + direction + " hamnade tåg med för få varor");
                return(false);
            }
        }
        return(true);
    }
Exemplo n.º 16
0
    public static IEnumerator NextInput(GameObject inputValueObject)
    {
        yield return(new WaitForSeconds((1 - PMWrapper.speedMultiplier) * 2));

        if (hasTestDefined && PMWrapper.LevelMode == LevelMode.Case)
        {
            if (inputs == null || inputs.Count == 0)
            {
                PMWrapper.RaiseTaskError("Jag förväntade mig inga inmatningar, så nu vet jag inte vad jag ska mata in.");
            }

            else if (inputIndex > inputs.Count - 1)
            {
                PMWrapper.RaiseTaskError("För många inmatningar. Jag förväntade mig bara " + inputs.Count + " inmatningar.");
            }

            else
            {
                var nextInput = inputs[inputIndex];
                IOStream.Instance.StartCoroutine(inputValueObject.GetComponent <InputValue>().StartInputAnimation(nextInput));
                inputIndex++;
            }
        }
    }
Exemplo n.º 17
0
 public void OnPMWrongAnswer(string answer)
 {
     PMWrapper.RaiseTaskError("\"" + answer + "\" är inte rätt svar");
 }