// Update is called once per frame void Update() { // Drop if (this.drop != null && !this.drop.MoveNext()) { this.drop = null; } // Dig if (Input.GetKey(KeyCode.Space) && Time.time > nextDigTime) { nextDigTime = Time.time + this.digTimeRate; this.walkButtonOn = false; Dig(); } // Walk if (this.walk != null && !this.walk.MoveNext()) { this.walk = null; Block.Type hit = blockController.Collision(this.pos, Direction.Down); if (hit == Block.Type.Empty) { DropStart(); } } this.walkButtonOn = false; if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.H)) { this.direction = Direction.Left; this.walkButtonOn = true; if (this.walk == null) { this.walk = GetWalkEnumerator(Direction.Left); } } else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.L)) { this.direction = Direction.Right; this.walkButtonOn = true; if (this.walk == null) { this.walk = GetWalkEnumerator(Direction.Right); } } else if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.K)) { this.direction = Direction.Up; } else if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.J)) { this.direction = Direction.Down; } }
public void Grouping(Block block) { if (block == null || block.type == Block.Type.Empty) { return; } if (!Add(block)) { return; } // 上下左右 foreach (Direction d in System.Enum.GetValues(typeof(Direction))) { if (blockController.Collision(block.pos, d) == block.type) { Grouping(blockController.NextBlock(block.pos, d)); } } }