Inheritance: MonoBehaviour, IDifficultyBasedBuilderPicking
        public override CommercialLevelUp OnCalculateCommercialLevelUp(CommercialLevelUp levelUp, int averageWealth, int landValue, ushort buildingID, Service service, SubService subService, Level currentLevel)
        {
            DifficultyManager d = Singleton <DifficultyManager> .instance;

            if (levelUp.landValueProgress != 0)
            {
                Level targetLevel;

                int target2 = d.CommercialTargetLandValue.GetValue(Level.Level2);
                int target3 = d.CommercialTargetLandValue.GetValue(Level.Level3);

                if (landValue < target2)
                {
                    targetLevel = Level.Level1;
                    levelUp.landValueProgress = 1 + (int)(15f * landValue / target2 + 0.49f);
                }
                else if (landValue < target3)
                {
                    targetLevel = Level.Level2;
                    levelUp.landValueProgress = 1 + (int)(15f * (landValue - target2) / (target3 - target2) + 0.49f);
                }
                else
                {
                    targetLevel = Level.Level5;
                    levelUp.landValueProgress = 1;
                }

                if (targetLevel < currentLevel)
                {
                    levelUp.landValueProgress = 1;
                }
                else if (targetLevel > currentLevel)
                {
                    levelUp.landValueProgress = 15;
                }

                if (targetLevel < levelUp.targetLevel)
                {
                    levelUp.targetLevel = targetLevel;
                }
            }

            levelUp.landValueTooLow = false;
            if (currentLevel == Level.Level2)
            {
                if (landValue < d.CommercialTargetLandValue.GetTooLowValue(Level.Level2))
                {
                    levelUp.landValueTooLow = true;
                }
            }
            else if (currentLevel == Level.Level3)
            {
                if (landValue < d.CommercialTargetLandValue.GetTooLowValue(Level.Level3))
                {
                    levelUp.landValueTooLow = true;
                }
            }

            return(levelUp);
        }
        public override OfficeLevelUp OnCalculateOfficeLevelUp(OfficeLevelUp levelUp, int averageEducation, int serviceScore, ushort buildingID, Service service, SubService subService, Level currentLevel)
        {
            DifficultyManager d = Singleton <DifficultyManager> .instance;

            if (levelUp.serviceProgress != 0)
            {
                Level targetLevel;

                int target2 = d.OfficeTargetScore.GetValue(Level.Level2);
                int target3 = d.OfficeTargetScore.GetValue(Level.Level3);

                if (serviceScore < target2)
                {
                    targetLevel             = Level.Level1;
                    levelUp.serviceProgress = 1 + (int)(15f * serviceScore / target2 + 0.49f);
                }
                else if (serviceScore < target3)
                {
                    targetLevel             = Level.Level2;
                    levelUp.serviceProgress = 1 + (int)(15f * (serviceScore - target2) / (target3 - target2) + 0.49f);
                }
                else
                {
                    targetLevel             = Level.Level5;
                    levelUp.serviceProgress = 1;
                }

                if (targetLevel < currentLevel)
                {
                    levelUp.serviceProgress = 1;
                }
                else if (targetLevel > currentLevel)
                {
                    levelUp.serviceProgress = 15;
                }

                if (targetLevel < levelUp.targetLevel)
                {
                    levelUp.targetLevel = targetLevel;
                }
            }

            levelUp.tooFewServices = false;
            if (currentLevel == Level.Level2)
            {
                if (serviceScore < d.OfficeTargetScore.GetTooLowValue(Level.Level2))
                {
                    levelUp.tooFewServices = true;
                }
            }
            else if (currentLevel == Level.Level3)
            {
                if (serviceScore < d.OfficeTargetScore.GetTooLowValue(Level.Level3))
                {
                    levelUp.tooFewServices = true;
                }
            }

            return(levelUp);
        }
        public override int OnGetMaintenanceCost(int originalMaintenanceCost, Service service, SubService subService, Level level)
        {
            DifficultyManager d = Singleton <DifficultyManager> .instance;
            int multiplier;

            if (service == Service.Road)
            {
                multiplier = d.MaintenanceCostMultiplier_Road.Value;
            }
            else if (service == Service.PublicTransport)
            {
                multiplier = d.MaintenanceCostMultiplier_Public.Value;
            }
            else if (service == Service.Education || service == Service.Electricity || service == Service.FireDepartment ||
                     service == Service.Garbage || service == Service.HealthCare || service == Service.PoliceDepartment || service == Service.Water)
            {
                multiplier = d.MaintenanceCostMultiplier_Service.Value;
            }
            else
            {
                multiplier = d.MaintenanceCostMultiplier.Value;
            }

            return((int)(0.01f * originalMaintenanceCost * multiplier + 0.99f));
        }
Example #4
0
    public void StartNextWave()
    {
        if (!waveInProgress)
        {
            wave++;
            waveInProgress = true;
            spawnCurrency  = wave * waveMultiplier;
            spawnSpeed    += spawnSpeedIncrease;
            cannotSpawn.Clear();

            AudioManager.Play_Static("Trumpets");

            float trueAmbushChance = 0;
            if (wave > 5)
            {
                trueAmbushChance = (DifficultyManager.difficultyLevel) * ambushChance;
            }

            if (trueAmbushChance > Random.value)
            {
                spawnPos = new Vector2(spawnBox.x, Random.Range(-spawnBox.y, spawnBox.y));
                DifficultyManager.UpdateDifficulty(0.8f);
            }
            else
            {
                spawnPos = new Vector2(-spawnBox.x, 0);
                DifficultyManager.UpdateDifficulty();
            }

            spawnChanceScript.UpdateSpawnChances(wave);
            StartCoroutine("SpawnWave");
        }
    }
Example #5
0
    // Update is called once per frame
    void Update()
    {
        if (_onDifficultyScreen)
        {
            if (Utils.Clicked())
            {
                int size = _results.Count;
                _ped.position = Utils.GetClickedPosition();
                _raycaster.Raycast(_ped, _results);
                if (_results.Count > size)
                {
                    Debug.Log("clicked : " + _results[size].gameObject.name);
                    Button clicked = _results[size].gameObject.GetComponent <Button>();
                    if (clicked != null)
                    {
                        if (!clicked.IsInteractable())
                        {
                            return;
                        }

                        if (DifficultyManager.isDifficultyValid(clicked.tag))
                        {
                            DifficultyManager.PICKED_DIFFICULTY = clicked.tag;
                            LoadGame(_selectedGame);
                        }
                    }
                }
            }
        }
    }
 public void SpawnNextWave()
 {
     isSpawning     = true;
     enemiesSpawned = 0;
     enemiesToSpawn = DifficultyManager.CalculateEnemiesToSpawn();
     StartCoroutine(SpawnDelay());
 }
Example #7
0
    public void LoadDifficultyScreen(int gameId)
    {
        _selectedGame = gameId;

        foreach (Button button in _difficultyButtons)
        {
            string difficulty = button.tag;
            Image  icon       = button.transform.GetChild(1).GetComponent <Image>();
            if (DifficultyManager.isDifficultyUnlocked(difficulty, _selectedGame))
            {
                button.interactable = true;
                icon.sprite         = _unlockedSprite;
            }
            else
            {
                button.interactable = false;
                icon.sprite         = _lockedSprite;
            }
        }

        if (gameId == DifficultyManager.ID_SIMON)
        {
            _tutoButton.interactable = true;
        }
        else
        {
            _tutoButton.interactable = false;
        }

        ShowLevelPicking();
    }
Example #8
0
        public override void OnLevelLoaded(LoadMode mode)
        {
            EconomyManager    em = Singleton <EconomyManager> .instance;
            DifficultyManager d  = Singleton <DifficultyManager> .instance;

            if (mode == LoadMode.NewGame)
            {
                int moneyToAdd = (d.InitialMoney.Value - 70) * 100000;
                em.AddResource(EconomyManager.Resource.LoanAmount, moneyToAdd, ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Level.None);
            }

            if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame)
            {
                for (int i = 0; i < 3; i++)
                {
                    EconomyManager.Bank     bank = em.m_properties.m_banks[i];
                    EconomyManager.LoanInfo li   = bank.m_loanOffers[0];

                    int newAmount = (int)Math.Round(li.m_amount * 0.01f * d.LoanMultiplier.Value);
                    int newLength = (int)Math.Round(li.m_length * (1 + 0.01f * d.LoanMultiplier.Value) / 2f); // Halve the effect to prevent too long loan length.
                    Helper.ValueChangedMessage(bank.m_bankName, "Loan amount", li.m_amount, newAmount);
                    Helper.ValueChangedMessage(bank.m_bankName, "Loan length", li.m_length, newLength);
                    li.m_amount = newAmount;
                    li.m_length = newLength;

                    bank.m_loanOffers[0]       = li;
                    em.m_properties.m_banks[i] = bank;
                }
            }

            Achievements.Update();

            PrefabsManager.UpdatePrefabs(false);
            NetManager.UpdateSlopes(false);
        }
Example #9
0
    // Start is called before the first frame update
    public override void Start()
    {
        // set up difficulty mods
        DifficultyManager difficultyManager = DifficultyManager.instance;

        healthMax          = healthMax * difficultyManager.getHealthMod();
        moveSpeedX        *= difficultyManager.getMoveSpeedMod();
        moveSpeedY        *= difficultyManager.getMoveSpeedMod();
        fireDelay         /= difficultyManager.getFiringSpeedMod();
        fireDelayVariance /= difficultyManager.getFiringSpeedMod();

        base.Start();

        // randomize the firing timer
        fireTimer = Random.Range(0f, fireDelay) + Random.Range(-fireDelayVariance, fireDelayVariance);

        // randomize direction? if we want to
        if (randomizeStartDirection && Random.Range(0, 2) == 1)
        {
            moveSpeedX *= -1f;
        }

        // add the enemy to the game manager for tracking
        GameManager.instance.EnemySpawned();
    }
Example #10
0
 void Start()
 {
     playerStats       = GameObject.Find("Player").GetComponent <PlayerDataManager>();
     collisionStats    = GameObject.Find("CollisionDataManager").GetComponent <CollisionDataManager>();
     player            = GameObject.Find("Player");
     difficultyManager = GameObject.Find("DifficultyManager").GetComponent <DifficultyManager> ();
 }
Example #11
0
    public void HandleBarrelHit(GameObject barrelObjHit)
    {
        HandleBarrelBeat(barrelObjHit);

        float rotationDuration = DifficultyManager.MoveDurationBasedOnDifficulty();

        Barrel barrelObjHitBarrelScript = barrelObjHit.gameObject.GetComponent <Barrel>();

        barrelObjHitBarrelScript.HoldPlayer();

        int potentialNextBarrelIndex = barrels.IndexOf(barrelHolingPlayer) + 1;

        nextBarrel = potentialNextBarrelIndex < barrels.Count ? barrels[potentialNextBarrelIndex] : null;

        if (barrelsToJump > 0)
        {
            barrelObjHitBarrelScript.AutoFire(0.5f);
            barrelsToJump--;
        }
        else
        {
            MoveBehaviour barrelObjHitMoveBehaviour = barrelObjHit.gameObject.GetComponent <MoveBehaviour>();
            barrelObjHitMoveBehaviour.Activate(); //barrel will only move after the move duration, witch is the rotation duration
            barrelObjHitMoveBehaviour.RotateToInitialAngle(rotationDuration);
        }



        if (nextBarrel)
        {
            FocusCameraOnBarrel(nextBarrel);
        }

        HandleBarrelsJumped();
    }
    void Start()
    {
        difficultyManager = new DifficultyManager();
        new ServiceLocator ();
        ServiceLocator.addService<IProcessorFSM> (new ProcessorFSM ());
        ServiceLocator.addService<IProcessorPatternConfiguration> (new ProcessorPatternConfigurator ());
        ServiceLocator.addService<IBladeSectionDifficulty>(difficultyManager);
        levelData = new LevelData();
        poolManager = new GameObjectPoolManager();
        testSectionBuilderConfigurator = new SectionBuilderConfigurator(levelData) as ISectionBuilderConfiguration;
        testSectionBuilderSeclector = new SectionBuilderSelector(testSectionBuilderConfigurator, levelData) as ISectionBuilderSelection;

        SectionBuilderClear clearBuilder = new SectionBuilderClear();
        SectionBuilderBlades bladesBuilder = new SectionBuilderBlades(levelData, poolManager);
        SectionBuilderProcessors processorsBuilder = new SectionBuilderProcessors (levelData, poolManager);
        testSectionBuilderSeclector.addSectionBuilder(clearBuilder);
        testSectionBuilderSeclector.addSectionBuilder(bladesBuilder);
        testSectionBuilderSeclector.addSectionBuilder(processorsBuilder);

        levelData.activeSectionBuilder = clearBuilder;

        testSectionDesigner = new SectionDesigner(testSectionBuilderSeclector, levelData) as ISectionDesigning;
        rowCleaner = new RowCleaner(poolManager);
        testLevelHandler = new LevelHandler(levelData, testSectionDesigner, rowCleaner);

        for (int i = 0; i < 50; ++i)
        {
            testLevelHandler.buildNewRow();
        }
    }
Example #13
0
// --> Init Random value using the selected difficulty
    public void initRandomValue()
    {
        GameObject tmpObj = GameObject.Find("Game_Manager");

        if (tmpObj)
        {
            difficultyManager = tmpObj.GetComponent <DifficultyManager> ();
        }

        if (difficultyManager != null && carController != null && carController.playerNumber != 1)
        {
            //if(carController.playerNumber - 2 < 3){
            carController.offsetSpeedDifficultyManager = difficultyManager.difficulties[PlayerPrefs.GetInt("DifficultyChoise")].addGlobalSpeedOffset[carController.playerNumber - 2];
            successRate_BestTargetPos = difficultyManager.difficulties[PlayerPrefs.GetInt("DifficultyChoise")].waypointSuccesRate[carController.playerNumber - 2];
            TargetPosMin = difficultyManager.difficulties[PlayerPrefs.GetInt("DifficultyChoise")].waypointMinTarget[carController.playerNumber - 2];
            TargetPosMax = difficultyManager.difficulties[PlayerPrefs.GetInt("DifficultyChoise")].waypointMaxTarget[carController.playerNumber - 2];
            successRate_BestOffsetSpeed = difficultyManager.difficulties[PlayerPrefs.GetInt("DifficultyChoise")].speedSuccesRate[carController.playerNumber - 2];
            offsetSpeedMin = difficultyManager.difficulties[PlayerPrefs.GetInt("DifficultyChoise")].speedOffset[carController.playerNumber - 2];
            successRate_BestOffsetRandomEulerAngle = difficultyManager.difficulties[PlayerPrefs.GetInt("DifficultyChoise")].rotationSuccesRate[carController.playerNumber - 2];
            offsetRandomEulerAngleMin = difficultyManager.difficulties[PlayerPrefs.GetInt("DifficultyChoise")].rotationOffset[carController.playerNumber - 2];

            F_RandomCarValues();
            //}
        }
    }
    private void Awake() {
        DifficultyManager = GetComponent<DifficultyManager>();

        if(DifficultyManager == null) {
            throw new MissingComponentException("No DifficultyManager found");
        }
    }
        public override void OnLevelLoaded(LoadMode mode)
        {
            EconomyManager    em = Singleton <EconomyManager> .instance;
            DifficultyManager d  = Singleton <DifficultyManager> .instance;

            if (mode == LoadMode.NewGame)
            {
                int moneyToAdd = (d.InitialMoney.Value - 70) * 100000;
                em.AddResource(EconomyManager.Resource.LoanAmount, moneyToAdd, ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Level.None);
            }

            if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame)
            {
                for (int i = 0; i < 3; i++)
                {
                    EconomyManager.Bank     bank = em.m_properties.m_banks[i];
                    EconomyManager.LoanInfo li   = bank.m_loanOffers[0];

                    li.m_amount = (int)Math.Round(0.01f * li.m_amount * d.LoanMultiplier.Value);
                    li.m_length = (int)Math.Round(0.01f * li.m_length * d.LoanMultiplier.Value);

                    bank.m_loanOffers[0]       = li;
                    em.m_properties.m_banks[i] = bank;
                    //DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, bank.m_bankName);
                }
            }

            Achievements.Update();

            PrefabsManager.UpdatePrefabs(false);
        }
Example #16
0
 public void SetWord(string newWord)
 {
     latestAskDuration  = DifficultyManager.GetAskDuration();
     TimeRemainingOnAsk = latestAskDuration;
     CurrentWord        = newWord.Trim();
     WorkDone           = 0;
 }
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
    private void OnGameplayFadeOutCallback()
    {
        bgMng.StartBackground();
        videoAlreadyWhatched = false;

        DifficultyManager.StartGame();

        int firstGame = PlayerPrefs.GetInt("Tutorial", 0);

        if (firstGame == 0)
        {
            readInput  = false;
            isTutorial = true;
            tutorialTimes++;
            gameplayPanel.EnableTutorialPanel(true);
            spawnCtrl.StartSpawn(ShapeController.GetShapeByIndex(ShapeController.GetCurrentShapeIndex() - 1));
            CoroutineController.StartRoutine(StartTutotrial, 6.5f);
        }
        else
        {
            spawnCtrl.StartSpawn();
            readInput  = true;
            isTutorial = false;
        }

        startState = true;
    }
Example #19
0
    public void RestartGame()
    {
        EndGame();

        barrelsBeat = initialBarrelsBeat;

        player.SetActive(true);
        player.GetComponent <Player>().ResetRB2DForcesAndGravity();

        DifficultyManager.UpdateDifficulty();
        for (int i = 0; i < INITIAL_BARRELS; i++)
        {
            BarrelGenerator.inst.GenerateBarrel(DifficultyManager.currentDifficulty);
            initialBarrelsSpawned++;
            DifficultyManager.UpdateDifficulty();
        }

        barrels[0].GetComponent <Barrel>().HoldPlayer();
        barrels[0].GetComponent <MoveBehaviour>().Activate();
        nextBarrel = barrels[1];

        mainCameraScript.target         = barrelHolingPlayer.transform;
        mainCameraScript.fixedYPosition = barrelHolingPlayer.transform.position.y;

        gameplayIsRunning = true;
        StartCoroutine(RestartIfPlayerDies());
        StartCoroutine(DestroyBarrelsInExcess());
    }
Example #20
0
    private void Awake()
    {
        pointTimerStore = pointTimer;

        healthStore = health;

        difficultyManager = FindObjectOfType <DifficultyManager>();
    }
Example #21
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "projectile")
     {
         takeDamage(2 * DifficultyManager.getAttackMultiplier());
         //Destroy(other.gameObject);
     }
 }
 private void OnCollisionStay2D(Collision2D other)
 {
     if (other.gameObject.name == "Player" && m_GhostState != GhostState.Inactive)
     {
         // Debug.Log("m_GhostState="+ m_GhostState);
         other.gameObject.GetComponent <Player>().takeDamage(attackPower * DifficultyManager.getAttackMultiplier());
     }
 }
Example #23
0
 void Awake()
 {
     lineSpawner       = GameObject.FindGameObjectWithTag("LineSpawner").GetComponent <CubeSpawner>();
     musicManager      = GameObject.FindGameObjectWithTag("MusicManager").GetComponent <MusicManager>();
     scoreManager      = GameObject.FindGameObjectWithTag("ScoreManager").GetComponent <ScoreManager>();
     difficultyManager = GameObject.FindGameObjectWithTag("DifficultyManager").GetComponent <DifficultyManager>();
     playerController  = GameObject.Find("Player").GetComponent <PlayerController>();
 }
Example #24
0
 // If user wants to quit using Task Manager.
 private void OnApplicationPause(bool pause)
 {
     if (pause)
     {
         DifficultyManager.Save();
         ScoreManager.Save();
     }
 }
        private int scaleDemandByDifficulty(int demandValue)
        {
            DifficultyManager d = Singleton <DifficultyManager> .instance;

            float value = 0.01f * (demandValue + d.DemandOffset.Value) * d.DemandMultiplier.Value;

            return(Math.Min(100, (int)Math.Round(value))); // Limit to 100 to avoid possible uncompatibility with other mods
        }
 public static DifficultyManager getInstance()
 {
     if (instance == null)
     {
         instance = new DifficultyManager();
     }
     return(instance);
 }
Example #27
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.name == "Player")
        {
            other.gameObject.GetComponent <Player>().takeDamage(5 * DifficultyManager.getAttackMultiplier());

            DestroyThis();
        }
    }
Example #28
0
 // Update is called once per frame
 void Update()
 {
     spawnTimer -= Time.deltaTime;
     if (spawnTimer <= 0.0f)
     {
         StartCoroutine(spawnEnemyWave(getRandomEnemyWaveSpawnPoint()));
         spawnTimer = DifficultyManager.getNextSpawnTimer();
     }
 }
 private void Start()
 {
     cards     = GameObject.FindGameObjectsWithTag("Card");
     lManager  = GameObject.Find("SceneManager").GetComponent <LevelManager>();
     dManager  = GameObject.Find("SceneManager").GetComponent <DifficultyManager>();
     uiManager = GameObject.Find("SceneManager").GetComponent <UIManager>();
     adManager = (AdsManager)FindObjectOfType(typeof(AdsManager));
     countDown = delayDuration;
 }
Example #30
0
    public void Start()
    {
        _cameraText = transform.FindChild("CameraText").gameObject.GetComponentSafe<Text>();
        _guardText = transform.FindChild("GuardText").gameObject.GetComponentSafe<Text>();
        _difficultyManager = DifficultyManager.Instance;

        _cameraText.text = string.Format("{0:D2}", _difficultyManager.GetRequiredBeacons());
        _guardText.text = string.Format("{0:D4}", _difficultyManager.GetChasersPerWave() * 40);
    }
Example #31
0
    // Use this for initialization
    void Start()
    {
        mobCurrentHealth = mobMaxHealth;
        mobDamage        = 5;

        // If game is on peaceful, kills the enemy
        diffMan = FindObjectOfType <DifficultyManager>();
        sfxMan  = FindObjectOfType <SFXManager>();
    }
Example #32
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
     }
     instance = this;
     DontDestroyOnLoad(this.gameObject);
 }
	// Use this for initialization
	void Start ()
    {
        PlayerPrefs.SetString("Difficulty", difficulty);
        PlayerPrefs.SetInt("Score", 0);
        PlayerPrefs.SetInt("Last Scene", 0);
        PlayerPrefs.SetInt("Max Combo", 0);
        singleton = this;
        nextBead = beadInterval;
        MusicManager.singleton.Speed = startSpeed;
	}
Example #34
0
 void Awake()
 {
     instance = this;
 }
Example #35
0
    public void Reset()
    {
        spawnTime = Time.time;
        gameMng = GameManager.instance;
        diffMng = DifficultyManager.instance;

        screenUpperLeft = Camera.main.ScreenToWorldPoint(new Vector3(0, Screen.height, 0));
        screenLowerRight = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0, 0));

        triggers = GetComponents<Collider>();
        poolBehaviour = GetComponent<PooledObjectBehaviour>();

        SetStats();
        ActivateWeapons();

        TrailResetter[] trailResetters = GetComponentsInChildren<TrailResetter>();
        foreach (TrailResetter resetter in trailResetters)
        {
            resetter.Reset();
        }
    }
    void Start()
    {
        if(dManager != null)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            dManager = this;
            DontDestroyOnLoad(this.gameObject);

            //Start on floor 1
            floor = 1;
            buildIndex = SceneManager.GetActiveScene().buildIndex;
            StartCoroutine(setUpFloor());
        }
        
    }