void RPCDoMovement(int startX, int startZ, int endX, int endZ) { Tile bottomLeftCorner = Global.instance.currentMap.board[startX, startZ]; Unit unit = bottomLeftCorner.GetMyObject <Unit>(); if (unit == null) { Debug.LogError("NoUnit!"); LogConsole.instance.SpawnLog("NO UNIT TO MOVE!"); return; } MultiTile destination = MultiTile.Create(Global.instance.currentMap.board[endX, endZ], unit.currentPosition.size); unit.Move(destination); }
/// <summary> /// Used to either perform movement in offline modes or send an RPC in online mode. /// </summary> /// <param name="unit"> Unit to be moved to the last tile in Path made by PathCreator</param> public void SendCommandToMove(Unit unit, MultiTile destination) { PlayerInput.instance.isInputBlocked = true; //this makes sense only on the 'active' PC' that's why I put it here ;) if (Global.instance.matchType == MatchTypes.Online) { int startX = unit.currentPosition.bottomLeftCorner.position.x; int startZ = unit.currentPosition.bottomLeftCorner.position.z; int endX = destination.bottomLeftCorner.position.x; int endZ = destination.bottomLeftCorner.position.z; photonView.RPC( "RPCDoMovement", RpcTarget.All, startX, startZ, endX, endZ); } else { unit.Move(destination); } }