Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

  private int GetNumberAfterRotation(Vector3 direction) {
   //rotating to the left
   if(direction == Vector3.up) {
    return gameScript.getBlockNumber (2-z,y,x);
   }
   //rotating to the right
   if(direction == Vector3.down) {
    return gameScript.getBlockNumber (z,y,2-x);
   }
   //rotating up
   if(direction == Vector3.left) {
    return gameScript.getBlockNumber (x,2-z,y);
   }
   //rotating down
   if(direction == Vector3.right) {
    return gameScript.getBlockNumber (x,z,2-y);
   }
   return 1;
  }