コード例 #1
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.S))
     {
         scoreCounter.AddScore(1000);
         settings.SetCheatsEnabled();
     }
     if (Input.GetKeyDown(KeyCode.E))
     {
         energyCounter.AddEnergy(100);
         settings.SetCheatsEnabled();
     }
 }
コード例 #2
0
ファイル: EnemyController.cs プロジェクト: Sainori/Asteroids
        private void SpawnEnemy()
        {
            var enemy = GetEnemyForSpawn();

            enemy.Activate();
            enemy.OnKill += () => _scoreCounter.AddScore(enemy.GetScoreReward());
        }
コード例 #3
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "redball")
     {
         life.IncreaseLife();
         scoreCount.heal(other.gameObject);
         Destroy(other.gameObject);
         if (sound == 0)
         {
             GameObject heal = Instantiate(healSound, this.transform);
             Destroy(heal, 3);
         }
     }
     if (other.gameObject.tag == "ball")
     {
         scoreCount.AddScore(1);
         scoreCount.explode(other.gameObject);
         Destroy(other.gameObject);
         if (sound == 0)
         {
             GameObject sound = Instantiate(stickPopSound, this.transform);
             Destroy(sound, 1);
         }
     }
 }
コード例 #4
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            scoreCounter.AddScore();
            scoreCounter.AddScore();

            AddHealth(halfLife);

            playerRB.bodyType = RigidbodyType2D.Static;

            Debug.Log("Random degree is" + randomDegree);

            StartCoroutine(PushPLayer());
        }
    }
コード例 #5
0
ファイル: Box.cs プロジェクト: R1msky/Unity-Game
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == gameObject.name)
     {
         audioSource.PlayOneShot(audioClip);
         count++;
         timeController.ReturnColor();
         Fruits.getFruits().Remove(fruit.gameObject);
         Destroy(fruit);
         scoreCounter.AddScore();
         fruit = null;
         Fruits.translateFruits();
         Fruits.SpawnNewFruit();
         if (count == 10)
         {
             speed = timeController.getSpeed() + 0.005f;
             timeController.setSpeed(speed);
             count = 0;
         }
     }
     else
     {
         loseSript.ShowLoseMenu();
     }
 }
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.tag == "Player")
     {
         _ScoreCounter.AddScore();
     }
 }
コード例 #7
0
    private void OnTriggerEnter(Collider other)
    {
        var ship = other.GetComponent <SpaceShip>();

        if (ship != null)
        {
            if (ship.GetOwner() != ownerName)
            {
                var hp     = ship.GetHP();
                var result = ship.Damage(GameParams.GetProjectileInfo(type).damage);
                if (result <= 0)
                {
                    ScoreCounter.AddScore(ownerName, 100);
                }
                else
                {
                    ScoreCounter.AddScore(ownerName, hp - result);
                }
                Destruct();
            }
        }
        else
        {
            if (other.name.Contains("Planet"))
            {
                Destruct();
            }
            if (other.name.Contains("Asteroid"))
            {
                other.GetComponent <Asteroid>().Destruct();
                Destruct();
            }
        }
    }
コード例 #8
0
        private void StartCheckingForMove(MatchingTile tile, MatchingTile tile2)
        {
            var tiles = Grid.GetValidTilesGroup(tile);

            tiles.AddRange(Grid.GetValidTilesGroup(tile2));
            if (tiles.Count < MinimumAmountOfGroupedTiles)
            {
                return;
            }

            _audioSource.PlayOneShot(OnMoveSounds[UnityEngine.Random.Range(0, OnMoveSounds.Length)]);
            Grid.PerformMove(tiles, OnExplosionParticles);

            OnMoveParticles.transform.position = new Vector3(tile.transform.position.x, tile.transform.position.y, tile.transform.position.z - 1f);
            OnMoveParticles.Play();

            var score = CalculateScore(tiles.Count);

            ScorePopupText.text           = "+" + score;
            ScorePopup.transform.position = Camera.main.WorldToScreenPoint(tile.transform.position);
            ScorePopup.EnableFor(0.5f);
            OnScoreParticles.transform.position = new Vector3(tile.transform.position.x, tile.transform.position.y, tile.transform.position.z - 1f);
            OnScoreParticles.Play();
            ScoreCounter.AddScore(score);
        }
コード例 #9
0
    protected void OnMouseDown()
    {
        if (ST_PuzzleDisplay.CanMove && !ST_PuzzleDisplay.Instance.Complete)
        {
            ST_PuzzleDisplay.CanMove = false;

            var gridLocation = GridLocation;
            var movePosition = this.transform.parent.GetComponent <ST_PuzzleDisplay>().GetTargetLocation(this.GetComponent <ST_PuzzleTile>());

            if (movePosition == TargetPosition)
            {
                ST_PuzzleDisplay.CanCount = false;
            }

            if (ST_PuzzleDisplay.CanCount)
            {
                ST_PuzzleDisplay.Moves.Add(new STPuzzleMove((int)gridLocation.x, (int)gridLocation.y));
                ST_PuzzleDisplay.PuzzleMoves++;
                ScoreCounter.AddScore();
                ST_PuzzleDisplay.Instance.AudioSource.PlayOneShot(ST_PuzzleDisplay.Instance.OnMoveSound);
            }

            ST_PuzzleDisplay.CanCount = true;

            // get the puzzle display and return the new target location from this tile.
            LaunchPositionCoroutine(movePosition);
        }
    }
コード例 #10
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.name == "Player")
     {
         theScoreCounter.AddScore(scoreToGive);
     }
 }
コード例 #11
0
    protected virtual void OnPlayerBounceOn(object[] data)
    {
        GameObject player   = (GameObject)data[0];
        Vector3    hitPoint = (Vector3)data[1];

        this.hits--;
        if (this.hits <= 0)
        {
            if (scoreCounter)
            {
                scoreCounter.NotifyLastHit(this.transform.position + Vector3.up * 0.8f);
                scoreCounter.AddScore(this.killScore);
            }
            if (this.animator)
            {
                this.animator.SetTrigger("killed");
                this.shrinking = true;
            }
            this.Die();
        }
        else
        {
            if (scoreCounter)
            {
                scoreCounter.NotifyDamage(this.transform.position + Vector3.up * 0.8f);
                scoreCounter.AddScore(this.hitScore);
            }
            if (this.animator)
            {
                this.animator.SetTrigger("hurt");
            }
        }

        GameObject shockWave = Instantiate(particleEffect);

        shockWave.transform.position = this.transform.position;

        // Change color of tv
        if (skin && hits < colors.Length)
        {
            skin.materials[4].color = colors[hits];
            skin.materials[5].color = colors[hits];
        }

        AudioSource.PlayClipAtPoint(this.audioClip, this.transform.position, scoreCounter.GetVolume());
    }
コード例 #12
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.name == "Player")
     {
         scoreCounter.AddScore(scoreIncrease);
         soundEffect.Play();
         gameObject.SetActive(false);
     }
 }
コード例 #13
0
 public void TakeDamage(Weapon weapon, Projectile projectile, Vector3 contactPoint)
 {
     health -= weapon.GetDamage();
     if (health <= 0)
     {
         scoreCounter.AddScore(100);
         Destroy(gameObject);
     }
 }
コード例 #14
0
ファイル: BoardMatch3.cs プロジェクト: Kozhevka/Match3-Core
    MoveStageEnum ChangeStageEnum(MoveStageEnum nextStage)
    {
        movePhaseEnum = nextStage;

        if (movePhaseEnum == MoveStageEnum.PlayerMakeMove)
        {
            scoreMultiplier = 1;
            scoreCounterScript.AddScore(0, 1);
        }

        if (movePhaseEnum == MoveStageEnum.AfterFallCheck)
        {
            bool getMatch = false;


            BlockData[] allBlockData = FindObjectsOfType(typeof(BlockData)) as BlockData[];

            foreach (BlockData _blockData in blocksWhatNeedCheck)
            {
                if (_blockData)
                {
                    if (CheckMatch(_blockData, allBlockData))
                    {
                        getMatch = true;
                    }
                }
            }
            blocksWhatNeedCheck.RemoveAll(BlockData => BlockData == null);

            if (!getMatch)
            {
                ChangeStageEnum(MoveStageEnum.PlayerMakeMove);
            }
            else
            {
                MoveAllBlockDown();
                AddScoreToScoreCounter();
            }
        }
        return(nextStage);
    }
コード例 #15
0
    public void OnBalloonPopped(Balloon.BalloonType balloonType)
    {
        if (!GameManager.IsPaused && !GameManager.GameEnded)
        {
            switch (balloonType)
            {
            case Balloon.BalloonType.standart:
                ScoreCounterScript.AddScore(1);
                break;

            case Balloon.BalloonType.heal:
                ScoreCounterScript.AddScore(1);
                HealsScript.AddHeals(1);
                break;

            case Balloon.BalloonType.bad:
                HealsScript.TakeDamage(3);
                break;
            }
        }
    }
コード例 #16
0
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.transform.GetComponent <MouseController>() != null)
     {
         audioSource.Play();
         animator.SetTrigger("HitTrigger");
         scoreCounter.AddScore(scoreToAdd);
         scoreToAdd *= 2;
         Invoke("DivScoreToAdd", 1f);
         Destroy(collision.gameObject);
         playerSpeed += .2f;
     }
 }
コード例 #17
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "ball")
     {
         scoreCount.AddScore(1);
         scoreCount.explode(other.gameObject);
         Destroy(other.gameObject);
         if (sound == 0)
         {
             GameObject sound = Instantiate(stickPopSound, this.transform);
             Destroy(sound, 1);
         }
     }
 }
コード例 #18
0
 void DamageCube(int DamageValue, float Reward)
 {
     particlerender.material = CubeMaterial;
     // Damage
     CubeHealth -= DamageValue;
     if (CubeHealth <= 0)
     {
         particle.transform.parent = null;
         particle.Emit(10);
         score.AddScore(Reward * GV.rewardMultiplier);
         DestroyCube();
     }
     ApplyColor(Convert.ToInt32(CubeHealth));
 }
コード例 #19
0
ファイル: HealthStats.cs プロジェクト: fabsenet/octo-defence
    public void ApplyDamage(float damageInPonts)
    {
        CurrentHealthPoints = Mathf.Max(CurrentHealthPoints - damageInPonts, 0);

        Debug.Log(name + " took " + damageInPonts + " damage and has now " + CurrentHealthPoints + " health points left");
        if (CurrentHealthPoints <= 0.00001f)
        {
            //dead!
            var deathAnimation = (Transform)Instantiate(DeathAnimationPrefab, gameObject.transform.position, Quaternion.identity);
            deathAnimation.parent = gameObject.transform.parent;
            Destroy(gameObject);
            Destroy(deathAnimation.gameObject, 3);

            ScoreCounter.AddScore(MaxHealthPoints * 100 * Random.Range(0.93f, 1.07f));
        }
    }
コード例 #20
0
    public void TrueAnswer(int score)
    {
        //questionMan.npcDialog.text = text;

        questionMan.nextButton.gameObject.SetActive(true);
        questionMan.nextButton.onClick.RemoveAllListeners();
        foreach (Transform item in questionMan.choiceUI.transform)
        {
            Destroy(item.gameObject);
        }

        scoreMan.AddScore(score);
        SoundControl.PlaySfx(sfx_sound.true_answer);

        questionUI.ShowBenarSalah(true);
        StartCoroutine(LoadNextQuestion());
    }
コード例 #21
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            scoreCounter.AddScore();
            playerRefRB.bodyType = RigidbodyType2D.Static;

            Debug.Log("Target hit!");

            //Gain little health
            AddPlayerHealth(addToHealth);



            StartCoroutine(KillSelf(waitToKillTime));
        }
    }
コード例 #22
0
 public void DoNewLayer()
 {
     if (GV.cubeDifficulty == GV.bCubeScaleStages.Length - 1)
     {
         GV.cubeDifficulty = -1;
         GV.CubeHealth    += 1;
         if (GV.CubeHealth > GV.BreakableCubeColors)
         {
             GV.CubeHealth = GV.BreakableCubeColors;
         }
         GV.rewardMultiplier *= 1.5f;
     }
     GV.LayersCleared++;
     GV.cubeDifficulty++;
     GV.bCubeScale = GV.bCubeScaleStages[GV.cubeDifficulty];
     UpdateBCubeScale();
     RemoveCubes();
     GenerateFullCube();
     GV.tiksPerLayer = 100 * GV.rewardMultiplier;
     score.AddScore(GV.tiksPerLayer);
 }
コード例 #23
0
 private void OnTriggerEnter(Collider other)
 {
     parentobj.SetActive(false);
     scoreCounter.AddScore(coinValue);
 }
コード例 #24
0
        public void OnExchangingCompleted(object parameters)
        {
            var tiles       = (MatchingTile[])parameters;
            var tilesGroup1 = Grid.GetValidTilesGroup(tiles[0]);
            var tilesGroup2 = Grid.GetValidTilesGroup(tiles[1]);

            if (tilesGroup1.Count < MinimumAmountOfGroupedTiles && tilesGroup2.Count < MinimumAmountOfGroupedTiles)
            {
                Grid.ExchangeTiles(tiles[0], tiles[1], (obj) =>
                {
                    ClearMove();
                    _canMove = true;
                });
                return;
            }

            var tilesToPop = new List <MatchingTile>();

            if (tilesGroup1.Count >= MinimumAmountOfGroupedTiles)
            {
                tilesToPop.AddRange(tilesGroup1);
            }
            if (tilesGroup2.Count >= MinimumAmountOfGroupedTiles)
            {
                tilesToPop.AddRange(tilesGroup2);
            }

            _audioSource.PlayOneShot(OnMoveSounds[UnityEngine.Random.Range(0, OnMoveSounds.Length)]);
            foreach (var matchingTile in tilesToPop)
            {
                Grid.PopTile(matchingTile);
            }
            OnMoveParticles.transform.position = new Vector3(tiles[0].transform.position.x, tiles[0].transform.position.y, tiles[0].transform.position.z - 1f);
            OnMoveParticles.Play();
            OnExplosionParticles.transform.position = new Vector3(tilesToPop[tilesToPop.Count - 1].transform.position.x, tilesToPop[tilesToPop.Count - 1].transform.position.y, tilesToPop[tilesToPop.Count - 1].transform.position.z - 1f);
            OnExplosionParticles.Play();
            var score = CalculateScore(tilesToPop.Count);

            ScorePopupText.text           = "+" + score;
            ScorePopup.transform.position = Camera.main.WorldToScreenPoint(tiles[0].transform.position);
            ScorePopup.EnableFor(0.5f);
            OnScoreParticles.transform.position = new Vector3(tiles[0].transform.position.x, tiles[0].transform.position.y, tiles[0].transform.position.z - 1f);
            OnScoreParticles.Play();
            ScoreCounter.AddScore(score);

            Grid.Compact(() =>
            {
                ClearMove();
                if (Grid.IsCompleted())
                {
                    OnVictory();
                }
                _canMove = true;
            });



            /*_grid.OnExchangingCompleted(parameters, () =>
             * {
             *  var tiles = (MatchingTile[])parameters;
             *  StartCheckingForMove(tiles[0], tiles[1]);
             *  //StartCheckingForMove(tiles[1]);
             *  ClearMove();
             *
             *  if (_grid.IsCompleted())
             *  {
             *      OnVictory();
             *  }
             *
             *  _canMove = true;
             * });*/
        }
コード例 #25
0
        private void EndMove(Action callback)
        {
            _isCompleted = CheckForCorrectness();

            for (int i = 0; i < 9; i++)
            {
                var current = Front[i];
                var face    = current.GetFaceWithType(RubikFaceType.Front);
                if (face != null)
                {
                    face.Index = i;
                    face.Type  = RubikFaceType.Front;
                }
            }

            for (int i = 0; i < 9; i++)
            {
                var current = Back[i];
                var face    = current.GetFaceWithType(RubikFaceType.Back);
                if (face != null)
                {
                    face.Index = i;
                    face.Type  = RubikFaceType.Back;
                }
            }

            for (int i = 0; i < 9; i++)
            {
                var current = Left[i];
                var face    = current.GetFaceWithType(RubikFaceType.Left);
                if (face != null)
                {
                    face.Index = i;
                    face.Type  = RubikFaceType.Left;
                }
            }

            for (int i = 0; i < 9; i++)
            {
                var current = Right[i];
                var face    = current.GetFaceWithType(RubikFaceType.Right);
                if (face != null)
                {
                    face.Index = i;
                    face.Type  = RubikFaceType.Right;
                }
            }

            for (int i = 0; i < 9; i++)
            {
                var current = Top[i];
                var face    = current.GetFaceWithType(RubikFaceType.Top);
                if (face != null)
                {
                    face.Index = i;
                    face.Type  = RubikFaceType.Top;
                }
            }

            for (int i = 0; i < 9; i++)
            {
                var current = Bottom[i];
                var face    = current.GetFaceWithType(RubikFaceType.Bottom);
                if (face != null)
                {
                    face.Index = i;
                    face.Type  = RubikFaceType.Bottom;
                }
            }

            if (callback != null)
            {
                callback.Invoke();
            }

            if (!_shuffleMode)
            {
                ScoreCounter.AddScore();
            }

//            if (_isCompleted)
//                CheckForComplete();

            _canMove = true;
        }
コード例 #26
0
        public void StartGamePlay()
        {
            #region Send Teams
            foreach (var client in avatarDictionary)
            {
                // GamePlay is starting - get ready !!!

                string team        = null;
                int    teamCounter = avatarDictionary.Values.ToList().FindIndex(c => c.Equals(client.Value)) + 1;
                if (_numberOfTeams > 0)
                {
                    if (_numberOfTeams == 2)
                    {
                        if (teamCounter % 2 == 0)
                        {
                            team = teamList[1];
                        }
                        else
                        {
                            team = teamList[0];
                        }
                    }
                    else if (_numberOfTeams == 4)
                    {
                        if (teamCounter % 4 == 0)
                        {
                            team = teamList[3];
                        }
                        else if (teamCounter % 4 == 3)
                        {
                            team = teamList[2];
                        }
                        else if (teamCounter % 4 == 2)
                        {
                            team = teamList[1];
                        }
                        else
                        {
                            team = teamList[0];
                        }
                    }
                    client.Value.Team = team;
                }

                client.Key.gamePlayStarted(client.Value.CurrentMapForRobot.SerializeMap(), _roundNumber, team); // send team with initialMap
                EventLog.WriteMessageToLog(strLogPath, "Client: " + client.Value.Login + " is in TEAM: " + team);
            }
            #endregion

            // #region Send visible map
            //foreach (var client in avatarDictionary)
            // client.Key.reciveInitialData(InitialServerResponse.PlayerRegistered(avatarDictionary[client.Key].Color, (int)_roundTime, client.Value.RobotPosition,new MapSize(_currentMap.MapWidth, _currentMap.MapHeight)));
            // #endregion

            _isGameStarted = true;
            _globalHistory = new Dictionary <int, List <ActionHistory> >();

            EventLog.WriteMessageToLog(strLogPath, "GAME IS STARTING!");

            while (_currentRound != _roundNumber)
            {
                EventLog.WriteMessageToLog(strLogPath, "ROUND nr: " + _currentRound + " IS STARTING!");

                if (avatarDictionary.Values.ToList().Exists(rob => rob.ErrorNumber >= 10))
                {
                    Disconnect(avatarDictionary.FirstOrDefault(cl => cl.Value == avatarDictionary.Values.ToList().Find(rob => rob.ErrorNumber >= 10)).Key);
                }


                _globalHistory.Add(_currentRound, new List <ActionHistory>()); // add history card for this round

                try
                {
                    foreach (IArenaCallback client in avatarDictionary.Keys)
                    {// Round is starting - get ready !!!
                        var possibleMovesSet = Move.GetPossibleActions(avatarDictionary[client], _currentMap, avatarDictionary.Values.ToList());
                        _globalHistory[_currentRound].Add(new ActionHistory(avatarDictionary[client].Login, _currentRound, possibleMovesSet));
                        client.gameRoundStart(_currentRound, possibleMovesSet);
                    }
                }
                catch (Exception e)
                {
                    EventLog.WriteErrorToLog(strErrorLogPath, e);
                }

                EventLog.WriteMessageToLog(strLogPath, "ROUND nr: " + _currentRound + " SEND gameRoundStart message");

                try
                {
                    Thread.Sleep((int)_roundTime);
                }
                catch (ThreadInterruptedException e) // wake up!
                {
                }


                foreach (var history in _globalHistory[_currentRound])
                {
                    if (_currentMovesQueue.Exists(m => m.Robot.Login.Equals(history.RobotLogin)))
                    {
                        history.MadeMove = _currentMovesQueue.Find(m => m.Robot.Login.Equals(history.RobotLogin)).MadeMove;
                    }
                }

                var TimeoutPlayers = avatarDictionary.Keys.ToList <IArenaCallback>().FindAll(client => !_currentMovesQueue.Exists(m => m.Client.Equals(client)));



                foreach (var client in TimeoutPlayers)
                {                                                                                                                                         // send Timout to those who do not send move
                    _globalHistory[_currentRound].Find(history => history.RobotLogin.Equals(avatarDictionary[client].Login)).MadeMove = MoveType.Timeout; // set madeMove = Timeout for those who make timeout
                    EventLog.WriteMessageToLog(strLogPath, "TIMEOUT: Client: " + avatarDictionary[client].Login);
                    avatarDictionary[client].ErrorNumber++;
                    client.reciveGamePlayData(_currentMap.getSmallerPartForRobot(avatarDictionary[client].RobotPosition).SerializeMap(), new GamePlayServerResponse(_currentRound, avatarDictionary[client].RobotPosition, 0, 0, avatarDictionary[client].HasBigItem, avatarDictionary[client].SmallItem, MoveConsequence.TimeOut, GamePlayServerResponse.MoveTimout("Time out. Be quick!")));
                    _currentMovesQueue.Enqueue(new Move(MoveType.WrongAction, _currentMap, client, avatarDictionary, avatarDictionary[client], Directions.Down, _currentRound));
                }

                if (_disconnectedRobotAvatarList.Count > 0)
                {
                    foreach (var robot in _disconnectedRobotAvatarList)
                    {
                        _currentMovesQueue.Add(new Move(MoveType.DisconnectedPlayer, robot));
                    }
                }


                var roundScore = GamePlay.PlayTurn(_currentMovesQueue, _globalHistory);

                _scoreCounter.AddScore(_currentRound, roundScore);


                try
                {
                    foreach (IArenaCallback client in avatarDictionary.Keys)     // Round is starting - get ready !!!
                    {
                        try
                        {
                            client.gameRoundEnd(_currentRound);
                            EventLog.WriteMessageToLog(strLogPath, "SEND: gameRoundEnd");
                        }
                        catch (Exception e)
                        {
                            EventLog.WriteErrorToLog(strErrorLogPath, e);
                        }
                    }
                }
                catch (Exception e)
                {
                    EventLog.WriteErrorToLog(strErrorLogPath, e);
                }
                _currentRound++;

                if (_pauseGame)
                {
                    try
                    {
                        Thread.Sleep(Timeout.Infinite);
                    }
                    catch (ThreadInterruptedException e) // wake up!
                    {
                    }
                }
            }

            if (!_endGameInformationSend)
            {
                _endGameInformationSend = true;
                if (_scoreModule != null)
                {
                    foreach (IArenaCallback client in avatarDictionary.Keys)
                    {// GamePlay is ending;
                        EventLog.WriteMessageToLog(strLogPath, "SEND: gamePlayEnd");
                        client.gamePlayEnd(_scoreCounter.GetTotalScoreForRobot(avatarDictionary[client]));
                    }
                }
                else
                {
                    foreach (IArenaCallback client in avatarDictionary.Keys)
                    {// GamePlay is ending;
                        client.gamePlayEnd(0);
                        EventLog.WriteMessageToLog(strLogPath, "SEND: gamePlayEnd");
                    }
                }
            }
        }