|
|
@ -9,14 +9,14 @@ |
|
|
|
|
|
|
|
|
|
|
|
package engine.net.client.handlers; |
|
|
|
package engine.net.client.handlers; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import engine.Enum; |
|
|
|
import engine.exception.MsgSendException; |
|
|
|
import engine.exception.MsgSendException; |
|
|
|
|
|
|
|
import engine.gameManager.BuildingManager; |
|
|
|
import engine.gameManager.MovementManager; |
|
|
|
import engine.gameManager.MovementManager; |
|
|
|
import engine.net.client.ClientConnection; |
|
|
|
import engine.net.client.ClientConnection; |
|
|
|
import engine.net.client.msg.ClientNetMsg; |
|
|
|
import engine.net.client.msg.ClientNetMsg; |
|
|
|
import engine.net.client.msg.MoveToPointMsg; |
|
|
|
import engine.net.client.msg.MoveToPointMsg; |
|
|
|
import engine.objects.AbstractWorldObject; |
|
|
|
import engine.objects.*; |
|
|
|
import engine.objects.Building; |
|
|
|
|
|
|
|
import engine.objects.PlayerCharacter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class MoveToPointHandler extends AbstractClientMsgHandler { |
|
|
|
public class MoveToPointHandler extends AbstractClientMsgHandler { |
|
|
|
|
|
|
|
|
|
|
@ -32,22 +32,24 @@ public class MoveToPointHandler extends AbstractClientMsgHandler { |
|
|
|
PlayerCharacter pc = (origin != null) ? (origin.getPlayerCharacter()) : null; |
|
|
|
PlayerCharacter pc = (origin != null) ? (origin.getPlayerCharacter()) : null; |
|
|
|
if (pc == null) |
|
|
|
if (pc == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
PlayerCharacter player = origin.getPlayerCharacter(); |
|
|
|
|
|
|
|
if (player == null) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AbstractWorldObject target = player.combatTarget; |
|
|
|
AbstractWorldObject target; |
|
|
|
|
|
|
|
Enum.GameObjectType targetType; |
|
|
|
|
|
|
|
|
|
|
|
if (target != null) { |
|
|
|
targetType = Enum.GameObjectType.values()[msg.getTargetType()]; |
|
|
|
switch (target.getObjectType()) { |
|
|
|
switch(targetType){ |
|
|
|
case NPC: |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
case Building: |
|
|
|
case Building: |
|
|
|
|
|
|
|
target = BuildingManager.getBuilding(msg.getTargetID()); |
|
|
|
|
|
|
|
if(target == null) |
|
|
|
|
|
|
|
return true;// early exit for no building pulled
|
|
|
|
Building targetBuilding = (Building) target; |
|
|
|
Building targetBuilding = (Building) target; |
|
|
|
if (!targetBuilding.isVulnerable() || targetBuilding.getRank() < 0) |
|
|
|
if (!targetBuilding.isVulnerable() || targetBuilding.getRank() < 0) |
|
|
|
return false; |
|
|
|
return true;// cannot attack destroyed building or protected building
|
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
case NPC: |
|
|
|
|
|
|
|
return true;//cannot attack anything other than the 3 above
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MovementManager.movement(msg, pc); |
|
|
|
MovementManager.movement(msg, pc); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|