public bool canMove(Direction direction) { MapVector2 tryMovePos = GetPositionAfterTryMove(direction); if (tryMovePos.x < 0 || tryMovePos.x >= MapManager.I.MapSize.x || tryMovePos.y < 0 || tryMovePos.y >= MapManager.I.MapSize.y) { return(false); } BoxUnit box = BoxManager.I.ExistBoxAtPos(tryMovePos); if (box != null) { Debug.Log("运动方向上有box"); if (!box.canMove(direction)) { return(false); } } ElementType element = MapManager.I.GetElementAt(tryMovePos.x, tryMovePos.y); if (element == ElementType.Wall) { return(false); } return(true); }
private void button4_Click(object sender, EventArgs e) { BoxUnit box = (BoxUnit)viewer3.FindUnit("box"); box.Height = box.Length = box.Width = 0.3; box.Opacity = 0.1; }
public BoxUnit CreateBox(MapVector2 pos, Color color) { BoxUnit newUnit = Instantiate(m_BoxUnitTemplate.gameObject).GetComponent <BoxUnit>(); newUnit.Position = new Vector3(pos.x, pos.y, m_Floor); newUnit.PositionInMap = pos; return(newUnit); }