Esempio n. 1
0
    IEnumerator bonusTimeCount(TimeBonus currentBonus, BonusSlider bonusSlider)
    {
        if (bonusSlider.slider == null) {
            Debug.Log ("Panie ni ma slajdera");
        }
        float bonusDuration = currentBonus.getDuration ();
        Vector3 orginalPos = bonusSlider.slider.transform.position;

        while (bonusSlider.slider.value < bonusDuration) {
            bonusSlider.slider.value =  (Mathf.MoveTowards(bonusSlider.slider.value, bonusDuration, 1f * Time.deltaTime));
            yield return null;
        }

        currentBonus.disactivate ();
        timeBonuses.Remove(currentBonus);
        releasedBonuses.Add(bonusSlider);
        Vector2 pos = bonusSlider.slider.transform.position;
        pos.y += 75f;

        while (Vector3.Distance (bonusSlider.slider.transform.position, pos) > 0.5f) {
            bonusSlider.slider.transform.position = new Vector3(bonusSlider.slider.transform.position.x, Mathf.MoveTowards( bonusSlider.slider.transform.position.y, pos.y, 50f * Time.deltaTime), bonusSlider.slider.transform.position.z);
            yield return null;
        }

        bonusSlider.slider.transform.position = orginalPos;
        bonusSlider.slider.GetComponentInChildren<Image>().sprite = null;
        bonusSlider.slider.GetComponentInChildren<Image>().color = Color.white;
        bonusSlider.slider.value = 0.0f;

        releasedBonuses.Remove(bonusSlider);
    }
Esempio n. 2
0
    void LateUpdate()
    {
        timeLeft  -= Time.deltaTime;
        totalTime += Time.deltaTime;

        ////Generate random time bonus
        if (!timeBonus)
        {
            //calculate random position
            int     randomCheckPoint = Random.Range(0, gameController.checkPoints.Count - 1);
            Vector3 randomPos        = gameController.checkPoints[randomCheckPoint].transform.position + Random.insideUnitSphere * 20;
            randomPos.y        = gameController.timeBonusPrefab.transform.position.y;
            timeBonus          = Instantiate(gameController.timeBonusPrefab, randomPos, gameController.checkPoints[randomCheckPoint].transform.rotation);
            timeBonus.gameMode = this;
        }

        //Update UI
        gameUI.SetTimeLeftTime(timeLeft);
        gameUI.UpdateP1Speed(carPlayer1.ForwardVelocity().magnitude, carPlayer1.maxSpeed);

        //Check gameover
        if (timeLeft <= 0)
        {
            gameController.GameOver();
            gameUI.SetResultText("You lasted " + Mathf.FloorToInt(totalTime) + " seconds");
            timeLeft = 0;
            gameUI.SetTimeLeftTime(timeLeft);
        }
    }
Esempio n. 3
0
 public void registerTimeBonus(TimeBonus newBonus)
 {
     if(timeBonuses.ContainsKey(newBonus))
     {
         timeBonuses[newBonus].slider.value = 0f;
     }
     else {
         timeBonuses.Add (newBonus, spawn (newBonus));
         StartCoroutine(bonusTimeCount (newBonus, timeBonuses [newBonus]));
     }
 }
        private void OnEnemyKilled(LifeControl life)
        {
            var time_bonus   = TimeBonus.GetBonusForTime(life.ScreenTime);
            var enemy_score  = life.score_points_on_destroyed <= 0 ? life.TotalHitPoints : life.score_points_on_destroyed;
            var kill_points  = time_bonus.points_amount + enemy_score;
            var total_points = kill_points * ScoreMultiplier;
            var screenPoint  = life.gameObject.transform.position;

            UI_Scoring.DisplayEnemyPoint(screenPoint, enemy_score, time_bonus.name);
            score += total_points;
            UpdateDisplay();
        }
Esempio n. 5
0
    //clear list of gamepieces (plus potential sublist of gamepieces destroyed by bombs)
    void ClearPiecesAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces)
    {
        //add score bonus if 4 or more pieces cleared
        int bonus = 0;

        if (gamePieces.Count >= 4)
        {
            bonus = 20;
        }

        foreach (GamePiece piece in gamePieces)
        {
            if (piece != null)
            {
                //clear the gamepiece
                ClearPieceAt(piece.xIndex, piece.yIndex);
                MarkAdjacentExplosions(piece.xIndex, piece.yIndex);

                if (GameManager.Instance != null)
                {
                    //add bonus points
                    GameManager.Instance.ScorePoints(piece, m_scoreMultiplier, bonus);

                    //add time bonus if in timed mode
                    TimeBonus timeBonus = piece.GetComponent <TimeBonus>();
                    if (timeBonus != null)
                    {
                        GameManager.Instance.AddTime(timeBonus.bonusValue);
                        Debug.Log("adding time bonus from " + piece.name + " of " + timeBonus.bonusValue);
                    }

                    //update collection goals
                    GameManager.Instance.UpdateCollectionGoals(piece);
                }

                //play particle effects for pieces destroyed
                if (m_particleManager != null)
                {
                    if (bombedPieces.Contains(piece))
                    {
                        m_particleManager.BombFXAt(piece.xIndex, piece.yIndex);
                    }
                    else
                    {
                        m_particleManager.ClearPieceFXAt(piece.xIndex, piece.yIndex);
                    }
                }
            }
        }
    }
Esempio n. 6
0
    void ClearPieceAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces)
    {
        foreach (GamePiece piece in gamePieces)
        {
            if (piece != null)
            {
                ClearPieceAt(piece.xIndex, piece.yIndex);                 //Destroy gamepiece



                int bonus = 0;

                if (gamePieces.Count >= 4)
                {
                    bonus = 20; //per gamepiece.
                }

                if (GameManager.Instance != null)
                {
                    GameManager.Instance.ScorePoints(piece, m_scoreMultiplier, bonus);

                    TimeBonus timeBonus = piece.GetComponent <TimeBonus>();

                    if (timeBonus != null)
                    {
                        GameManager.Instance.AddTime(timeBonus.bonusValue);
                        //Debug.Log("BOARD Adding time bonus from " + piece.name + " of " + timeBonus.bonusValue);
                    }

                    GameManager.Instance.UpdateCollectionGoals(piece);
                    //everytime we clear piece we check collection goals.
                }
                //piece.ScorePoints(m_scoreMultiplier, bonus); //piece to be destroyed, add score but if we destroy immidiately doesn't wait current frame to finish.



                if (m_particleManager != null)
                {
                    if (bombedPieces.Contains(piece))
                    {
                        m_particleManager.BombFXAt(piece.xIndex, piece.yIndex);
                    }
                    else
                    {
                        m_particleManager.ClearPieceFXAt(piece.xIndex, piece.yIndex);
                    }
                }
            }
        }
    }
Esempio n. 7
0
    // clear a list of GamePieces (plus a potential sublist of GamePieces destroyed by bombs)
    public void ClearPieceAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces)
    {
        foreach (GamePiece piece in gamePieces)
        {
            if (piece != null)
            {
                // clear the GamePiece
                ClearPieceAt(piece.xIndex, piece.yIndex);

                // add a score bonus if we clear four or more pieces
                int bonus = 0;
                if (gamePieces.Count >= 4)
                {
                    bonus = 20;
                }

                if (GameManager.Instance != null)
                {
                    GameManager.Instance.ScorePoints(piece, board.scoreMultiplier, bonus);

                    TimeBonus timeBonus = piece.GetComponent <TimeBonus>();

                    if (timeBonus != null)
                    {
                        GameManager.Instance.AddTime(timeBonus.bonusValue);
                        //                        Debug.Log("BOARD Adding time bonus from " + piece.name + " of " + timeBonus.bonusValue + "seconds");
                    }

                    GameManager.Instance.UpdateCollectionGoals(piece);
                }

                // play particle effects for pieces...
                if (board.particleManager != null)
                {
                    // ... cleared by bombs
                    if (bombedPieces.Contains(piece))
                    {
                        board.particleManager.BombFXAt(piece.xIndex, piece.yIndex);
                    }
                    // ... cleared normally
                    else
                    {
                        board.particleManager.ClearPieceFXAt(piece.xIndex, piece.yIndex);
                    }
                }
            }
        }
    }
Esempio n. 8
0
    public BonusSlider spawn(TimeBonus newBonus)
    {
        Slider freeSlider = NextFreePosition ();
        if (freeSlider)
        {
            Image background = freeSlider.GetComponentInChildren<Image>();
            background.sprite = newBonus.GetComponent<SpriteRenderer> ().sprite;
            background.color = Color.black;

            if (freeSlider == null)
            {
                Debug.Log ("Nie stworzyłem go :<");
            }
            return new BonusSlider(freeSlider, freeSlider.transform.position);
        }
        return new BonusSlider(); // do something with that
    }
    private void ClearPieceAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces)
    {
        foreach (GamePiece piece in gamePieces)
        {
            if (piece != null)
            {
                ClearPieceAt(piece.xIndex, piece.yIndex);

                int bonus = 0;

                if (gamePieces.Count >= 4)
                {
                    bonus = 20;
                }

                if (GameManager.Instance != null)
                {
                    GameManager.Instance.ScorePoints(piece, scoreMultiplier, bonus);

                    TimeBonus timeBonus = piece.GetComponent <TimeBonus>();

                    if (timeBonus != null)
                    {
                        GameManager.Instance.AddTime(timeBonus.bonusValue);

                        // Debug.Log("Board: adding time bonus from" +
                        //           piece.name + " of " + timeBonus.bonusValue);
                    }

                    GameManager.Instance.UpdateCollectionGoals(piece);
                }

                if (particleManager != null)
                {
                    if (bombedPieces.Contains(piece))
                    {
                        particleManager.BombFXAt(piece.xIndex, piece.yIndex);
                    }
                    else
                    {
                        particleManager.ClearPieceFXAt(piece.xIndex, piece.yIndex);
                    }
                }
            }
        }
    }
Esempio n. 10
0
    public void ClearBubbleAt(List <Bubble> bubbles, List <Bubble> bombedBubbles)
    {
        foreach (Bubble bubble in bubbles)
        {
            if (bubble != null)
            {
                ClearBubbleAt(bubble.xIndex, bubble.yIndex);

                int bonus = 0;
                if (bubbles.Count >= 4)
                {
                    bonus = 20;
                }

                if (GameManager.Instance != null)
                {
                    GameManager.Instance.ScorePoints(bubble, m_board.scoreMultiplier, bonus);

                    TimeBonus timeBonus = bubble.GetComponent <TimeBonus>();

                    if (timeBonus != null && timeBonus.bonusValue > 0)
                    {
                        GameManager.Instance.AddTime(timeBonus.bonusValue);
                    }

                    GameManager.Instance.UpdateCollectionGoals(bubble);
                }

                if (ParticleManager.Instance != null)
                {
                    if (bombedBubbles.Contains(bubble))
                    {
                        ParticleManager.Instance.BombFXAt(bubble.xIndex, bubble.yIndex);
                    }
                    else
                    {
                        ParticleManager.Instance.ClearBubbleFXAt(bubble.xIndex, bubble.yIndex);
                    }
                }
            }
        }
    }
Esempio n. 11
0
    void ClearPieceAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces)
    {
        foreach (GamePiece piece in gamePieces)
        {
            if (piece != null)
            {
                ClearPieceAt(piece.XIndex, piece.YIndex);
                int bonus = 0;
                if (gamePieces.Count >= 4)
                {
                    bonus = 20;
                }
                if (GameManager.Instance != null)
                {
                    GameManager.Instance.ScorePoints(piece, _scoreMultiplier, bonus);

                    TimeBonus timeBonus = piece.GetComponent <TimeBonus>();

                    if (timeBonus != null)
                    {
                        GameManager.Instance.AddTime(timeBonus.BonusValue);
                    }

                    GameManager.Instance.UpdateCollectionGoals(piece);
                }

                if (_particlManager != null)
                {
                    if (bombedPieces.Contains(piece))
                    {
                        _particlManager.BombFXAt(piece.XIndex, piece.YIndex);
                    }
                    else
                    {
                        _particlManager.ClearPieceFXAt(piece.XIndex, piece.YIndex);
                    }
                }
            }
        }
    }
Esempio n. 12
0
    // clear a list of GamePieces (plus a potential sublist of GamePieces destroyed by bombs)
    public void ClearPieceAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces)
    {
        GameManager.Instance.ScorePoints(board.scoreMultiplier, gamePieces.Count);
        foreach (GamePiece piece in gamePieces)
        {
            if (piece != null)
            {
                // clear the GamePiece
                ClearPieceAt(piece.xIndex, piece.yIndex);

                if (GameManager.Instance != null)
                {
                    GameManager.Instance.SoundAtItemsClear(piece);
                    TimeBonus timeBonus = piece.GetComponent <TimeBonus>();

                    if (timeBonus != null)
                    {
                        GameManager.Instance.AddTime(timeBonus.bonusValue);
                    }

                    GameManager.Instance.UpdateCollectionGoals(piece);
                }

                // play particle effects for pieces...
                if (board.particleManager != null)
                {
                    // ... cleared by bombs
                    if (bombedPieces.Contains(piece))
                    {
                        board.particleManager.BombFXAt(piece.xIndex, piece.yIndex);
                    }
                    // ... cleared normally
                    else
                    {
                        board.particleManager.ClearPieceFXAt(piece.xIndex, piece.yIndex);
                    }
                }
            }
        }
    }
 public TimeBonus GenerateTimeBonus(string type, Vector2 pos)
 {
     string name = "timeBonus-" + type.ToLower();
     TimeBonus toRet = new TimeBonus(m_lvl, pos, m_itemPoints[name], m_itemClr[name], m_itemTimeBonus[name]);
     toRet.Attributes = m_itemAttributes[name];
     return toRet;
 }