public int BuildBlock(BlockType b, PlayerSetup pSetup) { Vector3 localPos = this.position; Vector3 chunkPos = this.owner.chunk.transform.position; Vector3 blockWorldPos = chunkPos + localPos; if (pSetup.CheckFences(blockWorldPos, pSetup.username)) { return(2); } if (b == BlockType.REDSTONE) { if (pSetup.isServer) { Debug.Log("Red stone build 1"); pSetup.RpcFenceSync(true, blockWorldPos, pSetup.username); } else { Debug.Log("Red stone build 2"); pSetup.RpcFenceSync(false, blockWorldPos, pSetup.username); //pSetup.CmdFenceSync2(true, blockWorldPos, pSetup.username); } } SetType(b); owner.Redraw(); return(1); }
public int HitBlock(PlayerSetup pSetup) { Vector3 localPos = this.position; Vector3 chunkPos = this.owner.chunk.transform.position; Vector3 blockWorldPos = chunkPos + localPos; if (pSetup.CheckFences(blockWorldPos, pSetup.username)) { Debug.Log("INSIDE"); return(2);//other users fences tryed to be accessed } if (currentHealth == -1) { return(0); } currentHealth--; health++; if (currentHealth == (blockHealthMax[(int)bType] - 1)) { owner.mb.StartCoroutine(owner.mb.HealBlock(position)); } if (currentHealth <= 0) { if (bType == BlockType.REDSTONE) { if (pSetup.isServer) { pSetup.RpcFenceSync(false, blockWorldPos, pSetup.username); } else { pSetup.RpcFenceSync(false, blockWorldPos, pSetup.username); // pSetup.CmdFenceSync2(false, blockWorldPos, pSetup.username); } } bType = BlockType.AIR; isSolid = false; health = BlockType.NOCRACK; owner.Redraw(); return(1); } owner.Redraw(); return(0); }