public void ShouldScoreStateManagerRestoreToPreviousStates()
        {
            var setting           = new FieldSetting();
            var score             = new Score(setting);
            var scoreStateManager = new ScoreStateManager(score, 2);

            scoreStateManager.Save();
            score.Add(2);

            scoreStateManager.Save();
            score.Add(3);

            scoreStateManager.Save();
            score.Add(4);

            score.Value.ShouldBe(9);

            var result = scoreStateManager.BackToPrevious();

            result.ShouldBeTrue();
            score.Value.ShouldBe(5);

            result = scoreStateManager.BackToPrevious();
            result.ShouldBeTrue();
            score.Value.ShouldBe(2);

            result = scoreStateManager.BackToPrevious();
            result.ShouldBeFalse();
            score.Value.ShouldBe(2);
        }
Example #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Player" && gsm.state == GameStateManager.State.GAME_MODE_PLAY)
     {
         //update recording
         if (gsm.framesInState > 7 && gsm.recordThisGame && gsm.state == GameStateManager.State.GAME_MODE_PLAY)
         {
             recorder.RecordIfRecording(recorder.DestroyCommand(gameObject));
         }
         if (gameObject.tag == "Growth")
         {
             //make cats flee
             foreach (AIController enemy in FindObjectsOfType <AIController>())
             {
                 enemy.flee += 10;
             }
             score.Add(100);
         }
         else
         {
             score.Add(10);
         }
         sound.Gulp();
         GameObject.Destroy(gameObject, .1f);//give it 1/10 second to be swallowed
     }
 }
Example #3
0
    private void MovedCharacterHandler(Character character, Vector2Int moveTo)
    {
        if (selectedCharacter == character)
        {
            selectedCharacter.OnMoved -= MovedCharacterHandler;
            selectedCharacter.Unselect();
            selectedCharacter = null;
        }

        characterProvider.Move(moveTo, character);

        int countDeleteMatched = matcher.DeleteMatched();

        if (countDeleteMatched == 0)
        {
            RandomSpawn();
        }
        else
        {
            score.Add(countDeleteMatched);
            audioOwlSound.Play();
            if (characterProvider.GetAllFillPosition().Count == 0)
            {
                RandomSpawn();
            }

            saveGame.Save();
            gameWorldInput.enabled = true;
        }
    }
Example #4
0
    // 敵を食べて得点を得る
    void EatEnemy(Collision collision)
    {
        for (int i = 0; i < (int)EnemyColor.max; ++i)
        {
            EnemyColor mEnemyColor = (EnemyColor)i;

            if (collision.gameObject.CompareTag(mEnemyColor.ToString()))
            {
                if (oldEnemyColor == mEnemyColor)
                {
                    ++combo;
                    score.Add(addScore * combo);
                }
                else
                {
                    oldEnemyColor = mEnemyColor;
                    combo         = 1;
                    score.Add(addScore);
                }
                ++totalEatNum;
                GetComponent <AudioSource>().PlayOneShot(GetComponent <Sound>().GetSE(2));
                Debug.Log(mEnemyColor.ToString() + "と接触");
                // Destroy(collision.gameObject);
            }
        }
        Debug.Log(combo + "コンボ");
        Debug.Log("敵を食べた数:" + totalEatNum);
    }
Example #5
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("a"))
        {
            MoveLeft();
        }

        if (Input.GetKeyDown("d"))
        {
            MoveRight();
        }

        if (Input.GetKeyDown("s"))
        {
            if (!MoveBottom())
            {
                // 下への動作を確定できれば 10 点
                _Score.Add(10);
            }
        }

        if (Input.GetKeyDown("w"))
        {
            Rotate();
        }
    }
Example #6
0
        public override void Update(GameTime gameTime)
        {
            bool _gameOver = false;

            for (int i = snake.Children.Count - 1; i >= 0; i--)
            {
                SnakeSegment s = snake.Children[i] as SnakeSegment;
                for (int x = bullets.Children.Count - 1; x >= 0; x--)
                {
                    Bullet b = bullets.Children[x] as Bullet;
                    if (s.CollidesWith(b))
                    {
                        score.Add(scoreSnakeHit);
                        mushrooms.Add(new Mushroom(s.Position));
                        bullets.Remove(b);
                        snake.Remove(s);
                    }
                }
                for (int x = mushrooms.Children.Count - 1; x >= 0; x--)
                {
                    Mushroom m = mushrooms.Children[x] as Mushroom;
                    if (s.CollidesWith(m))
                    {
                        s.Bounce(m.Position.X - s.Position.X);
                    }
                }
                if (s.CollidesWith(player))
                {
                    _gameOver = true;
                }
            }
            if (_gameOver)
            {
                Reset();
            }
            for (int i = bullets.Children.Count - 1; i >= 0; i--)
            {
                Bullet b = bullets.Children[i] as Bullet;
                for (int x = mushrooms.Children.Count - 1; x >= 0; x--)
                {
                    Mushroom m = mushrooms.Children[x] as Mushroom;
                    if (b.CollidesWith(m))
                    {
                        score.Add(scoreMushroomHit);
                        mushrooms.Remove(m);
                        bullets.Remove(b);
                    }
                }
            }
            base.Update(gameTime);
        }
Example #7
0
        /// <summary>
        /// マージする
        /// </summary>
        /// <param name="merge">マージするもの</param>
        /// <remarks>
        /// この機能は、ロードした作品データにREST API分のデータをマージするための物なので、PV関連はノータッチ。
        /// </remarks>
        public void Merge(DB.Title merge)
        {
            //探す日付
            var mergeScore = merge.LatestScore;
            var findDate   = mergeScore.Date.Date;

            //おんなじ日付があるか探す(後ろから探すのが早かろう)
            for (var i = Score.Count - 1; i >= 0; i--)
            {
                if (Score[i].Date.Date == findDate)
                {
                    Score[i].MergeScore(merge.LatestScore);
                    return;
                }
            }
            //見つからなかったので足す。
            Score.Add(merge.LatestScore);

            //日付を新しいほうにする
            if (LastUp < merge.LastUp)
            {
                LastUp = merge.LastUp;
            }
            if (LastCheck < merge.LastCheck)
            {
                LastCheck = merge.LastCheck;
            }
        }
Example #8
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (speed < maxSpeed)
        {
            speed = startingSpeed + score.GetComponent <Score>().GetScore() / speedScale;
        }


        if (!playerIsInCloud && playerIsAlive)
        {
            float movement = speed * Time.deltaTime;
            //move the cloud
            cloud.transform.Translate(new Vector3(0, -movement, 0));
            //cloud.transform.position = new Vector3(0, cloud.transform.position.y - movement, 0);
            //add to score
            score.Add(movement);
            //increment platTracker
            //platTracker += movement;
            //if (platTracker >= spacingMultiplier)
            //{
            //    platTracker -= spacingMultiplier;
            //    UpdatePlatforms();
            //}
        }
    }
Example #9
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            if (player && flee > 0)
            {
                //Eat the cat!
                score.Add(player.GetCatValue());

                GameObject g = Instantiate(pointsPrefab);
                g.transform.position = transform.position;
                Points p = g.GetComponent <Points>();
                p.points = player.GetCatValue();
                p.color  = GetComponent <SpriteRenderer>().color;

                player.DoubleCatValue();
                sound.BigGulp();
                ResetEnemy();
                delay = 10;
            }
            else
            {
                gsm.state = GameStateManager.State.GAME_MODE_DEATH;
            }
        }
    }
Example #10
0
        /// <summary>
        /// スコアデータ登録
        /// </summary>
        /// <param name="dailyValue"></param>
        /// <remarks>
        /// この機能は、ロードした作品データにPVデータをマージするための物なので、REST-API分のデータはノータッチ。
        /// </remarks>
        public void AddPageView(DailyScore pv, bool isUnique)
        {
            //探す日付
            var findDate = pv.Date.Date;

            //おんなじ日付があるか探す
            for (var i = 0; i < Score.Count; i++)
            {
                if (Score[i].Date.Date == findDate)
                {
                    //同じ日→マージ
                    if (isUnique)
                    {
                        Score[i].MergeUniquePageView(pv);
                    }
                    else
                    {
                        Score[i].MergePageView(pv);
                    }
                    return;
                }
                else if (Score[i].Date.Date > findDate)
                {
                    //過ぎた→インサート
                    Score.Insert(i, pv);
                    return;
                }
            }
            //最期に足す(普通はUpdate時のScoreデータがあるのでここには来ない)
            Score.Add(pv);
        }
        public override void Initialize()
        {
            Name = "recent issues of \"Spelunker Today\"";
            Synonyms.Are("magazines", "magazine", "issue", "issues", "spelunker", "today");
            Description        = "I'm afraid the magazines are written in Dwarvish.";
            InitialDescription = "There are a few recent issues of ~Spelunker Today~ magazine here.";
            Article            = "a few";
            // multitude

            FoundIn <Anteroom>();

            After <Take>(() =>
            {
                if (CurrentRoom.Location is WittsEnd)
                {
                    Score.Add(-1);
                }
            });

            After <Drop>(() =>
            {
                if (CurrentRoom.Location is WittsEnd)
                {
                    Score.Add(1);
                    Print("You really are at wit's end.");
                }
            });
        }
Example #12
0
 public void Die()
 {
     core.died?.Invoke();
     Score.Add(core.stats.points);
     Instantiate(core.feedback.deathEffect);
     PlaySound(core.feedback.deathSound);
     Destroy(gameObject, core.feedback.deathSound.length);
 }
Example #13
0
        public override void Visit(ShipBulletLeaf b)
        {
            CollisionPair pair = ColPairMan.Find(CollisionPairName.Bullet_UFO);

            pair.SetCollision(b, this);
            pair.Notify();
            Score.Add(Rand.GetNext(50, 100));
        }
Example #14
0
    public void ReceiveBlood()
    {
        health = 1;

        score_controller.Add();

        GetComponent <AudioSource>().pitch = Random.Range(0.7f, 1.3f);
        GetComponent <AudioSource>().Play();
    }
Example #15
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Bullet")
     {
         score.Add(100);
         AudioManager.PlaySE("button");
         Destroy(gameObject);
         Destroy(other.gameObject);
     }
 }
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Bullet")
        {
            Destroy(this.gameObject);

            score.Add(100);
            comboBonus.Add(1);
        }
    }
Example #17
0
 void OnTriggerEnter(Collider other)//Other is the reference to the object we have collided.
 {
     if (other.tag == "Enemy")
     {
         CancelInvoke();
         Destroy(other.gameObject);
         //Debug.Log("Score");
         score.Add(100);
         Die();//The game object atateched to the script dies.
     }
 }
Example #18
0
        public override void Initialize()
        {
            Name = "Plover Room";

            Synonyms.Are("plover", "room");

            Description =
                "You're in a small chamber lit by an eerie green light. " +
                "An extremely narrow tunnel exits to the west. " +
                "A dark corridor leads northeast.";

            Light = true;

            NorthEastTo <DarkRoom>();

            WestTo(() =>
            {
                var carrying = Inventory.Items.Count;

                if (carrying == 0 || carrying == 1 && IsCarrying <EggSizedEmerald>())
                {
                    return(Room <Alcove>());
                }

                Print("Something you're carrying won't fit through the tunnel with you. You'd best take inventory and drop something.");

                return(this);
            });

            Before <Plover>(() =>
            {
                if (IsCarrying <EggSizedEmerald>())
                {
                    Move <EggSizedEmerald> .To <PloverRoom>();
                    Score.Add(-5, true);
                }

                MovePlayer.To <Y2>();

                return(true);
            });

            Before <Go>((Direction direction) =>
            {
                if (direction is Out)
                {
                    MovePlayer.To(W());
                    return(true);
                }

                return(false);
            });
        }
Example #19
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player" && isAlive)
     {
         var score = Random.Range(1000, 10000);
         Score.Add(score);
         Notification.Show("You got " + score + " points!");
         isAlive = false;
         effect.SetActive(false);
         SoundManager.Play("HotSpot", transform.position);
         StartCoroutine(Revival());
     }
 }
Example #20
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        if (isDead)
        {
            return;
        }

        if (collider.tag.Equals(ScoreTag))
        {
            // スコアアップ
            score.Add(10);
        }
    }
Example #21
0
    public void Load()
    {
        if (!File.Exists(filePath))
        {
            Debug.Log("Нет сохранения");
            _gameWorld.Restart();
            return;
        }

        Save save;

        try
        {
            string json = File.ReadAllText(filePath);
            save = JsonUtility.FromJson <Save>(json);
        }
        catch (Exception ex)
        {
            Debug.LogWarning(ex);

            Debug.LogWarning("сохранения не подходят");
            _gameWorld.Restart();
            return;
        }

        if (save.allCharacters == null || save.nextCharacters == null)
        {
            Debug.LogWarning("в файле сохраниения нет данных");
            _gameWorld.Restart();
            return;
        }

        _score.Reset();
        _characterProvider.Clear();

        _score.Add(save.score);

        SaveCharacter[] savedCharacters = save.allCharacters;

        foreach (var item in savedCharacters)
        {
            _characterProvider.Create(item.x, item.y, item.prefabIndex);
        }

        _gameWorld.SetNextCharacters(save.nextCharacters);

        if (_characterProvider.GetAllFillPosition().Count == 0)
        {
            _gameWorld.RandomSpawn();
        }
    }
Example #22
0
    void Update()
    {
        if (Input.GetAxisRaw("Horizontal") != 0)
        {
            Rotate();
        }

        if (true)
        {
            time++;
            if (time >= 55)
            {
                seconds++;
                time = 0;
                Score.Add(seconds);
                seconds = 0;
            }
        }


        if (Input.GetAxisRaw("Vertical") != 0)
        {
            Move();
        }

        if (Input.GetAxisRaw("Jump") != 0)
        {
            if (grounded)
            {
                Jump();
            }
        }

        if (Input.GetAxisRaw("Fire1") != 0)
        {
            Fire();
        }
        if (Input.GetAxisRaw("Fire2") != 0)
        {
            Fire2();
        }

        if (transform.position.y < minimumY)
        {
            // Respawn
            Respawn();
        }
        Debug.DrawRay(transform.position, new Vector3(0, -1f, 0), Color.red);
        GroundTest();
        Friction();
    }
        public void ShouldScoreStateManagerNotChangeScoreIfNotSavedStates()
        {
            var setting = new FieldSetting();
            var score   = new Score(setting);

            score.Add(444);
            var scoreStateManager = new ScoreStateManager(score, 2);

            var result = scoreStateManager.BackToPrevious();

            result.ShouldBeFalse();

            score.Value.ShouldBe(444);
        }
Example #24
0
    //Nho danh tag cho Ammo
    void OnTriggerEnter(Collider obj)
    {
        Debug.Log("Trigger enter");
        if (obj.gameObject.tag == "Ammo")
        {
            Destroy(obj.gameObject);
            gameObject.SetActive(false);
            this.transform.position = gone;
            Score.Add(10, 1000);

            /*	AmmoBehavior ammo = obj.gameObject;
             *      Score.Add (ammo.getScore(),time);
             */
        }
    }
Example #25
0
        public override void Initialize()
        {
            DaemonStarted = false;

            Daemon = () =>
            {
                TimeLeft--;

                if (TimeLeft > 0)
                {
                    return;
                }

                DaemonStarted = false;

                Score.Add(10, true);

                foreach (var obj in Inventory.Items.ToList())
                {
                    obj.Remove();
                }

                var bottle = Get <Bottle>();
                bottle.Empty();

                bottle.MoveTo <NeEnd>();

                Move <GiantClam> .To <NeEnd>();

                Move <BrassLantern> .To <NeEnd>();

                Move <BlackRod> .To <NeEnd>();

                Move <LittleBird> .To <SwEnd>();

                Move <VelvetPillow> .To <SwEnd>();

                Print(
                    "\nThe sepulchral voice intones, \"The cave is now closed.\" " +
                    "As the echoes fade, there is a blinding flash of light " +
                    "(and a small puff of orange smoke). . . " +
                    "\n\n " +
                    "As your eyes refocus, you look around...\n"
                    );

                MovePlayer.To <NeEnd>();
            };
        }
Example #26
0
        static void Main(string[] args)
        {
            Console.WriteLine("---------- using factory ------------");
            var studentFactory = new StudentFactory();
            var student        = studentFactory.CreateStudent("special");
            var student2       = studentFactory.CreateStudent("normal");

            Console.WriteLine(student.Speak());
            Console.WriteLine(student2.Speak());

            Console.WriteLine("------------- using decorator ----------");
            var juniorWorker = new JuniorWorker();

            juniorWorker.DoWork();
            var seniorWorker = new SeniorWorker(juniorWorker);

            seniorWorker.DoWork();

            Console.WriteLine("-------------- Using singleton -------------");
            // instance will be same when used from anywhere
            GlobalObject global = GlobalObject.GetInstance();

            global.myGlobalList.ForEach(x => Console.WriteLine(x));
            global.myGlobalList.Add("Gaurav");
            global.myGlobalList.Add("Kapoor");
            global.myGlobalList.ForEach(x => Console.WriteLine(x));


            Console.WriteLine("---------------Using Adapter ---------------");
            ILogger outputLogger = new OutputterAdapter();
            var     newSystem    = new MyNewSystem(outputLogger);

            newSystem.Dowork();

            Console.WriteLine("----------------Using Template method -------------");
            Car myCar = new BMW();

            myCar.GetReadyAndDrive();


            Console.WriteLine("----------------Using Observer  -------------");
            Score myScore = new Score();

            myScore.AddObserver(new ScoreObserver());
            myScore.AddObserver(new SuperScoreObserver());
            myScore.Add(5);
            myScore.Subtract(3);
        }
Example #27
0
    public void TakeDamage(float amount)
    {
        currentHealth -= amount;
        Debug.Log("DAMAGE!");

        if (currentHealth <= 0f)
        {
            Destroy(Instantiate(deathEffect, transform.position, Quaternion.identity) as GameObject, 4);
            Die();
            score.Add(100);
        }

        else if (currentHealth <= 30)
        {
            damageAnimation.SetActive(true);
        }
    }
Example #28
0
        void Start()
        {
            _enter.Subscribe(x =>
            {
                score.Add(x.BroiledValue.Value);
                x.Freeze();
                x.transform.SetParent(transform);
                x.transform.localPosition = Vector3.zero;
            })
            .AddTo(this);

            _enter.Pairwise()
            .Select(x => x.Previous?.gameObject)
            .Where(x => x != null)
            .Subscribe(Destroy)
            .AddTo(this);
        }
Example #29
0
        public override void Initialize()
        {
            Name        = "y2";
            Description =
                "You are in a large room, with a passage to the south, " +
                "a passage to the west, and a wall of broken rock to the east. " +
                "There is a large ~Y2~ on a rock in the room's center.";


            SouthTo <LowNSPassage>();
            EastTo <JumbleOfRock>();
            WestTo <WindowOnPit1>();


            After <Look>(() =>
            {
                if (Random.Number(1, 100) < 25)
                {
                    Print("\r\nA hollow voice says, \"Plugh.\"\n");
                }
            });

            Before <Plugh>(() =>
            {
                MovePlayer.To <InsideBuilding>();
                return(true);
            });

            Before <Plover>(() =>
            {
                if (!Room <PloverRoom>().Visited)
                {
                    return(false);
                }

                if (IsCarrying <EggSizedEmerald>())
                {
                    Move <EggSizedEmerald> .To <PloverRoom>();
                    Score.Add(-5);
                }

                MovePlayer.To <PloverRoom>();

                return(true);
            });
        }
Example #30
0
 //指定这个用户某个关卡的分数
 public void setScore(int stage, int score)
 {
     if (stage <= 0)
     {
         throw new Exception("关卡异常:" + stage);
     }
     if (score < 0)
     {
         throw new Exception("得分信息错误:" + score);
     }
     if (Score.ContainsKey(stage))
     {
         Score[stage] = score;
         return;
     }
     Score.Add(stage, score);
 }