public void dig(GamePosition pos) { if (!isServer) { return; } MapCoords mapCoords = pos.toMapCoords(); Tile tile = mapData.getTile(mapCoords); if (tile.GetType().Equals(typeof(Wall))) { spawnManager.SpawnItemFromTile(new RockItem(), 1, mapCoords.toGamePosition()); spawnManager.SpawnItemFromTile(new DirtItem(), 1, mapCoords.toGamePosition()); if (Random.Range(1, 100) <= 25) { spawnManager.SpawnItemFromTile(new GrubItem(), 1, mapCoords.toGamePosition()); } if (Random.Range(1, 100) <= 50) { spawnManager.SpawnItemFromTile(new WormItem(), 1, mapCoords.toGamePosition()); } } RpcDig(pos.toStruct()); }
private void tryPlaceDirt() { Vector2 placeOffset = getActionOffset(); GamePosition placeSpot = gamePos.addWorld(placeOffset); CmdPlace(placeSpot.toStruct()); }
private void tryDig() { Vector2 digOffset = getActionOffset(); GamePosition digSpot = gamePos.addWorld(digOffset); CmdDig(digSpot.toStruct()); }
private void applyGravity() { GamePosition pos = null; if (isLocalPlayer) { pos = gamePos; applyGravity(pos); } else { pos = GamePosition.ParseStruct(syncPos); applyGravity(pos); syncPos = pos.toStruct(); } }
void Update() { if (!firstSync) { InitializeObject(); firstSync = true; } trans.position = gamePos.getRenderingPosition(); if (rend != null) { rend.sortingOrder = (map.mapDepth - gamePos.toMapCoords().depth - 1) * 10 + 5; } if (!isLocalPlayer) { GamePosition syncGamePos = GamePosition.ParseStruct(syncPos); gamePos.planePosition = Vector2.Lerp(gamePos.planePosition, syncGamePos.planePosition, Time.deltaTime * lerpRate); gamePos.depth = syncGamePos.depth; if (rend.sortingOrder > MoleController.localPlayer.GetComponent <MoleController> ().rend.sortingOrder) { rend.color = new Color(1, 1, 1, 0); } else { rend.color = new Color(1, 1, 1, 1); } } else { CmdTransmitPosition(gamePos.toStruct()); } GameUpdate(); }
public void place(GamePosition pos) { RpcPlace(pos.toStruct()); }