Esempio n. 1
0
    public void BuyBonus()
    {
        ShopController  shopController  = FindObjectOfType <ShopController>();
        SceneController sceneController = FindObjectOfType <SceneController>();
        BonusController bonusController = FindObjectOfType <BonusController>();

        m_profile = FindObjectOfType <Profile>();

        if (sceneController.Score >= bonusController.GetPrice(m_type))
        {
            int currScore = sceneController.Score;
            int count     = m_profile.GetBoughtBonus(Type);
            count     += m_bonusCountMultiplier;
            currScore -= (m_price * m_bonusCountMultiplier);
            m_profile.SetScore(currScore);
            m_profile.SetBoughtBonus(Type, count);
            m_profile.Save();
            sceneController.Score = currScore;
            shopController.BuyBonus(m_type);
        }
        else
        {
            Debug.Log("You don't have enough Points!");
        }
    }
Esempio n. 2
0
 void Awake()
 {
     anim     = GetComponent <Animator>();
     bonus    = GameObject.FindGameObjectWithTag("Player").GetComponent <BonusController>();
     spikePos = GameObject.FindGameObjectWithTag("spikePos");
     player   = GameObject.FindGameObjectWithTag("Player");
 }
Esempio n. 3
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
 void Awake()
 {
     bonus   = GameObject.FindGameObjectWithTag("Player").GetComponent <BonusController>();
     enemies = GameObject.FindGameObjectsWithTag("enemy");
     player  = GameObject.FindGameObjectWithTag("Player");
     anim    = GetComponent <Animator>();
 }
Esempio n. 5
0
    public void OnBonusClick()
    {
        BonusController controller = FindObjectOfType <BonusController>();

        controller.CreateBonus(m_type);
        controller.UseBonus(m_type);
    }
Esempio n. 6
0
    // Start is called before the first frame update
    void Awake()
    {
        foreach (var bonus in bonusesToGather)
        {
            bonus.IsCollected += bonusCollected;
        }
        BonusController tmp;

        if (TryGetComponent(out tmp))
        {
            thisbonus                       = tmp;
            thisbonus.enabled               = false;
            gameObject.tag                  = "Untagged";
            thisbonus.IsGettingCorrupted   += SetCorrupted;
            thisbonus.IsGettingUncorrupted += SetUncorrupted;
            foreach (Transform child in transform)
            {
                children.Add(child.gameObject);
            }

            foreach (var child in children)
            {
                child.SetActive(false);
            }
        }
    }
Esempio n. 7
0
    public void SetupGameplay()
    {
        m_referenceImage = m_gameplay.ReferenceImage;
        var initialColor  = m_referenceImage.Colors[0];
        var imageProgress = m_gameplay.ImageProgress;

        m_boardInputController.BoardTileTapped += HandleBoardTileTapped;

        m_hud.Init(m_referenceImage.Colors);
        m_hud.SetPaleteButtonColor(initialColor);
        m_hud.PreviewPressed         += HandlePreviewPressed;
        m_hud.PreviewReleased        += HandlePreviewReleased;
        m_hud.PaletteClicked         += HandlePaletteClicked;
        m_hud.PauseClicked           += HandlePauseClicked;
        m_hud.CheatFillColorsClicked += HandleCheatFillColorsClicked;

        m_board.PreviewEnded += HandleBoardPreviewEnded;
        m_board.SetReferenceImage(m_referenceImage.Texture);
        m_board.SetSize(imageProgress.Width, imageProgress.Height);
        m_board.SetTiles(m_gameplay.ImageProgress.GetTiles());
        m_board.HidePreview();

        m_hud.m_palette.ColorClicked += HandleColorClicked;
        m_hud.m_palette.SetActiveColor(initialColor);
        m_hud.m_tileProgress.SetMax(m_gameplay.ImageProgress.TotalTiles);
        m_hud.m_tileProgress.SetCurrent(m_gameplay.ImageProgress.RevealedTiles);
        m_hud.m_cheatRevealImage.gameObject.SetActive(GameSettings.DevBuild);

        m_hud.m_palette.PaletteShown  += PaletteShown;
        m_hud.m_palette.PaletteClosed += PaletteClosed;

        m_pauseView.ResumeClicked     += HandlePauseViewResumeClicked;
        m_pauseView.BackToMenuClicked += HandlePauseViewBackToMenuClicked;
        m_pauseView.OptionsClicked    += HandlePauseViewOptionsClicked;
        m_pauseView.Hide();

        m_summaryView.BackToMenuClicked += HandleBackToMenuClicked;
        m_summaryView.Hide();

        m_summaryController = new SummaryController(m_board, m_summaryView, m_gameplay, m_boardInputController);

        m_bonusController = new BonusController();
        m_bonusController.Init(m_gameplay, m_bonusView, m_hud);

        m_tutorialView.Hide();
        if (m_gameplay.IsTutorialImage)
        {
            m_tutorial = new TutorialController();
            m_tutorial.Init(m_tutorialView, this);
        }

        var imageViewData = LevelsScene.CreateImageViewData(m_referenceImage, m_gameplay.BundleId);

        m_boardInputController.PauseInput();
        m_board.SetScale(Vector2.zero, m_board.MinScale);
        m_board.SetLocalPosition(Vector2.zero);
        m_levelIntroView.Finished += HandleLevelIntroViewFinished;
        m_levelIntroView.Show(imageViewData);
    }
Esempio n. 8
0
    void Awake()
    {
        Cursor.visible = true;

        bonus      = GetComponent <BonusController>();
        rigid      = GetComponent <Rigidbody>();
        layer_mask = LayerMask.GetMask("floor");
    }
Esempio n. 9
0
 void Start()
 {
     bonusController = GameObject.FindGameObjectWithTag("GameController").GetComponent<BonusController>();
     Rigidbody BoltRigidBody = GetComponent<Rigidbody>();
     Vector3 boltSpread = Random.insideUnitSphere * Spread;
     boltSpread.y = 0.0f;
     BoltRigidBody.velocity = (transform.forward + boltSpread) * Speed;
 }
Esempio n. 10
0
 public void Initialize()
 {
     this.repositoryMock      = new Mock <IBonusRepository>();
     this.plataRepositoryMock = new Mock <IPlataRepository>();
     this.clientController    = new ClientController(new Mock <IClientRepository>().Object, this.plataRepositoryMock.Object,
                                                     new Mock <IConvorbireTelefonicaRepository>().Object, new Mock <IAbonamentRepository>().Object);
     this.controller = new BonusController(repositoryMock.Object, this.clientController);
 }
    void Awake()
    {
        bonus      = GameObject.FindGameObjectWithTag("Player").GetComponent <BonusController>();
        layer_mask = LayerMask.GetMask("floor");
        _collider  = GetComponent <MeshCollider>();
        player     = GameObject.FindGameObjectWithTag("Player");

        parent = transform.parent;
    }
Esempio n. 12
0
    // Use this for initialization
    void Start()
    {
        scoreController    = GameObject.FindObjectOfType <ScoreController>();
        bonusValueText     = gameObject.transform.parent.GetComponentInChildren <Text>();
        bonusController    = GameObject.FindObjectOfType <BonusController>();
        conveyorController = GameObject.FindObjectOfType <ConveyorController>();
        soundController    = GameObject.FindObjectOfType <SoundController>();

        currentBonusValue = baseBonusValue;

        UpdateBonusValueText();
    }
Esempio n. 13
0
    void Update()
    {
        if (m_roof != null)
        {
            int rd = m_roof.GetComponent <Roof>().RoofDurability;
            if (CalcMass() >= rd)
            {
                Destroy(m_roof.gameObject);
                // event roof destroyed
                if (EventRoofDestroyed != null)
                {
                    EventRoofDestroyed();
                }
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            Ray          ray = m_camera.ScreenPointToRay(Input.mousePosition);
            RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);
            if (hit.collider != null)
            {
                Meteor meteor = hit.collider.GetComponent <Meteor>();
                if (meteor != null)
                {
                    Vector2        position = meteor.gameObject.transform.position;
                    ParticleSystem ps       = meteor.GetComponentInChildren <ParticleSystem>();
                    ps.Play();

                    if (meteor.DestroyMeteor())
                    {
                        Score += meteor.ScorePoints * ScoreMultiplier;
                        m_profile.SetScore(m_score);
                        m_meteors.Remove(meteor);
                        BonusController bc = FindObjectOfType <BonusController>();
                        bc.CreateBonusActivator(position);
                        //if (EventMeteorDestroyed != null)
                        //{
                        //    EventMeteorDestroyed();
                        //}
                    }
                }

                BonusActivator ba = hit.collider.GetComponent <BonusActivator>();
                if (ba != null)
                {
                    BonusController bc = FindObjectOfType <BonusController>();
                    bc.AddBonus(ba.Type);
                    Destroy(ba.gameObject);
                }
            }
        }
    }
Esempio n. 14
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            BonusController bonusControler = GameManager.Instance.GetComponent <BonusController>();
            bonusControler.GiveBonus(this.tag, collision.gameObject);


            GetComponent <CircleCollider2D>().enabled = false;
            GetComponent <SpriteRenderer>().enabled   = false;
            Destroy(gameObject);
        }
    }
    private void ResourcesLoaded()
    {
        if (_transitionInfo != null)
        {
            _bonusController = new BonusController();
            _bonusController.Initialize(_timerProvider, _transitionInfo.BonusTypes, OnSetBonus, OnRemoveBonus);
        }
        _roundTimer = _timerProvider.Get();

        FeatureInitializeFinish();

        _roundTimer.StartTimer(_config.GetGameTime(), UpdateTimer, FinishTimer);
        _bonusController.Start();
    }
    public override void Shutdown()
    {
        base.Shutdown();
        if (_bonusController != null)
        {
            _bonusController.Destroy();
            _bonusController = null;
        }

        if (_gameView != null)
        {
            _gameView.DeactivateAndRelease();
            _gameView = null;
        }
    }
Esempio n. 17
0
        public int Score(int comboCount, int ballNumber)
        {
            points        += comboCount;
            txtPoints.text = points.ToString();

            if (ballNumber % 10 == 0)
            {
                int bonus = ballNumber / 10;
                bonus *= BONUS_NUMBER;
                this.bonus.Set("BONUS +" + bonus);
                points += bonus;
            }

            return(comboCount);
        }
Esempio n. 18
0
    private void AddBonus()
    {
        int id;

        do
        {
            id = Random.Range(2, FieldController.MaxCell - 1);
        } while (_level.cells[id - 1]);

        var cell = fieldController.GetCellPosition(id);
        var pos  = new Vector3(cell.x, PlayerController.HalfSize, cell.z);

        _bonus       = Instantiate(bonusPrefab, pos, Quaternion.identity).GetComponent <BonusController>();
        _bonusCellId = id;
    }
Esempio n. 19
0
        private static void CheckGemAndActivateBonus(FieldCell cell)
        {
            switch (cell.Gem.Type)
            {
            case GemType.Bomb:
                ActivatedBombs.Add((FieldCell)cell.Clone());
                GemsController.DeleteGem(cell);
                break;

            case GemType.VerticalLine:
            case GemType.HorizontalLine:
                BonusController.LaunchDestroyers(cell);
                GemsController.DeleteGem(cell);
                break;
            }
        }
Esempio n. 20
0
        private void Awake()
        {
            GetCore   = this;
            GetCoreUI = coreUI;

            gameController   = new GameController(transform.position, paddle, brick, ball);
            paddleController = new PaddleController(gameController.paddle, mainCamera);
            ballController   = new BallController(gameController);

            controllers = new List <BaseController>()
            {
                gameController,
                paddleController,
                ballController
            };

            bonusController = new BonusController(bonusSprites, bonus);
            coreUI.Init(gameController);

            controllers.Add(bonusController);
        }
Esempio n. 21
0
    public void PlayerCollectBonus(BonusController bonus)
    {
        bonus.Collect();
        var path = PathFinder.FindPath(_bonusCellId, _level.cells);

        if (path == null)
        {
            return;
        }
        path.RemoveAt(0);
        var positions = new List <Vector3>(_level.powerUpMoves);

        for (var i = 0; i < path.Count; i++)
        {
            if (i > _level.powerUpMoves - 1)
            {
                break;
            }
            positions.Add(fieldController.GetCellPosition(path[i]));
        }
        _player.MoveOnPath(positions);
    }
Esempio n. 22
0
    // Use this for initialization
    void Start()
    {
        gameController     = GameObject.FindObjectOfType <GameController>();
        conveyorController = GameObject.FindObjectOfType <ConveyorController>();
        bonusController    = GameObject.FindObjectOfType <BonusController>();
        soundController    = GameObject.FindObjectOfType <SoundController>();

        gameObject.transform.position = new Vector3(startXPos, transform.position.y, transform.position.z);

        currentXPos = startXPos;
        endGame     = false;

        foreach (Grinder grinder in GameObject.FindObjectsOfType <Grinder>())
        {
            grinder.SetBonusValue(gameObject);
        }

        // play entry sound
        if (gameObject.tag != "MiniBoss")
        {
            soundController.PlayStandardEnemyEntryClip();
        }
    }
Esempio n. 23
0
        public override void Update(GameTime gameTime)
        {
            if (IsTimerEnded(gameTime))
            {
                _gameOverWindow?.Update(gameTime);

                return;
            }

            GameBoardConroller.MatchAndClear(GameField);

            UpdateActivatedBonuses();

            UpdateDestroyers(gameTime);

            BonusController.BlowActivatedBombs();

            BonusController.UseDestoyers();

            if (Destroyers.Count == 0)
            {
                GemsController.MoveGems(GameField);

                GemsController.GenerateNewGems(GameField);
            }

            if (IsCurrentMoveImposible())
            {
                return;
            }

            foreach (var cell in GameField)
            {
                cell.Update(gameTime);
                cell.Gem?.Update(gameTime);
            }
        }
Esempio n. 24
0
 public void ActivateBonus()
 {
     bonuses.Sort();
     foreach (TypeOfBonus bonus in bonuses)
     {
         if (slot != null)
         {
             TypeOfBonus typeBonus = bonus;
             bonuses.Remove(bonus);
             BonusController.ActivateBonus(slot.x, slot.y, typeOfPlanet, typeBonus, typeOfExPlanetBonus);
             break;
         }
         else
         {
             if (slotToMove != null)
             {
                 TypeOfBonus typeBonus = bonus;
                 bonuses.Remove(bonus);
                 BonusController.ActivateBonus(slotToMove.x, slotToMove.y, typeOfPlanet, typeBonus, typeOfExPlanetBonus);
                 break;
             }
         }
     }
 }
 void Awake()
 {
     bonus = GameObject.FindGameObjectWithTag("Player").GetComponent <BonusController>();
 }
Esempio n. 26
0
 void Awake()
 {
     bonusController = this;
 }
 void Start()
 {
     playerShield = Instantiate (playerShieldPrefab);
     playerShield.transform.parent = transform;
     bonusController = FindObjectOfType<BonusController> ();
     #if _DEBUG
     #else
     gameController = FindObjectOfType<GameController> ();
     #endif
     Screen.sleepTimeout = SleepTimeout.NeverSleep;
     playerPlane = new Plane (Vector3.forward, transform.position);
     #if _DEBUG
     transform.position = new Vector3(bounds.xMin - 3f, bounds.yMax - 3f, transform.position.z);
     #endif
     animator = gameObject.GetComponent<Animator> ();
 }
    public void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Shield")
        {
            // 1) ignore BOUNDARY --> boundary will destroy THIS after
            //	  OnTriggerExit of Destroy By Boundary script is called
            // 2) ignore SHIELD --> for unknown reason, shield is collieding
            //	  with the ship in the moment, when the shield is activated...
            return;
        }


        // player ship is hit by ENEMY BULLET
        if (other.tag == "Bullet")
        {
            // fail-safe
            float bullDamage = 20.0f;

            BulletController refBullCtrl = other.gameObject.GetComponent <BulletController>();
            if (refBullCtrl != null)
            {
                bullDamage = refBullCtrl.nesBulletSys.GetDamageCollision();
            }
            else
            {
                Debug.LogWarning("PLAYER >> Unable to obtain damage of bullet, which just hit the player...");
            }

            // destroy enemy's bullet
            Destroy(other.gameObject);

            // show explosion caused by hit
            //Instantiate (refExplosionPlayer, transform.position, transform.rotation);

            bool isAlive = HitShip(bullDamage);

            // show actualized gui texts
            RuntimeContext.GetInst().StorePlayerCore(nesCoreSys.nesLifes.GetLifes(),
                                                     nesCoreSys.nesHealth.GetHealth(),
                                                     nesCoreSys.nesShield.GetShield());

            // store flags for bonus generation into global context container
            RuntimeContext.GetInst().StorePlayerCoreMax(nesCoreSys.nesHealth.IsMaxHealth(),
                                                        nesCoreSys.nesShield.IsMaxShield());

            if (!isAlive)
            {
                PlayerDestruction();
            }
        }
        // player ship is hit by BONUS
        else if (other.tag == "Bonus")
        {
            BonusController refBonCtrl = other.gameObject.GetComponent <BonusController>();
            if (refBonCtrl != null)
            {
                if (refBonCtrl.bonusType == "Energy")
                {
                    // recharge energy & show actualized gui texts
                    RuntimeContext.GetInst().StorePlayerCoreEnergy(
                        nesCoreSys.nesEnergy.RechargeEnergy(refBonCtrl.bonusValue),
                        nesCoreSys.nesEnergy.actualRechargeType);
                }
                else if (refBonCtrl.bonusType == "Shield")
                {
                    // shield was initialized properlly
                    if (refShieldControll != null)
                    {
                        // activate shield's GameObject
                        refShieldControll.gameObject.SetActive(true);

                        // recharge shield & show actualized gui texts
                        RuntimeContext.GetInst().StorePlayerCoreShield(
                            nesCoreSys.nesShield.RechargeShield(refBonCtrl.bonusValue),
                            nesCoreSys.nesShield.IsMaxShield());
                    }
                    else
                    {
                        Debug.LogWarning("PLAYER >> Shield was not initialized properlly, no bonus added...");
                    }
                }
                else if (refBonCtrl.bonusType == "Health")
                {
                    // recharge health & show actualized gui texts
                    RuntimeContext.GetInst().StorePlayerCoreHealth(
                        nesCoreSys.nesHealth.RechargeHealth(refBonCtrl.bonusValue),
                        nesCoreSys.nesHealth.IsMaxHealth());
                }
                else
                {
                    Debug.Log("PLAYER >> Unknown bonus");
                }

                //Debug.Log ("PLAYER >> Bonus >> " + refBonCtrl.bonusType + " >> +" + refBonCtrl.bonusValue + " units");
            }

            // destroy bonus object
            Destroy(other.gameObject);
        }
        //
        else if (other.tag == "Weapon")
        {
            BonusController refBonCtrl = other.gameObject.GetComponent <BonusController>();
            if (refBonCtrl != null)
            {
                bool anyChange = false;

                if (refBonCtrl.bonusType == "AmmoType")
                {
                    bool ammoTypeOk = true;

                    switch (refBonCtrl.bonusMode)
                    {
                    case "Advanced":
                        // check, if `advanced` ammo type can be activated
                        if (nesWeapSys.actualAmmoType == Weapon.eAmmoTypes.Better)
                        {
                            if (!nesWeapSys.Init(nesWeapSys.actualWeaponType,
                                                 Weapon.eAmmoTypes.Advanced,
                                                 false))
                            {
                                ammoTypeOk = false;
                                break;
                            }

                            anyChange = true;
                        }
                        break;

                    case "Hardcore":
                        // check, if `hardcore` ammo type can be activated
                        if (nesWeapSys.actualAmmoType == Weapon.eAmmoTypes.Advanced)
                        {
                            if (!nesWeapSys.Init(nesWeapSys.actualWeaponType,
                                                 Weapon.eAmmoTypes.Hardcore,
                                                 false))
                            {
                                ammoTypeOk = false;
                                break;
                            }

                            anyChange = true;
                        }
                        break;

                    case "Armagedon":
                        // check, if `armagedon` ammo type can be activated
                        if (nesWeapSys.actualAmmoType == Weapon.eAmmoTypes.Hardcore)
                        {
                            if (!nesWeapSys.Init(nesWeapSys.actualWeaponType,
                                                 Weapon.eAmmoTypes.Armagedon,
                                                 false))
                            {
                                ammoTypeOk = false;
                                break;
                            }

                            anyChange = true;
                        }
                        break;

                    default:
                        Debug.LogWarning("PLAYER >> Unknown Ammo Type");
                        break;
                    }

                    if (!ammoTypeOk)
                    {
                        // initialization of new ammo type failed...
                        Debug.LogWarning("PLAYER >> Unable to initialize eAmmoTypes::" + refBonCtrl.bonusMode);
                    }
                }
                else if (refBonCtrl.bonusType == "Weapon")
                {
                    bool weaponSystemOk = true;

                    switch (refBonCtrl.bonusMode)
                    {
                    case "ForwardBetter":
                        // check, if `forward better` weapon type can be activated
                        if (nesWeapSys.actualWeaponType == WeaponSystems.eWeaponTypes.ForwardBasic)
                        {
                            if (!nesWeapSys.Init(WeaponSystems.eWeaponTypes.ForwardBetter,
                                                 Weapon.eAmmoTypes.Better,
                                                 false))
                            {
                                weaponSystemOk = false;
                                break;
                            }

                            anyChange = true;
                        }
                        break;

                    case "ForwardAdvanced":
                        // check, if `forward advanced` weapon type can be activated
                        if (nesWeapSys.actualWeaponType == WeaponSystems.eWeaponTypes.ForwardBetter)
                        {
                            if (!nesWeapSys.Init(WeaponSystems.eWeaponTypes.ForwardAdvanced,
                                                 Weapon.eAmmoTypes.Better,
                                                 false))
                            {
                                weaponSystemOk = false;
                                break;
                            }

                            anyChange = true;
                        }
                        break;

                    case "DirectionalBasic":
                        // check, if `directional basic` weapon type can be activated
                        if (nesWeapSys.actualWeaponType == WeaponSystems.eWeaponTypes.ForwardAdvanced)
                        {
                            if (!nesWeapSys.Init(WeaponSystems.eWeaponTypes.DirectionalBasic,
                                                 Weapon.eAmmoTypes.Better,
                                                 false))
                            {
                                weaponSystemOk = false;
                                break;
                            }

                            anyChange = true;
                        }
                        break;

                    default:
                        Debug.LogWarning("PLAYER >> Unknown Weapon System");
                        break;
                    }

                    if (!weaponSystemOk)
                    {
                        // initialization of new weapon type failed...
                        Debug.LogWarning("PLAYER >> Unable to initialize eWeaponTypes::" + refBonCtrl.bonusMode);
                    }
                }

                if (anyChange)
                {
                    if (!nesWeapSys.ActivateWeapons())
                    {
                        Debug.LogError("PLAYER >> FAILED to activate weapon systems (!!)");
                        anyChange = false;
                    }
                }

                if (anyChange)
                {
                    // store current state of ship systems for next-time loading and bonus generation system
                    RuntimeContext.GetInst().StorePlayerWeapon(nesWeapSys.actualWeaponType,
                                                               nesWeapSys.actualAmmoType);
                }
            }
            else
            {
                Debug.LogError("PLAYER >> FAILED to obtain reference to `BonusController`");
            }

            // destroy bonus object
            Destroy(other.gameObject);
        }
        // player ship is hit by ASTEROID or ENEMY SHIP
        else if (other.tag == "Asteroid" || other.tag == "Enemy")
        {
            bool isAlive = HitShip(GetCollisionDamageRate());

            // show actualized gui texts
            RuntimeContext.GetInst().StorePlayerCore(nesCoreSys.nesLifes.GetLifes(),
                                                     nesCoreSys.nesHealth.GetHealth(),
                                                     nesCoreSys.nesShield.GetShield());

            // store flags for bonus generation into global context container
            RuntimeContext.GetInst().StorePlayerCoreMax(nesCoreSys.nesHealth.IsMaxHealth(),
                                                        nesCoreSys.nesShield.IsMaxShield());

            if (!isAlive)
            {
                PlayerDestruction();
            }
        }
        else
        {
            Debug.Log("PLAYER >> Something just hit the ship (!!) >> " + other.name);
        }
    }
 void Awake()
 {
     bonus   = GameObject.FindGameObjectWithTag("Player").GetComponent <BonusController>();
     _camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Animator>();
     //_col = GetComponent<MeshCollider>();
 }
 private void Awake()
 {
     mcHpBar  = GameObject.FindGameObjectWithTag("mcHp");
     mcHpText = GameObject.FindGameObjectWithTag("mcHpText");
     bonus    = GetComponent <BonusController>();
 }
Esempio n. 31
0
 // Use this for initialization
 void Start()
 {
     shotCounter     = UnityEngine.Random.Range(minTimeBetweenShots, maxTimeBetweenShots);
     gameSession     = FindObjectOfType <GameSession>();
     bonusController = FindObjectOfType <BonusController>();
 }
Esempio n. 32
0
    /// <summary>
    /// Поиск комбинаций
    /// </summary>
    private void FindCombination()
    {
        for (int i = 0; i < sizeField; i++)
        {
            for (int j = 0; j < sizeField; j++)
            {
                planetsInCombination[i, j] = false;
            }
        }

        for (int i = 0; i < sizeField; i++)
        {
            for (int j = 0; j < sizeField; j++)
            {
                planetsAddInCombination[i, j] = false;
            }
        }

        //combination.Clear();

        int  minPlanetsMoveCount = 0;
        Slot bonusSlot           = slots[0, 0];

        for (int i = 0; i < sizeField; i++)
        {
            for (int j = 0; j < sizeField; j++)
            {
                List <Slot> combo = new List <Slot>();
                combo = FindCombinationFromSlot(slots[i, j]);
                if (combo.Count >= 1)
                {
                    switch (combo.Count)
                    {
                    case 1:
                    {
                        combination.Add(combo);
                        break;
                    }

                    case 2:
                    {
                        combination.Add(combo);
                        break;
                    }

                    case 3:
                    {
                        combination.Add(combo);
                        break;
                    }

                    case 4:
                    {
                        minPlanetsMoveCount = 0;
                        foreach (Slot slot in combo)
                        {
                            if (planetsMoveCounter[slot.x, slot.y] >= minPlanetsMoveCount)
                            {
                                minPlanetsMoveCount = planetsMoveCounter[slot.x, slot.y];
                                bonusSlot           = slot;
                            }
                        }
                        if (bonusSlot.planet.CountBonus() == 0)
                        {
                            combo.Remove(bonusSlot);
                        }
                        BonusController.AddLineBonus(bonusSlot);
                        bonusSlot.DestroyEffectActivate();
                        combination.Add(combo);
                        break;
                    }

                    case 5:
                    {
                        minPlanetsMoveCount = 0;
                        boxBonus            = false;

                        if ((combo[0].x == combo[1].x))
                        {
                            foreach (Slot slot in combo)
                            {
                                if (planetsMoveCounter[slot.x, slot.y] >= minPlanetsMoveCount)
                                {
                                    minPlanetsMoveCount = planetsMoveCounter[slot.x, slot.y];
                                    bonusSlot           = slot;
                                }
                                if (combo[0].x != slot.x)
                                {
                                    boxBonus = true;
                                }
                            }
                        }
                        else
                        {
                            foreach (Slot slot in combo)
                            {
                                if (planetsMoveCounter[slot.x, slot.y] >= minPlanetsMoveCount)
                                {
                                    minPlanetsMoveCount = planetsMoveCounter[slot.x, slot.y];
                                    bonusSlot           = slot;
                                }
                                if (combo[0].y != slot.y)
                                {
                                    boxBonus = true;
                                }
                            }
                        }

                        if (bonusSlot.planet.CountBonus() == 0)
                        {
                            combo.Remove(bonusSlot);
                        }

                        if (boxBonus)
                        {
                            BonusController.AddBoxFirstBonus(bonusSlot);
                        }
                        else
                        {
                            BonusController.AddStarBonus(bonusSlot);
                        }

                        bonusSlot.DestroyEffectActivate();
                        combination.Add(combo);
                        break;
                    }

                    default:
                    {
                        minPlanetsMoveCount = 0;
                        boxBonus            = false;

                        if ((combo[0].x == combo[1].x))
                        {
                            foreach (Slot slot in combo)
                            {
                                if (planetsMoveCounter[slot.x, slot.y] >= minPlanetsMoveCount)
                                {
                                    minPlanetsMoveCount = planetsMoveCounter[slot.x, slot.y];
                                    bonusSlot           = slot;
                                }
                                if (combo[0].x != slot.x)
                                {
                                    boxBonus = true;
                                }
                            }
                        }
                        else
                        {
                            foreach (Slot slot in combo)
                            {
                                if (planetsMoveCounter[slot.x, slot.y] >= minPlanetsMoveCount)
                                {
                                    minPlanetsMoveCount = planetsMoveCounter[slot.x, slot.y];
                                    bonusSlot           = slot;
                                }
                                if (combo[0].y != slot.y)
                                {
                                    boxBonus = true;
                                }
                            }
                        }

                        if (bonusSlot.planet.CountBonus() == 0)
                        {
                            combo.Remove(bonusSlot);
                        }

                        if (boxBonus)
                        {
                            BonusController.AddBoxFirstBonus(bonusSlot);
                        }
                        else
                        {
                            BonusController.AddStarBonus(bonusSlot);
                        }


                        bonusSlot.DestroyEffectActivate();
                        combination.Add(combo);
                        break;
                    }
                    }
                }
            }
        }

        DestroyCombination();

        //CanPlanetMove = true;

        moveCounter = 0;

        for (int i = 0; i < sizeField; i++)
        {
            for (int j = 0; j < sizeField; j++)
            {
                planetsMoveCounter[i, j] = 0;
            }
        }
    }