public void Move(int toX, int toY, int speed, float value, out int gridX, out int gridY, out float offset) { //init data desX = toX; desY = toY; if (toX == posX && toY == posY) { gridX = posX; gridY = posY; offset = 0; return; } moveSpeed = speed; MapField field = GameRoot.GetInstance().MapField; field.MarkMovable(posX, posY, radius, false); float toViewX, toViewY; field.GetViewPos(toX, toY, out toViewX, out toViewY); float nowViewX = gameObject.transform.position.x; float nowViewY = gameObject.transform.position.z; Vector2 desPoint = field.GetRoute(nowViewX, nowViewY, toViewX, toViewY, value); float nextViewX = desPoint.x; float nextViewY = desPoint.y; offset = 0; gameObject.transform.position = new Vector3(nextViewX, 0f, nextViewY); field.GetGridPos(nextViewX, nextViewY, out gridX, out gridY); SetRotation(toX, toY); posX = gridX; posY = gridY; field.MarkMovable(posX, posY, radius, true); return; }
public void Portal(int _x, int _y) { MapField field = GameRoot.GetInstance().MapField; field.PortalEntity(this, _x, _y); }