player2_dz

HungryBoy Code

May 28th, 2017
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 45.62 KB | None | 0 0
  1. /* Includes */
  2. using UnityEngine;
  3. using System.Collections;
  4. using System;
  5. using UnityEngine.EventSystems;
  6. using System.Collections.Generic;
  7.  
  8. /*  Block Address Data Structure
  9. ---------------------------------
  10.   Description:
  11.     Used for storing block addresses relative to an origin point.
  12.  
  13.   Values:
  14.     3 Signed Bytes (-128 to 127 range)
  15.       d = Difficulty (Valid Values: 1 to 7, Default/ErrorCheck: -128)
  16.       x = X Position (Valid Values -8 to 12, Default/ErrorCheck: -128)
  17.       y = Y Position (Valid Values -8 to 3, Default/ErrorCheck: -128)
  18. */
  19. using System.Security.AccessControl;
  20.  
  21.  
  22. [Serializable] public struct blockAddress {
  23.     public SByte d, x, y;      
  24.     public blockAddress (SByte difficulty = -128, SByte xOffset = -128, SByte yOffset = -128) {
  25.         d = difficulty;     x = xOffset;        y = yOffset;
  26.     }
  27. }
  28.  
  29. /*  Difficulty Chance Data Structure
  30. -------------------------------------
  31.   Description:
  32.     Used for assigning a percent chance on spawning different amount of blocks
  33.     and different difficulty level blocks.
  34.  
  35.   Values:
  36.     2 Signed Bytes (-128 to 127 range)
  37.       d = Difficulty    (Valid Values: 1 to 7, Default/ErrorCheck: -128)
  38.       c = Chance        (Valid Values: 0 to 100, Default/ErrorCheck: -128)
  39. */
  40. [Serializable] public struct difficultyChance {
  41.     public SByte d, c;
  42.     public difficultyChance(SByte difficulty = -128, SByte chance = -128) {
  43.         d = difficulty;     c = chance;
  44.     }
  45. }
  46.  
  47. /*  prefabGenerator Class
  48. -------------------------------------
  49. */
  50. public class prefabGenerator : MonoBehaviour {
  51.     /*============================================================================================================================*/
  52.     /*  Public Variables & Test Settings
  53.     /*============================================================================================================================*/
  54.  
  55.     //Used for difficulty setting from main menu
  56.     public eventSystem eSys;
  57.  
  58.     //Used to track player position
  59.     public Transform playerPos;
  60.  
  61.     //Enable test-mode which creates objects on start-up
  62.     public bool createOnStartUp = false;
  63.  
  64.     //Amount of jumps/platforms to generate ahead of the player (Must be multiple of 2) (createOnStartUp only)
  65.     public int c_leadAheadBy = 4;
  66.  
  67.     //Difficulty setting to use when generating platforms on start-up (createOnStartUp ONLY)
  68.     [Range(1,4)] public int c_difficultySetting = 4;
  69.  
  70.     //Starting game object / platform (createOnStartUp ONLY)
  71.     public GameObject c_startPlatform;
  72.  
  73.     //Used to stop generating platforms once started
  74.     public bool stopGenerating = false;
  75.  
  76.     //When fully-randomly generating without up/down overrides, prevent blocks from straying too far from 0 with this
  77.     //This means that from 0 it will only go +20 or -20 on y axis when generating a platform
  78.     float maxStray = 20f;
  79.  
  80.     //Prefab for single cube that we use to construct platforms from
  81.     public GameObject singleCubePrefab;
  82.     //Prefab lists for non-tileable and tileable platforms (SPACE)
  83.     public GameObject[] nonTileablePlatforms_space = new GameObject[2];
  84.     public GameObject[] tileablePlatforms_space = new GameObject[3];
  85.  
  86.     //Create addressList of all the positions/offsets from origin we can spawn a block at
  87.     public const int blockAddressListEntryCount = 100;
  88.     private blockAddress[] addressList = new blockAddress[blockAddressListEntryCount];
  89.  
  90.     //  Create Chance Arrays (These contain percent chances)
  91.     //Block Difficulty
  92.     public difficultyChance[] easyBlockDifficultySettings    = new difficultyChance[7];
  93.     public difficultyChance[] mediumBlockDifficultySettings  = new difficultyChance[7];
  94.     public difficultyChance[] hardBlockDifficultySettings    = new difficultyChance[7];
  95.     public difficultyChance[] extremeBlockDifficultySettings = new difficultyChance[7];
  96.     //Block Count
  97.     public difficultyChance[] easyBlockCountSettings         = new difficultyChance[7];
  98.     public difficultyChance[] mediumBlockCountSettings       = new difficultyChance[7];
  99.     public difficultyChance[] hardBlockCountSettings         = new difficultyChance[7];
  100.     public difficultyChance[] extremeBlockCountSettings      = new difficultyChance[7];
  101.  
  102.     //  Create Chance Tables (These are generated using the arrays)
  103.     //Block Difficulty
  104.     public SByte[] easyBlockDifficultyChancesTable    = new SByte[100];
  105.     public SByte[] mediumBlockDifficultyChancesTable  = new SByte[100];
  106.     public SByte[] hardBlockDifficultyChancesTable    = new SByte[100];
  107.     public SByte[] extremeBlockDifficultyChancesTable = new SByte[100];
  108.     //Block Count
  109.     public SByte[] easyBlockCountChancesTable         = new SByte[100];
  110.     public SByte[] mediumBlockCountChancesTable       = new SByte[100];
  111.     public SByte[] hardBlockCountChancesTable         = new SByte[100];
  112.     public SByte[] extremeBlockCountChancesTable      = new SByte[100];
  113.  
  114.  
  115.     /*============================================================================================================================*/
  116.     /*  Settings - Block Difficulty & Block Count
  117.     /*============================================================================================================================*/
  118.  
  119.     /*  Block Difficulty Settings
  120.     ------------------------------
  121.       Description:
  122.         These settings determine the chances of the generator selecting various difficulty blocks
  123.         at varying difficulty settings. For each difficulty the chances MUST add up to 100 or errors will occur.
  124.         This is the chances for the difficulty of blocks, where 7 is the hardest and 1 is the easiest.
  125.     */
  126.     void blockDifficultySettings() {
  127.         /*                          Block Difficulty Selection Chances */
  128.         /* Easy Difficulty */
  129.         easyBlockDifficultySettings[0].d = 1; easyBlockDifficultySettings[0].c = 5;
  130.         easyBlockDifficultySettings[1].d = 2; easyBlockDifficultySettings[1].c = 25;
  131.         easyBlockDifficultySettings[2].d = 3; easyBlockDifficultySettings[2].c = 25;
  132.         easyBlockDifficultySettings[3].d = 4; easyBlockDifficultySettings[3].c = 25;
  133.         easyBlockDifficultySettings[4].d = 5; easyBlockDifficultySettings[4].c = 15;
  134.         easyBlockDifficultySettings[5].d = 6; easyBlockDifficultySettings[5].c = 5;
  135.         easyBlockDifficultySettings[6].d = 7; easyBlockDifficultySettings[6].c = 0;
  136.         /* Medium Difficulty */
  137.         mediumBlockDifficultySettings[0].d = 1; mediumBlockDifficultySettings[0].c = 0;
  138.         mediumBlockDifficultySettings[1].d = 2; mediumBlockDifficultySettings[1].c = 20;
  139.         mediumBlockDifficultySettings[2].d = 3; mediumBlockDifficultySettings[2].c = 20;
  140.         mediumBlockDifficultySettings[3].d = 4; mediumBlockDifficultySettings[3].c = 25;
  141.         mediumBlockDifficultySettings[4].d = 5; mediumBlockDifficultySettings[4].c = 25;
  142.         mediumBlockDifficultySettings[5].d = 6; mediumBlockDifficultySettings[5].c = 10;
  143.         mediumBlockDifficultySettings[6].d = 7; mediumBlockDifficultySettings[6].c = 0;
  144.         /* Hard Difficulty */
  145.         hardBlockDifficultySettings[0].d = 1; hardBlockDifficultySettings[0].c = 0;
  146.         hardBlockDifficultySettings[1].d = 2; hardBlockDifficultySettings[1].c = 5;  
  147.         hardBlockDifficultySettings[2].d = 3; hardBlockDifficultySettings[2].c = 10;  
  148.         hardBlockDifficultySettings[3].d = 4; hardBlockDifficultySettings[3].c = 30;  
  149.         hardBlockDifficultySettings[4].d = 5; hardBlockDifficultySettings[4].c = 30;  
  150.         hardBlockDifficultySettings[5].d = 6; hardBlockDifficultySettings[5].c = 15;  
  151.         hardBlockDifficultySettings[6].d = 7; hardBlockDifficultySettings[6].c = 10;
  152.         /* Extreme Difficulty */
  153.         extremeBlockDifficultySettings[0].d = 1; extremeBlockDifficultySettings[0].c = 0;
  154.         extremeBlockDifficultySettings[1].d = 2; extremeBlockDifficultySettings[1].c = 0;
  155.         extremeBlockDifficultySettings[2].d = 3; extremeBlockDifficultySettings[2].c = 0;
  156.         extremeBlockDifficultySettings[3].d = 4; extremeBlockDifficultySettings[3].c = 25;
  157.         extremeBlockDifficultySettings[4].d = 5; extremeBlockDifficultySettings[4].c = 25;
  158.         extremeBlockDifficultySettings[5].d = 6; extremeBlockDifficultySettings[5].c = 30;
  159.         extremeBlockDifficultySettings[6].d = 7; extremeBlockDifficultySettings[6].c = 20;
  160.     }
  161.  
  162.     /*  Block Count Settings
  163.     ------------------------------
  164.       Description:
  165.         These settings determine the chances of the generator selecting various difficulty blocks
  166.         at varying difficulty settings. For each difficulty the chances MUST add up to 100 or errors will occur.
  167.         This is the chances for the count of blocks, where 7 spawns 7 blocks and 1 spawns 1 block.
  168.     */
  169.     void blockCountSettings() {
  170.         /*                          Block Amount Selection Chances */
  171.         easyBlockCountSettings[0].d = 1; easyBlockCountSettings[0].c = 0;
  172.         easyBlockCountSettings[1].d = 2; easyBlockCountSettings[1].c = 10;
  173.         easyBlockCountSettings[2].d = 3; easyBlockCountSettings[2].c = 20;
  174.         easyBlockCountSettings[3].d = 4; easyBlockCountSettings[3].c = 20;
  175.         easyBlockCountSettings[4].d = 5; easyBlockCountSettings[4].c = 20;
  176.         easyBlockCountSettings[5].d = 6; easyBlockCountSettings[5].c = 20;
  177.         easyBlockCountSettings[6].d = 7; easyBlockCountSettings[6].c = 10;
  178.         /* Medium Difficulty */
  179.         mediumBlockCountSettings[0].d = 1; mediumBlockCountSettings[0].c = 5;  
  180.         mediumBlockCountSettings[1].d = 2; mediumBlockCountSettings[1].c = 25;
  181.         mediumBlockCountSettings[2].d = 3; mediumBlockCountSettings[2].c = 25;
  182.         mediumBlockCountSettings[3].d = 4; mediumBlockCountSettings[3].c = 15;
  183.         mediumBlockCountSettings[4].d = 5; mediumBlockCountSettings[4].c = 15;
  184.         mediumBlockCountSettings[5].d = 6; mediumBlockCountSettings[5].c = 10;
  185.         mediumBlockCountSettings[6].d = 7; mediumBlockCountSettings[6].c = 5;
  186.         /* Hard Difficulty */
  187.         hardBlockCountSettings[0].d = 1; hardBlockCountSettings[0].c = 20;
  188.         hardBlockCountSettings[1].d = 2; hardBlockCountSettings[1].c = 25;  
  189.         hardBlockCountSettings[2].d = 3; hardBlockCountSettings[2].c = 30;  
  190.         hardBlockCountSettings[3].d = 4; hardBlockCountSettings[3].c = 10;  
  191.         hardBlockCountSettings[4].d = 5; hardBlockCountSettings[4].c = 10;  
  192.         hardBlockCountSettings[5].d = 6; hardBlockCountSettings[5].c = 5;  
  193.         hardBlockCountSettings[6].d = 7; hardBlockCountSettings[6].c = 0;
  194.         /* Extreme Difficulty */
  195.         extremeBlockCountSettings[0].d = 1; extremeBlockCountSettings[0].c = 30;
  196.         extremeBlockCountSettings[1].d = 2; extremeBlockCountSettings[1].c = 40;
  197.         extremeBlockCountSettings[2].d = 3; extremeBlockCountSettings[2].c = 20;
  198.         extremeBlockCountSettings[3].d = 4; extremeBlockCountSettings[3].c = 10;
  199.         extremeBlockCountSettings[4].d = 5; extremeBlockCountSettings[4].c = 0;
  200.         extremeBlockCountSettings[5].d = 6; extremeBlockCountSettings[5].c = 0;
  201.         extremeBlockCountSettings[6].d = 7; extremeBlockCountSettings[6].c = 0;
  202.     }
  203.  
  204.     /*============================================================================================================================*/
  205.     /*  Functions
  206.     /*============================================================================================================================*/
  207.  
  208.     /*  Start-Up (Initialization)
  209.     -------------------------------------
  210.       Description:
  211.         Builds key public values for later use (addressList and chance tables).
  212.         If createOnStartup enabled, run generatePrefabs with given public variables.
  213.     */
  214.     void Start () {
  215.  
  216.         //We do it this way to make sure we always get the correct game controller
  217.         eSys = GameObject.Find ("GameController").GetComponent<gameController> ().lvlCtrl.GetComponent<eventSystem> ();
  218.         c_difficultySetting = eSys.arcadeDifficulty;
  219.  
  220.         //Build the address list using pre-determined values for difficulty and xy
  221.         buildAddressList ();
  222.  
  223.         //Create chance tables from difficulty settings
  224.         buildSettingsChanceTables ();
  225.  
  226.         //Recommended use...
  227.         if (createOnStartUp) {
  228.             StartCoroutine (prefabSpawnLoop ());
  229.         };
  230.    
  231.     //Prefab spawning loop co-routine
  232.     } IEnumerator prefabSpawnLoop() {
  233.  
  234.         //2 is real minimum lead ahead
  235.         c_leadAheadBy = Math.Max(c_leadAheadBy, 3);
  236.  
  237.         //Create 2 sets of platforms
  238.         GameObject oldestSetLastPlatform = generatePrefabs (c_leadAheadBy / 2, c_difficultySetting, new Vector2(c_startPlatform.transform.position.x, c_startPlatform.transform.position.y));
  239.         GameObject youngestSetLastPlatform = generatePrefabs (c_leadAheadBy / 2, c_difficultySetting, new Vector2(oldestSetLastPlatform.transform.position.x, oldestSetLastPlatform.transform.position.y));
  240.  
  241.         //Loop until stopped
  242.         while (!stopGenerating) {
  243.  
  244.             //Delete all that are more than 30 units behind where the player is
  245.             GameObject[] foundPlats = GameObject.FindGameObjectsWithTag ("platform");
  246.             foreach (GameObject plat in foundPlats) { if (plat.transform.position.x < (playerPos.position.x - 30f)) { Destroy(plat); }; };
  247.  
  248.             //If player has passed the oldest set and is now on the youngest set platforms (giving 3f extra leeway)
  249.             if (playerPos.position.x > (oldestSetLastPlatform.transform.position.x - 3f)) {
  250.  
  251.                 //Create 2 new sets
  252.                 oldestSetLastPlatform = generatePrefabs (c_leadAheadBy / 2, c_difficultySetting, new Vector2(youngestSetLastPlatform.transform.position.x, youngestSetLastPlatform.transform.position.y));
  253.                 youngestSetLastPlatform = generatePrefabs (c_leadAheadBy / 2, c_difficultySetting, new Vector2(oldestSetLastPlatform.transform.position.x, oldestSetLastPlatform.transform.position.y));
  254.             }
  255.  
  256.             //Wait before re-checking
  257.             yield return new WaitForSeconds (1f);
  258.         };
  259.     }
  260.  
  261.  
  262.     /* Generate Platform
  263.     --------------------
  264.     Description:
  265.         This generates a platform offset from the given origin based on input difficulty and the difficultySettings.
  266.         It starts at the given vector2 and generates a platform of 1-7 blocks (can be overriden). These platforms
  267.         are a jump away from the current one and none are directly connected.
  268.       Inputs (Non-Optional):
  269.         difficultySetting   (sByte):    Range from 1 (easy), 2 (medium), 3 (hard), 4 (extreme)
  270.         originPoint         (Vector2):  Where to start (first platform will be created based on this origin point)
  271.       Inputs (Optional Overrides):
  272.         blockCountOverride  (sByte):    Amount of blocks to spawn at location chosen
  273.         UpOnlyOverride      (bool):     Whether or not to only spawn blocks with a POSITIVE Y value.
  274.         DownOnlyOverride    (bool):     Whether or not to only spawn blocks with a NEGATIVE Y value.
  275.         LeftOnlyOverride    (bool):     Whether or not to only spawn blocks with a NEGATIVE X value.
  276.         RightOnlyOverride   (bool):     Whether or not to only spawn blocks with a POSITIVE X value.
  277.     */
  278.  
  279.     GameObject generatePlatform(SByte difficultySetting, Vector2 originPoint, SByte blockCountOverride = 0, bool upOnlyOverride = false, bool downOnlyOverride = false, bool leftOnlyOverride = false, bool rightOnlyOverride = false) {
  280.  
  281.         /*  Variable Declarations & Set-Up
  282.         -----------------------------------
  283.         */
  284.  
  285.         //Used to store the chosen offset address from the addressList table
  286.         blockAddress addressToSpawnAt;
  287.  
  288.         //Used to store the address once it has been converted from offset (addressToSpawnAt)
  289.         Vector2 finalAddress;
  290.  
  291.         //Used to store the last-created object
  292.         GameObject createdObject = null;
  293.  
  294.         //Selected amount of blocks to spawn (selected from chance table)
  295.         SByte amntOfBlocksToSpawn;
  296.  
  297.         //Selected block difficulty level (selected from chance table)
  298.         SByte blockDifficulty;
  299.  
  300.         //Create chance table arrays
  301.         SByte[] difficultyChanceTable;
  302.         SByte[] blockCountChanceTable;
  303.  
  304.         //Based on input difficulty setting, set our chance table array values (see buildSettingsChanceTables for more info)
  305.         switch (difficultySetting) {
  306.             case 1:     difficultyChanceTable = easyBlockDifficultyChancesTable;        blockCountChanceTable = easyBlockCountChancesTable;         break;
  307.             case 2:     difficultyChanceTable = mediumBlockDifficultyChancesTable;      blockCountChanceTable = mediumBlockCountChancesTable;       break;
  308.             case 3:     difficultyChanceTable = hardBlockDifficultyChancesTable;        blockCountChanceTable = hardBlockCountChancesTable;         break;
  309.             case 4:     difficultyChanceTable = extremeBlockDifficultyChancesTable;     blockCountChanceTable = extremeBlockCountChancesTable;      break;
  310.             default:    difficultyChanceTable = mediumBlockDifficultyChancesTable;      blockCountChanceTable = mediumBlockCountChancesTable;       break;
  311.         }
  312.  
  313.         /*  Select Difficulty & Amount of Blocks to Spawn
  314.         --------------------------------------------------
  315.         */
  316.  
  317.         //Find random address to start with (prevents compiler errors)
  318.         addressToSpawnAt = findRandomAddressInRange (0, (blockAddressListEntryCount - 1));
  319.  
  320.         //Select difficulty for block using chance table generated from difficulty settings
  321.         blockDifficulty = Convert.ToSByte(UnityEngine.Random.Range(0,99));
  322.         blockDifficulty = difficultyChanceTable [blockDifficulty];
  323.  
  324.         //Check amount of block ovverride value
  325.         if (blockCountOverride > 0) {
  326.             //Set amount of blocks to spawn from ovverride
  327.             amntOfBlocksToSpawn = blockCountOverride;
  328.         } else {
  329.             //Pick block amount using chance table generated from difficulty settings
  330.             amntOfBlocksToSpawn = Convert.ToSByte(UnityEngine.Random.Range(0,99));
  331.             amntOfBlocksToSpawn = blockCountChanceTable [amntOfBlocksToSpawn];
  332.         };
  333.  
  334.         /*  Check Up Down Left Right Overrides
  335.         --------------------------------------------------
  336.         */
  337.         SByte minX = -12;       SByte maxX = 12;        SByte minY = -12;       SByte maxY = 12;
  338.         //Up
  339.         if (upOnlyOverride) {           minY = 0;       };
  340.         //Down
  341.         if (downOnlyOverride) {         maxY = 0;       };
  342.         //Left
  343.         if (leftOnlyOverride) {         maxX = 0;       };
  344.         //Right
  345.         if (rightOnlyOverride) {        minX = 0;       };
  346.  
  347.         /*  Select Block Spawn Address using Difficulty & Overrides
  348.         -----------------------------------------------------------
  349.         */
  350.  
  351.         //If no override for up/down are active then keep the map flat and level
  352.         if (!upOnlyOverride && !downOnlyOverride) {
  353.             /* To prevent random chance taking the map upwards/downwards until we're at +-1000 in the y axis we need
  354.            to to use a maximum 'stray' from 0 value for y. When we're at 0y they up/down have equal (50% chance).
  355.            As we approach the 'stray' value the chance should adjust to prevent it reaching the min/max. */
  356.             float curY = originPoint.y;
  357.             float upChance = 50f;
  358.             float modifier = 0f;
  359.  
  360.             //Create chance using minY,maxY,50% starting baseline, and current origin Y pos
  361.             modifier = ((1 / (Math.Abs (maxStray) / Math.Abs (curY))) / 2) * 100;
  362.  
  363.             //Check if y is positive or negative/0 and add/take depending
  364.             upChance = (curY > 0f) ? (upChance - modifier) : (upChance + modifier);
  365.  
  366.             //Generate random number between and inclusive of 1 and 100
  367.             //And if it is less than the upChance then generate upwards, if not then downwards
  368.             //Format: (Desired Difficulty Index,  Min X Offset, Max X Offset, Min Y Offset, Max Y Offset, AddressList Range to Search In Start & End Array Indexes)
  369.             addressToSpawnAt = (UnityEngine.Random.Range (1, 100) < upChance) ? (findAddress (blockDifficulty, minX, maxX, 0, 12, 0, (blockAddressListEntryCount - 1))) : (findAddress (blockDifficulty, minX, maxX, -8, 0, 0, (blockAddressListEntryCount - 1)));
  370.         } else {
  371.             //We have overrides for up/down, ignore flat-level-keeping code/maxStray value
  372.             findAddress (blockDifficulty, minX, maxX, minY, maxY, 0, (blockAddressListEntryCount - 1));
  373.         };
  374.  
  375.         //Do maths on address to get real world pos (have to convert from SByte)
  376.         finalAddress.x = originPoint.x + Convert.ToSingle(addressToSpawnAt.x);
  377.         finalAddress.y = originPoint.y + Convert.ToSingle(addressToSpawnAt.y);
  378.  
  379.         /*  Spawn Platform into Level and Return it
  380.         -----------------------------------------------------------
  381.         */
  382.  
  383.         //Spawn blocks using amount of blocks to spawn chosen from chance table
  384.         for (int j = 0; j < amntOfBlocksToSpawn; j++) {
  385.  
  386.             //Instantiate a cube, add j (for-index (starts at 0)) to the position on each iteration
  387.             // So that the squares sit in a line from left to right
  388.             createdObject = (GameObject) Instantiate (singleCubePrefab, new Vector3(finalAddress.x + j, finalAddress.y), Quaternion.identity);
  389.  
  390.             //Update origin point for next iteration to last objects position
  391.             originPoint = createdObject.transform.position;
  392.         }  
  393.  
  394.         //Return last created object to calling code
  395.         return createdObject;
  396.     }
  397.  
  398.  
  399.     /*  Generate Prefabs
  400.     ---------------------
  401.       Description:
  402.         This generates prefabs based on input difficulty and the difficultySettings.
  403.         It starts at the given vector2 and generates prefabs in a loop until it reaches the prefabsToGenerate number of prefabs created.
  404.         Prefabs here are defined as platforms of 1 to 7 blocks.
  405.       Inputs:
  406.         prefabsToGenerate   (int):  Amount of platforms/prefabs to create
  407.         inputDifficulty     (int):  Range from 1 (easy), 2 (medium), 3 (hard), 4 (extreme)
  408.         originPoint     (Vector2):  Where to start (first platform will be created based on this origin point)
  409.     */ 
  410.     GameObject generatePrefabs(int prefabsToGenerate, int inputDifficulty, Vector2 originPoint) {
  411.  
  412.         /*  Variable Declarations & Set-Up
  413.         -----------------------------------
  414.         */
  415.  
  416.         //Used to store the chosen offset address from the addressList table
  417.         blockAddress addressToSpawnAt;
  418.  
  419.         //Used to store the address once it has been converted from offset (addressToSpawnAt)
  420.         Vector2 finalAddress;
  421.  
  422.         //Used to store the last-created object
  423.         GameObject createdObject = null;
  424.  
  425.         //Selected amount of blocks to spawn (selected from chance table)
  426.         SByte amntOfBlocksToSpawn;
  427.  
  428.         //Selected block difficulty level (selected from chance table)
  429.         SByte blockDifficulty;
  430.  
  431.         //Create chance table arrays
  432.         SByte[] difficultyChanceTable;
  433.         SByte[] blockCountChanceTable;
  434.  
  435.         //Based on input difficulty setting, set our chance table array values (see buildSettingsChanceTables for more info)
  436.         switch (inputDifficulty) {
  437.             case 1:     difficultyChanceTable = easyBlockDifficultyChancesTable;        blockCountChanceTable = easyBlockCountChancesTable;         break;
  438.             case 2:     difficultyChanceTable = mediumBlockDifficultyChancesTable;      blockCountChanceTable = mediumBlockCountChancesTable;       break;
  439.             case 3:     difficultyChanceTable = hardBlockDifficultyChancesTable;        blockCountChanceTable = hardBlockCountChancesTable;         break;
  440.             case 4:     difficultyChanceTable = extremeBlockDifficultyChancesTable;     blockCountChanceTable = extremeBlockCountChancesTable;      break;
  441.             default:    difficultyChanceTable = mediumBlockDifficultyChancesTable;      blockCountChanceTable = mediumBlockCountChancesTable;       break;
  442.         }
  443.  
  444.         /*  Prefab-Spawning-Loop
  445.         -------------------------
  446.         */
  447.  
  448.         //Create and set this to false for start-up of loop
  449.         bool disableDownForPlatform = false;
  450.  
  451.         //Loop to spawn prefabs/platforms, each iteration spawns one, run until input number reached.
  452.         for (int i = 0; i < prefabsToGenerate; i++) {
  453.  
  454.             //Find random address to start with (prevents compiler errors)
  455.             addressToSpawnAt = findRandomAddressInRange (0, (blockAddressListEntryCount - 1));
  456.  
  457.             //Select difficulty for block using chance table generated from difficulty settings
  458.             blockDifficulty = Convert.ToSByte(UnityEngine.Random.Range(0,99));
  459.             blockDifficulty = difficultyChanceTable [blockDifficulty];
  460.  
  461.             //Pick block amount using chance table generated from difficulty settings
  462.             amntOfBlocksToSpawn = Convert.ToSByte(UnityEngine.Random.Range(0,99));
  463.             amntOfBlocksToSpawn = blockCountChanceTable [amntOfBlocksToSpawn];
  464.  
  465.             //If first prefab from loop then never go left
  466.             if (i == 0) {
  467.                 //Range is 3 to end as first 3 are only blocks with negative/0 for an x value
  468.                 addressToSpawnAt = findAddress (blockDifficulty, 0, 12, -8, 12, 3, (blockAddressListEntryCount - 1));
  469.  
  470.             } else {
  471.                
  472.                 //Not first block from loop, can go left now :)
  473.                 //If we don't want to disable down for this platform and we can use the full range of addresses
  474.                 if (!disableDownForPlatform) {
  475.  
  476.                     /* To prevent random chance taking the map upwards/downwards until we're at +-1000 in the y axis we need
  477.                        to to use a maximum 'stray' from 0 value for y. When we're at 0y they up/down have equal (50% chance).
  478.                        As we approach the 'stray' value the chance should adjust to prevent it reaching the min/max. */
  479.                     float maxStray = 20;
  480.                     float curY = originPoint.y;
  481.                     float upChance = 50;
  482.                     float modifier = 0;
  483.  
  484.                     //Create chance using minY,maxY,50% starting baseline, and current origin Y pos
  485.                     modifier = ((1 / (Math.Abs(maxStray) / Math.Abs(curY))) / 2) * 100;
  486.  
  487.                     //Check if y is positive or negative/0 and add/take depending
  488.                     upChance = (curY > 0f) ? (upChance - modifier) : (upChance + modifier);
  489.  
  490.                     //Generate random number between and inclusive of 1 and 100
  491.                     //And if it is less than the upChance then generate upwards, if not then downwards
  492.                     //Format: (Desired Difficulty Index,  Min X Offset, Max X Offset, Min Y Offset, Max Y Offset, AddressList Range to Search In Start & End Array Indexes)
  493.                     addressToSpawnAt = (UnityEngine.Random.Range (1, 100) < upChance) ? (findAddress (blockDifficulty, -8, 12, 0, 12, 0, (blockAddressListEntryCount - 1))) : (findAddress (blockDifficulty, -8, 12, -8, 0, 0, (blockAddressListEntryCount - 1)));
  494.                 } else {
  495.                     //Pick random address, using only values with positive Y Value since disableDownForNextPlatform is ON for this platform.
  496.                     //Format: (Desired Difficulty Index,  Min X Offset, Max X Offset, Min Y Offset, Max Y Offset, AddressList Range to Search In Start & End Array Indexes)
  497.                     addressToSpawnAt = findAddress (blockDifficulty, -8, 12, 1, 12, 0, (blockAddressListEntryCount - 1));
  498.                 };
  499.                    
  500.                 //If address is same as either of first 3 entries in list (which are blocks directly above/left of origin)
  501.                 if (addressToSpawnAt.x == addressList[0].x || addressToSpawnAt.y == addressList[0].y || addressToSpawnAt.x == addressList[1].x || addressToSpawnAt.y == addressList[1].y || addressToSpawnAt.x == addressList[2].x || addressToSpawnAt.y == addressList[2].y) {
  502.                     disableDownForPlatform = true;
  503.                 } else {
  504.                     disableDownForPlatform = false;
  505.                 };
  506.  
  507.             };
  508.  
  509.             //Do maths on address to get real world pos (have to convert from SByte)
  510.             finalAddress.x = originPoint.x + Convert.ToSingle(addressToSpawnAt.x);
  511.             finalAddress.y = originPoint.y + Convert.ToSingle(addressToSpawnAt.y);
  512.  
  513.  
  514.             //  If amount of blocks to spawn is 1, then pick one of the single platforms that aren't tilable
  515.             //  If amount of blocks is 2 then spawn one with leftEnd and one with rightEnd from tilable set
  516.             //  If amount of blocks is 3 then spawn one with leftEnd, 1x middle, and one with rightEnd
  517.             //  If amount of blocks is 4 then spawn one with leftEnd, 2x middle, and one with rightEnd
  518.             //  If amount of blocks is 5 then spawn one with leftEnd, 3x middle and one with rightEnd
  519.             //  etc
  520.  
  521.             GameObject prefabToSpawn = singleCubePrefab;
  522.  
  523.             switch (amntOfBlocksToSpawn) {
  524.             case 1:
  525.                 //Pick non-tileable platform at random
  526.                 if (randBool ()) {
  527.                     prefabToSpawn = nonTileablePlatforms_space [0];
  528.                 } else {
  529.                     prefabToSpawn = nonTileablePlatforms_space [1];
  530.                 };
  531.  
  532.                 //Spawn it
  533.                 createdObject = (GameObject) Instantiate (prefabToSpawn, new Vector3(finalAddress.x, finalAddress.y), Quaternion.identity);
  534.  
  535.                 //Parent it to levelController
  536.                 createdObject.transform.SetParent (this.gameObject.transform);
  537.  
  538.                 break;
  539.             case 2:
  540.                  
  541.                 //Spawn left end
  542.                 createdObject = spawnRandomTileablePiece (finalAddress, true, false);
  543.  
  544.                 //Spawn right end
  545.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 1, finalAddress.y), false, true);
  546.  
  547.                 break;
  548.  
  549.             case 3:
  550.                
  551.                 //Spawn left end
  552.                 createdObject = spawnRandomTileablePiece (finalAddress, true, false);
  553.  
  554.                 //Spawn middle
  555.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 1, finalAddress.y), false, false);
  556.  
  557.                 //Spawn right end
  558.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 2, finalAddress.y), false, true);
  559.  
  560.                 break;
  561.            
  562.             case 4:
  563.  
  564.                 //Spawn left end
  565.                 createdObject = spawnRandomTileablePiece (finalAddress, true, false);
  566.  
  567.                 //Spawn middle
  568.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 1, finalAddress.y), false, false);
  569.  
  570.                 //Spawn middle
  571.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 2, finalAddress.y), false, false);
  572.  
  573.                 //Spawn right end
  574.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 3, finalAddress.y), false, true);
  575.  
  576.                 break;
  577.             case 5:
  578.  
  579.                 //Spawn left end
  580.                 createdObject = spawnRandomTileablePiece (finalAddress, true, false);
  581.  
  582.                 //Spawn middle
  583.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 1, finalAddress.y), false, false);
  584.  
  585.                 //Spawn middle
  586.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 2, finalAddress.y), false, false);
  587.  
  588.                 //Spawn middle
  589.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 3, finalAddress.y), false, false);
  590.  
  591.                 //Spawn right end
  592.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 4, finalAddress.y), false, true);
  593.  
  594.                 break;
  595.  
  596.             case 6:
  597.  
  598.                 //Spawn left end
  599.                 createdObject = spawnRandomTileablePiece (finalAddress, true, false);
  600.  
  601.                 //Spawn middle
  602.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 1, finalAddress.y), false, false);
  603.  
  604.                 //Spawn middle
  605.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 2, finalAddress.y), false, false);
  606.  
  607.                 //Spawn middle
  608.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 3, finalAddress.y), false, false);
  609.  
  610.                 //Spawn middle
  611.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 4, finalAddress.y), false, false);
  612.  
  613.                 //Spawn right end
  614.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 5, finalAddress.y), false, true);
  615.  
  616.                 break;
  617.  
  618.             case 7:
  619.                
  620.                 //Spawn left end
  621.                 createdObject = spawnRandomTileablePiece (finalAddress, true, false);
  622.  
  623.                 //Spawn middle
  624.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 1, finalAddress.y), false, false);
  625.  
  626.                 //Spawn middle
  627.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 2, finalAddress.y), false, false);
  628.  
  629.                 //Spawn middle
  630.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 3, finalAddress.y), false, false);
  631.            
  632.                 //Spawn middle
  633.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 4, finalAddress.y), false, false);
  634.  
  635.                 //Spawn middle
  636.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 5, finalAddress.y), false, false);
  637.  
  638.                 //Spawn right end
  639.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 6, finalAddress.y), false, true);
  640.  
  641.                 break;
  642.  
  643.             case 8:
  644.                
  645.                 //Spawn left end
  646.                 createdObject = spawnRandomTileablePiece (finalAddress, true, false);
  647.  
  648.                 //Spawn middle
  649.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 1, finalAddress.y), false, false);
  650.  
  651.                 //Spawn middle
  652.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 2, finalAddress.y), false, false);
  653.  
  654.                 //Spawn middle
  655.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 3, finalAddress.y), false, false);
  656.  
  657.                 //Spawn middle
  658.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 4, finalAddress.y), false, false);
  659.  
  660.                 //Spawn middle
  661.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 5, finalAddress.y), false, false);
  662.  
  663.                 //Spawn middle
  664.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 6, finalAddress.y), false, false);
  665.  
  666.                 //Spawn right end
  667.                 createdObject = spawnRandomTileablePiece (new Vector3(finalAddress.x + 7, finalAddress.y), false, true);
  668.  
  669.                 break;
  670.  
  671.             default:
  672.                 break;
  673.             }
  674.  
  675.             //Update origin point for next iteration to last objects position
  676.             originPoint = createdObject.transform.position;
  677.  
  678.             /*//    old code for single cube spawning
  679.  
  680.             //Spawn blocks using amount of blocks to spawn chosen from chance table
  681.             for (int j = 0; j < amntOfBlocksToSpawn; j++) {
  682.                
  683.                 //Instantiate a cube, add j (for-index (starts at 0)) to the position on each iteration
  684.                 // So that the squares sit in a line from left to right
  685.                 createdObject = (GameObject) Instantiate (singleCubePrefab, new Vector3(finalAddress.x + j, finalAddress.y), Quaternion.identity);
  686.  
  687.                 //Update origin point for next iteration to last objects position
  688.                 originPoint = createdObject.transform.position;
  689.             }
  690.            
  691.             //*/
  692.  
  693.         } //End of prefab spawning loop.
  694.  
  695.         //Return last created object to calling code
  696.         return createdObject;
  697.     }
  698.  
  699.     /*  Function:       spawnRandomTilablePiece
  700.         Description:    Spawns random space tilable piece it at the input pos with input end pieces
  701.     */
  702.     private GameObject spawnRandomTileablePiece(Vector2 spawnPos, bool enableLeftEnd, bool enableRightEnd) {
  703.  
  704.         //Pick random piece
  705.         GameObject prefabToSpawn = pickRandomTilablePiece();
  706.  
  707.         //Spawn it at input pos
  708.         GameObject obj = (GameObject)Instantiate(prefabToSpawn, spawnPos, Quaternion.identity);
  709.  
  710.         //Parent it to levelController
  711.         obj.transform.SetParent (this.gameObject.transform);
  712.  
  713.         //Randomly flip it
  714.         if (randBool ()) {
  715.             //Flip it
  716.             Vector3 objScale = obj.transform.localScale;    objScale.x *= -1;   obj.transform.localScale = objScale;
  717.             //Flip end bools
  718.             if (enableLeftEnd) { enableLeftEnd = false; enableRightEnd = true; } else if (enableRightEnd) { enableRightEnd = false; enableLeftEnd = true; };
  719.             //Move it to correct pos (plus one on x axis)
  720.             obj.transform.position = new Vector2 (obj.transform.position.x + 1, obj.transform.position.y);
  721.         };
  722.            
  723.         //Enable end pieces
  724.         if (enableLeftEnd || enableRightEnd) {
  725.             enableEndPiece(enableLeftEnd, enableRightEnd, obj);
  726.         }
  727.  
  728.         //Return object
  729.         return obj;
  730.     }
  731.  
  732.     /*  Function:       pickRandomTilablePiece
  733.         Description:    Picks a random tileable piece from the set of 4
  734.     */
  735.     private GameObject pickRandomTilablePiece() {
  736.         GameObject prefabToSpawn = singleCubePrefab;
  737.  
  738.         if (randBool())
  739.         {
  740.             if (randBool())
  741.             {
  742.                 prefabToSpawn = tileablePlatforms_space[0];
  743.             }
  744.             else
  745.             {
  746.                 prefabToSpawn = tileablePlatforms_space[1];
  747.             };
  748.         }
  749.         else
  750.         {
  751.             prefabToSpawn = tileablePlatforms_space[2];
  752.         };
  753.  
  754.         return prefabToSpawn;
  755.     }
  756.  
  757.  
  758.     /*  Function:       enableEndPiece
  759.         Description:    Enables left or right end pieces based on inputs
  760.     */
  761.     private void enableEndPiece(bool left, bool right, GameObject platformObject) {
  762.         if (left) {
  763.             //Enable leftEnd piece
  764.             GameObject leftEndParent = platformObject.transform.FindChild("endPieces").FindChild ("leftEnd").gameObject;
  765.             leftEndParent.SetActive(true);
  766.         }
  767.         if (right) {
  768.             //Enable rightEnd piece
  769.             GameObject rightEndParent = platformObject.transform.FindChild("endPieces").FindChild ("rightEnd").gameObject;
  770.             rightEndParent.SetActive(true);
  771.         }
  772.     }
  773.  
  774.     /*  Function:       randBool
  775.         Description:    50/50 chance of returning true or false
  776.     */
  777.     private bool randBool() { return UnityEngine.Random.value > 0.5f; }
  778.  
  779.     /*  Find Random Address In Range
  780.     -------------------------------------
  781.       Description:
  782.         Picks a random address within the given range.
  783.       Inputs:
  784.         rangeStart  (int): The start of the address range (0-(blockAddressListEntryCount - 1)) to search within
  785.         rangeEnd    (int): The end of the address range (0-(blockAddressListEntryCount - 1)) to search within
  786.       Outputs:
  787.         blockAddress: An address within the range
  788.     */
  789.     blockAddress findRandomAddressInRange (int rangeStart, int rangeEnd) {
  790.         int randomAddressID;
  791.         randomAddressID = UnityEngine.Random.Range(rangeStart,rangeEnd);
  792.         return (addressList[randomAddressID]);
  793.     }
  794.  
  795.     /*  Find Address
  796.     -------------------------------------
  797.       Description:
  798.         Strips the addressList of all values that don't meet the given criteria, then selects randomly from the new list.
  799.       Inputs:
  800.         blockDifficulty (SByte): The difficulty (1-7) of block to search for.
  801.         Min X Offset    (SByte): The minimum x offset position
  802.         Max X Offset    (SByte): The maximum x offset position
  803.         Min Y Offset    (SByte): The minimum y offset position
  804.         Max Y Offset    (SByte): The maximum y offset position
  805.         rangeStart      (int):   The start of the address range (0-(blockAddressListEntryCount - 1)) to search within
  806.         rangeEnd        (int):   The end of the address range (0-(blockAddressListEntryCount - 1)) to search within
  807.       Outputs:
  808.         blockAddress: The address found that matches the given criteria
  809.     */
  810.     blockAddress findAddress(SByte blockDifficulty, SByte min_x, SByte max_x, SByte min_y, SByte max_y, int rangeStart, int rangeEnd) {
  811.  
  812.         //Create temporary addressList to store valid addresses we find
  813.         List<blockAddress> tempAddressList = new List<blockAddress>();
  814.  
  815.         //For each address in the user specified range
  816.         for (int i = rangeStart; i < (rangeEnd - 1); i++) {
  817.             //Get address as var
  818.             blockAddress currentBlock = addressList[i];
  819.  
  820.             //If difficulty does not match, move on to next address
  821.             if (currentBlock.d != blockDifficulty) { continue; };
  822.  
  823.             //If position does not meet criteria move on to next address
  824.             if (currentBlock.x > max_x || currentBlock.x < min_x || currentBlock.y > max_y || currentBlock.y < min_y) { continue; };
  825.  
  826.             //If we got this far the address is valid, add it to our tempAddressList
  827.             tempAddressList.Add(currentBlock);
  828.         };
  829.  
  830.         int addressListCount = tempAddressList.Count;
  831.  
  832.         //Ensure we have values in our list
  833.         if (addressListCount == 0) {
  834.             return addressList [0];
  835.         } else {
  836.             int randSel = 0; randSel = UnityEngine.Random.Range(0,addressListCount);
  837.             return tempAddressList[randSel];
  838.         };
  839.     }
  840.  
  841.     /*  Create Chance Table
  842.     -------------------------------------
  843.       Description:
  844.         Generates arrays with 100 values using the settings values.
  845.         If in the settings a block difficulty of 7 has a 15% chance it will occupy 15/100 values.
  846.       Inputs:
  847.         inputChances (difficultyChance[]): The input chance settings to use when creating the table
  848.       Outputs:
  849.         SByte[] array of repeated values to represent their chances when selecting randomly from them all.
  850.     */
  851.     SByte[] createChanceTable(difficultyChance[] inputChances) {
  852.  
  853.         //Create output var
  854.         SByte[] table = new SByte[100];
  855.  
  856.         //Create currentIndex var (Used to maintain position in array)
  857.         int currentIndex = 0;
  858.  
  859.         /* Generate Chance Table */
  860.  
  861.         //For each set of difficulty and chance values in the input chances array
  862.         foreach (difficultyChance bD in inputChances) {
  863.             //Loop <chance> (eg 10 for 10%) amount of times, adding the difficulty as an entry to the array each time
  864.             // eg adding 10 of the difficulty (3 for example) to the array for output
  865.             for (int i = 0; (i < bD.c); i++) { table [currentIndex] = bD.d; currentIndex++; }
  866.         }
  867.  
  868.         //Return created table
  869.         return table;
  870.     }
  871.  
  872.     /*  Build Settings & Chance Tables
  873.     -------------------------------------
  874.       Description:
  875.         Builds settings tables using hard-coded values and then uses them to create chance tables. This is for
  876.         the difficulty of block (1-7) it will select at varying difficulty settings (easy-extreme) and how many
  877.         blocks it will choose to spawn at that location (1-7) depending on difficulty settings (easy-extreme).
  878.     */
  879.     void buildSettingsChanceTables() {
  880.         //Build settings for difficulty and block count
  881.         blockDifficultySettings();  blockCountSettings();
  882.         //Build chance tables for difficulty and block count
  883.         blockDifficultyCountChanceTables();
  884.     }
  885.  
  886.     /*  Block Difficulty & Count Chance Tables
  887.     -------------------------------------------
  888.       Description:
  889.         Using the blockDifficultySettings we create tables/arrays of 100 values.
  890.         With each difficulty/block amount being represented as many times as is listed
  891.         in its blockDifficultySettings chance value. Eg if 1 block has a 5 percent chance
  892.         of spawning in medium mode then '1' will occupy 5/100 values in the table, therefore
  893.         selecting a random value from that table will yeild a 5% chance of getting a 1.
  894.     */
  895.     void blockDifficultyCountChanceTables() {
  896.         /* Create Chance Tables for     Block Difficulty */
  897.         easyBlockDifficultyChancesTable    = createChanceTable (easyBlockDifficultySettings);
  898.         mediumBlockDifficultyChancesTable  = createChanceTable (mediumBlockDifficultySettings);
  899.         hardBlockDifficultyChancesTable    = createChanceTable (hardBlockDifficultySettings);
  900.         extremeBlockDifficultyChancesTable = createChanceTable (extremeBlockDifficultySettings);
  901.  
  902.         /* Create Chance Tables for     Block Count*/
  903.         easyBlockCountChancesTable    = createChanceTable (easyBlockCountSettings);
  904.         mediumBlockCountChancesTable  = createChanceTable (mediumBlockCountSettings);
  905.         hardBlockCountChancesTable    = createChanceTable (hardBlockCountSettings);
  906.         extremeBlockCountChancesTable = createChanceTable (extremeBlockCountSettings);
  907.     }
  908.  
  909.     /* Build Address List
  910.     -------------------------------------
  911.       Description:
  912.         Created using tested max-jump range values. See diagram for more info.
  913.         Format is: blockDifficulty.xOffset.yOffset
  914.     */
  915.     void buildAddressList() {
  916.         int i = 0; //Use int for array index and increment it after each value
  917.         addressList [i] = new blockAddress (5,-2,3); i++;
  918.         addressList [i] = new blockAddress (5,-1,3); i++;
  919.         addressList [i] = new blockAddress (5,0,3); i++;
  920.         addressList [i] = new blockAddress (5,1,3); i++;
  921.         addressList [i] = new blockAddress (6,2,3); i++;
  922.         addressList [i] = new blockAddress (6,3,3); i++;
  923.         addressList [i] = new blockAddress (6,4,3); i++;
  924.         addressList [i] = new blockAddress (6,5,3); i++;
  925.         addressList [i] = new blockAddress (6,6,3); i++;
  926.         addressList [i] = new blockAddress (7,7,3); i++;
  927.         addressList [i] = new blockAddress (7,8,3); i++;
  928.         addressList [i] = new blockAddress (4,1,2); i++;
  929.         addressList [i] = new blockAddress (4,2,2); i++;
  930.         addressList [i] = new blockAddress (4,3,2); i++;
  931.         addressList [i] = new blockAddress (4,4,2); i++;
  932.         addressList [i] = new blockAddress (5,5,2); i++;
  933.         addressList [i] = new blockAddress (6,6,2); i++;
  934.         addressList [i] = new blockAddress (6,7,2); i++;
  935.         addressList [i] = new blockAddress (7,8,2); i++;
  936.         addressList [i] = new blockAddress (7,9,2); i++;
  937.         addressList [i] = new blockAddress (3,3,1); i++;
  938.         addressList [i] = new blockAddress (3,4,1); i++;
  939.         addressList [i] = new blockAddress (3,5,1); i++;
  940.         addressList [i] = new blockAddress (4,6,1); i++;
  941.         addressList [i] = new blockAddress (5,7,1); i++;
  942.         addressList [i] = new blockAddress (6,8,1); i++;
  943.         addressList [i] = new blockAddress (6,9,1); i++;
  944.         addressList [i] = new blockAddress (7,10,1); i++;
  945.         addressList [i] = new blockAddress (1,3,0); i++;
  946.         addressList [i] = new blockAddress (2,4,0); i++;
  947.         addressList [i] = new blockAddress (3,5,0); i++;
  948.         addressList [i] = new blockAddress (3,6,0); i++;
  949.         addressList [i] = new blockAddress (4,7,0); i++;
  950.         addressList [i] = new blockAddress (4,8,0); i++;
  951.         addressList [i] = new blockAddress (5,9,0); i++;
  952.         addressList [i] = new blockAddress (6,10,0); i++;
  953.         addressList [i] = new blockAddress (7,11,0); i++;
  954.         addressList [i] = new blockAddress (1,3,-1); i++;
  955.         addressList [i] = new blockAddress (2,4,-1); i++;
  956.         addressList [i] = new blockAddress (2,5,-1); i++;
  957.         addressList [i] = new blockAddress (3,6,-1); i++;
  958.         addressList [i] = new blockAddress (4,7,-1); i++;
  959.         addressList [i] = new blockAddress (4,8,-1); i++;
  960.         addressList [i] = new blockAddress (5,9,-1); i++;
  961.         addressList [i] = new blockAddress (6,10,-1); i++;
  962.         addressList [i] = new blockAddress (6,11,-1); i++;
  963.         addressList [i] = new blockAddress (1,3,-2); i++;
  964.         addressList [i] = new blockAddress (1,4,-2); i++;
  965.         addressList [i] = new blockAddress (2,5,-2); i++;
  966.         addressList [i] = new blockAddress (3,6,-2); i++;
  967.         addressList [i] = new blockAddress (3,7,-2); i++;
  968.         addressList [i] = new blockAddress (4,8,-2); i++;
  969.         addressList [i] = new blockAddress (5,9,-2); i++;
  970.         addressList [i] = new blockAddress (5,10,-2); i++;
  971.         addressList [i] = new blockAddress (6,11,-2); i++;
  972.         addressList [i] = new blockAddress (1,3,-3); i++;
  973.         addressList [i] = new blockAddress (1,4,-3); i++;
  974.         addressList [i] = new blockAddress (2,5,-3); i++;
  975.         addressList [i] = new blockAddress (2,6,-3); i++;
  976.         addressList [i] = new blockAddress (3,7,-3); i++;
  977.         addressList [i] = new blockAddress (3,8,-3); i++;
  978.         addressList [i] = new blockAddress (4,9,-3); i++;
  979.         addressList [i] = new blockAddress (5,10,-3); i++;
  980.         addressList [i] = new blockAddress (5,11,-3); i++;
  981.         addressList [i] = new blockAddress (1,3,-4); i++;
  982.         addressList [i] = new blockAddress (1,4,-4); i++;
  983.         addressList [i] = new blockAddress (2,5,-4); i++;
  984.         addressList [i] = new blockAddress (2,6,-4); i++;
  985.         addressList [i] = new blockAddress (3,7,-4); i++;
  986.         addressList [i] = new blockAddress (3,8,-4); i++;
  987.         addressList [i] = new blockAddress (4,9,-4); i++;
  988.         addressList [i] = new blockAddress (5,10,-4); i++;
  989.         addressList [i] = new blockAddress (5,11,-4); i++;
  990.         addressList [i] = new blockAddress (1,3,-5); i++;
  991.         addressList [i] = new blockAddress (1,4,-5); i++;
  992.         addressList [i] = new blockAddress (2,5,-5); i++;
  993.         addressList [i] = new blockAddress (2,6,-5); i++;
  994.         addressList [i] = new blockAddress (3,7,-5); i++;
  995.         addressList [i] = new blockAddress (3,8,-5); i++;
  996.         addressList [i] = new blockAddress (4,9,-5); i++;
  997.         addressList [i] = new blockAddress (5,10,-5); i++;
  998.         addressList [i] = new blockAddress (5,11,-5); i++;
  999.         addressList [i] = new blockAddress (1,3,-6); i++;
  1000.         addressList [i] = new blockAddress (1,4,-6); i++;
  1001.         addressList [i] = new blockAddress (2,5,-6); i++;
  1002.         addressList [i] = new blockAddress (3,6,-6); i++;
  1003.         addressList [i] = new blockAddress (3,7,-6); i++;
  1004.         addressList [i] = new blockAddress (3,8,-6); i++;
  1005.         addressList [i] = new blockAddress (4,9,-6); i++;
  1006.         addressList [i] = new blockAddress (5,10,-6); i++;
  1007.         addressList [i] = new blockAddress (5,11,-6); i++;
  1008.         addressList [i] = new blockAddress (3,3,-7); i++;
  1009.         addressList [i] = new blockAddress (3,4,-7); i++;
  1010.         addressList [i] = new blockAddress (3,5,-7); i++;
  1011.         addressList [i] = new blockAddress (3,6,-7); i++;
  1012.         addressList [i] = new blockAddress (3,7,-7); i++;
  1013.         addressList [i] = new blockAddress (3,8,-7); i++;
  1014.         addressList [i] = new blockAddress (4,9,-7); i++;
  1015.         addressList [i] = new blockAddress (5,10,-7); i++;
  1016.         addressList [i] = new blockAddress (5,11,-7); i++;
  1017.     }
  1018. }
Advertisement
Add Comment
Please, Sign In to add comment