protected virtual void UpdateGridState() { if (this.IsSelect()) { this.CheckHitTerrainGrid(); if (this.last_hit_grid != null) { this.select.SetActive(true); this.select.transform.position = this.last_hit_grid.transform.position; this.select.transform.rotation = this.last_hit_grid.transform.rotation; this.select.transform.Translate(new Vector3(0f, 0.001f, 0f), Space.Self); if (Input.GetMouseButton(0)) { ChangeGridCommand command = new ChangeGridCommand(); command.GridId = this.last_hit_grid.GetComponent <TerrainGrid>().GetGridId(); command.Direction = this.select.transform.rotation.eulerAngles.y; if (this.select.GetComponent <TerrainGrid>()) { command.DataId = this.select.GetComponent <TerrainGrid>().GetDataId(); this.ChangeTerrainGrid(command); } else if (this.select.GetComponent <BuildGrid>()) { command.DataId = this.select.GetComponent <BuildGrid>().GetDataId(); this.ChangeBuildGrid(command); } } } else { this.select.SetActive(false); } if (Input.GetMouseButton(1)) { this.UnSelect(); } } }
protected override void ChangeBuildGrid(ChangeGridCommand command) { }
protected override void ChangeTerrainGrid(ChangeGridCommand command) { }
protected virtual void OnBuildGridChange(ChangeGridCommand command) { this.map.ChangeBuildGrid(command.GridId, command.DataId, command.Direction); }
// 通过保存命令可以做成引导回放等东西,先挖坑 protected virtual void OnTerrainGridChange(ChangeGridCommand command) { this.map.ChangeTerrainGrid(command.GridId, command.DataId); }
protected virtual void ChangeBuildGrid(ChangeGridCommand command) { this.OnBuildGridChange(command); }
protected virtual void ChangeTerrainGrid(ChangeGridCommand command) { this.OnTerrainGridChange(command); }