示例#1
0
        /// <summary>
        /// 游戏最重要函数
        /// </summary>
        private void Update()
        {
            // 游戏还没开始就不更新
            if (!Instance.IsGameStarted)
            {
                return;
            }
            // If paused,do not update anything
            if (IsPaused)
            {
                CurrentUpdateCount = MaxUpdateCount;
                return;
            }

            // 每隔一秒更新一次
            if (CurrentUpdateCount > 0)
            {
                CurrentUpdateCount -= Time.deltaTime;
                return;
            }
            else
            {
                CurrentUpdateCount = MaxUpdateCount;
                TimePast          += 1.0f; //One tick one second (in game time, not real time)
            }

            // 更新所有格子
            foreach (var block in MainGameCurrent.StageMap.Blocks)
            {
                BlockController blockController = new BlockController(block);
                blockController.BlockBacteriaUpdate();
                // block.BlockLogic.BlockBacteriaUpdBlocate();
            }

            // 判断游戏胜利
            if (MainGameCurrent.IsGameOver(MainGameCurrent.StageMap))
            {
                IsGameCompleted = true;
                IsGameStarted   = false;
                View.GameOverLogic.Instance.SetGameOverCondition(TimePast, 114514, true);
            }
        }
示例#2
0
        public static void TestGameOver()
        {
            Map map = new Map {
                Blocks = new List <Block> {
                    new Block {
                        PublicChemicals = new List <Chemical> {
                            new Chemical {
                                Name = "Cu", Count = 100
                            }
                        }
                    }
                },
                GameOverCondition = "Cu:10"
            };

            Debug.Assert(MainGameCurrent.IsGameOver(map));
            map.GameOverCondition = "Cu:1000";
            Debug.Assert(!MainGameCurrent.IsGameOver(map));
            map.GameOverCondition = "Cu:-1000";
            Debug.Assert(MainGameCurrent.IsGameOver(map));
            map.GameOverCondition = "Cu:-100";
            Debug.Assert(!MainGameCurrent.IsGameOver(map));
        }