public static bool FindPoint(LogicTileMap tileMap, LogicVector2 pos1, LogicVector2 pos2, LogicVector2 pos3, LogicVector2 pos4) { pos1.Set(pos2.m_x, pos2.m_y); pos1.Substract(pos3); int length = pos1.GetLength(); pos1.m_x = (pos1.m_x << 7) / length; pos1.m_y = (pos1.m_y << 7) / length; pos4.Set(pos3.m_x, pos3.m_y); int radius = LogicMath.Clamp(length / 128, 10, 25); for (int i = 0; i < radius; i++) { if (tileMap.IsPassablePathFinder(pos4.m_x >> 8, pos4.m_y >> 8)) { pos4.m_x = (int)((pos4.m_x & 0xFFFFFF00) | 128); pos4.m_y = (int)((pos4.m_y & 0xFFFFFF00) | 128); return(true); } pos4.Add(pos1); } return(false); }
public bool ManualPushBack(LogicVector2 position, int speed, int time, int id) { if (speed > 0) { if (this.m_parent != null && this.m_parent.GetJump() <= 0) { if (id != 0) { int idx = -1; for (int k = 0; k < 3; k++) { if (this.m_preventsPushId[k] == id) { return(false); } if (this.m_preventsPushTime[k] == 0) { idx = k; } } if (idx == -1) { return(false); } this.m_preventsPushId[idx] = id; this.m_preventsPushTime[idx] = 1500; } LogicGameObject parent = this.m_parent.GetParent(); int rndX = parent.Rand(100) & 0x7F; int rndY = parent.Rand(200) & 0x7F; int pushBackX = rndX + position.m_x - 0x3F; int pushBackY = rndY + position.m_y - 0x3F; LogicVector2 pushForce = new LogicVector2((2 * speed * pushBackX) >> 8, (2 * speed * pushBackY) >> 8); int prevPushBackTime = this.m_pushTime; if (prevPushBackTime <= 0) { this.m_pushTime = time - 16; this.m_pushInitTime = time; this.m_ignorePush = false; this.m_pushBackStartPosition.m_x = this.m_position.m_x; this.m_pushBackStartPosition.m_y = this.m_position.m_y; this.m_pushBackEndPosition.m_x = this.m_position.m_x + pushForce.m_x; this.m_pushBackEndPosition.m_y = this.m_position.m_y + pushForce.m_y; } else { LogicVector2 prevPushForce = new LogicVector2(this.m_pushBackEndPosition.m_x - this.m_position.m_x, this.m_pushBackEndPosition.m_y - this.m_position.m_y); this.m_pushTime = prevPushBackTime + time - 16; this.m_pushInitTime = prevPushBackTime + time; this.m_ignorePush = false; pushForce.Add(prevPushForce); this.m_pushBackStartPosition.m_x = this.m_position.m_x; this.m_pushBackStartPosition.m_y = this.m_position.m_y; this.m_pushBackEndPosition.m_x = this.m_position.m_x + pushForce.m_x; this.m_pushBackEndPosition.m_y = this.m_position.m_y + pushForce.m_y; prevPushForce.Destruct(); } return(true); } } return(false); }