/// <summary> /// 更新显示数据 /// </summary> void DoValueChange() { var currentSelected = getCurrentSelectMapPreview(); SetIntroductionImage(currentSelected.JsonModel.ImageName); SetIntroductionText(currentSelected.JsonModel.Description); MainGameCurrent.LoadMap(currentSelected.JsonModel); }
// Update is called once per frame void Update() { if (MainGameCurrent.FocusedHexBlock == null || !MainGameCurrent.FocusedHexBlock.IsActive) { gameObject.GetComponent <Text>().text = ""; return; } if (MainGameCurrent.FocusedHexBlock.IsActive) { gameObject.GetComponent <Text>().text = MainGameCurrent.GetCurrentBlockDetailInfo(); } }
/// <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); } }
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)); }
// Update is called once per frame void Update() { gameObject.GetComponent <Text>().text = MainGameCurrent.GetCurrentBlockStrainDetailInfo(); }
private void Awake() { // 为editor加载地图 MainGameCurrent.LoadMap(); GenerateBlockContainer(); }