void createGrid() { for (int x = 0; x < gridY; x++) { for (int y = 0; y < gridX; y++) { // instantite blocks here GameObject soundBlock = Instantiate(prefabBlock, Vector3.zero, prefabBlock.transform.rotation) as GameObject; soundBlock.transform.parent = transform; soundBlock.transform.localPosition = new Vector3(x + (offserX * x), y + (offsetY * y), offsetZ); soundBlock.name = ("sB_x" + x as string + "_y" + y as string + "_ID" + blockID as string + "_clip_" + audioFiles[blockID].name); // work on each block parameters through component cast blockController tempBlockController = soundBlock.GetComponent <blockController>(); AudioSource tempAS = soundBlock.GetComponent <AudioSource>(); tempBlockController.blockText.text = splitString(audioFiles[blockID].name, maxLineChars); tempBlockController.blockID = blockID; tempBlockController.audioToPlay = audioFiles[blockID]; tempAS.clip = (AudioClip)audioFiles[blockID]; // remember to increment blockID blockID++; } } }
void UndoMove(MoveInf move) { GameObject block; if (move.isChanged) { GameObject preBlock = relayBoard.transform.Find(move.blockName).gameObject; Vector3 iniPos = preBlock.GetComponent <blockController>().initBlockPos; GameObject blockPrefabs = preBlock.GetComponent <blockController>().changeBlock; block = GameObject.Instantiate(blockPrefabs, iniPos, Quaternion.identity, preBlock.transform.parent); GameObject.Destroy(preBlock); block.GetComponent <blockController>().isChanged = false; string partten = @"\s.*"; MatchCollection match = Regex.Matches(preBlock.name, partten); string order = null; if (match.Count > 0) { order = match[0].ToString(); } block.name = blockPrefabs.name + order; } else { block = relayBoard.transform.Find(move.blockName).gameObject; } blockController controller = block.GetComponent <blockController>(); if (move.endBoard == manager.JigsawBoard) { manager.AddPointToList(block, manager.JigsawBoard); controller.isAtJigsawBoard = false; } else { controller.isAtJigsawBoard = true; } block.transform.position = move.sourPos; block.transform.eulerAngles = move.sourRoa; if (move.sourBoard == manager.JigsawBoard) { manager.DeletePointFromList(block, manager.JigsawBoard); controller.isAtJigsawBoard = true; } else { controller.isAtJigsawBoard = false; } }
public void generate_blocks() { if (size_x % 2 == 0) { size_x++; } /**make x to odd number**/ //GameObject block_array[size_x][size_y]; floor_array = new blockController[size_x][]; for (int i = 0; i < size_x; i++) { floor_array [i] = new blockController[size_y]; } //presetMap init_map(); //generate block by array int middle_line = size_x / 2 + 1; for (int line = 0; line < size_x; line++) { /**this is the counter for the mid respawnning pool**/ int counter_mid_respawning_pool = number_of_spawning_point / 2 + 1; int counter_diamond = number_of_diamond; for (int roll = 0; roll < size_y; roll++) { if (block_array [line] [roll] == 0) { int r = Random.Range(0, 101); blockController b; if (r < 10) { b = ((GameObject)Instantiate(block, new Vector3(line * block_size, -1, roll * block_size), Quaternion.identity)).GetComponent <blockController> (); } else if (r < 20) { b = ((GameObject)Instantiate(block2, new Vector3(line * block_size, -1, roll * block_size), Quaternion.identity)).GetComponent <blockController> (); } else { b = ((GameObject)Instantiate(block3, new Vector3(line * block_size, -1, roll * block_size), Quaternion.identity)).GetComponent <blockController> (); } b.x = line; b.y = roll; // print ("init map x " + line + " y " + roll); floor_array [line] [roll] = b; b.type = block_array [line] [roll]; b.transform.parent = this.transform; } else if (block_array [line] [roll] == 1) { blockController b = ((GameObject)Instantiate(function_block, new Vector3(line * block_size, -1, roll * block_size), Quaternion.identity)).GetComponent <blockController> (); b.x = line; b.y = roll; floor_array [line] [roll] = b; b.transform.parent = this.transform; b.type = block_array [line] [roll]; } else if (block_array [line] [roll] == 2) { blockController b = ((GameObject)Instantiate(trap_block, new Vector3(line * block_size, -1, roll * block_size), Quaternion.identity)).GetComponent <blockController> (); b.x = line; b.y = roll; floor_array [line] [roll] = b; b.transform.parent = this.transform; b.type = block_array [line] [roll]; } else if (block_array [line] [roll] == 3) { blockController b = ((GameObject)Instantiate(no_pass_block, new Vector3(line * block_size, -1, roll * block_size), Quaternion.identity)).GetComponent <blockController> (); b.x = line; b.y = roll; floor_array [line] [roll] = b; b.transform.parent = this.transform; b.type = block_array [line] [roll]; } else if (block_array [line] [roll] == 4) { blockController b; if (line < middle_line) { b = ((GameObject)Instantiate(respwaning_block, new Vector3(line * block_size, -1, roll * block_size), Quaternion.Euler(0f, -90f, 0f))).GetComponent <blockController> (); } else { b = ((GameObject)Instantiate(respwaning_block, new Vector3(line * block_size, -1, roll * block_size), Quaternion.Euler(0f, 90f, 0f))).GetComponent <blockController> (); } b.x = line; b.y = roll; floor_array [line] [roll] = b; b.type = block_array [line] [roll]; if (map == 1 || map == 2) { main_respwaning_pool[1] = floor_array[0][roll]; main_respwaning_pool[0] = floor_array[size_x - 1][roll]; } else { if (line == 0 && counter_mid_respawning_pool == 1) { /**if the left side(true)**/ main_respwaning_pool[1] = floor_array[line][roll]; } else if ( line == size_x - 1 && counter_mid_respawning_pool == 1) { main_respwaning_pool[0] = floor_array[line][roll]; } } b.transform.parent = this.transform; counter_mid_respawning_pool--; } else if (block_array [line] [roll] == 5) { blockController b = ((GameObject)Instantiate(diamond_block, new Vector3(line * block_size, -1, roll * block_size), Quaternion.identity)).GetComponent <blockController> (); b.x = line; b.y = roll; floor_array [line] [roll] = b; diamond_array [counter_diamond - 1] = floor_array [line] [roll]; b.type = block_array [line] [roll]; counter_diamond--; b.transform.parent = this.transform; } else if (block_array [line] [roll] == 6) { blockController b = ((GameObject)Instantiate(wall, new Vector3(line * block_size, -1, roll * block_size), Quaternion.identity)).GetComponent <blockController> (); b.x = line; b.y = roll; floor_array [line] [roll] = b; b.transform.parent = this.transform; b.type = block_array [line] [roll]; } } } /**build edge block***/ for (int line = -1; line < size_x + 1; line++) { GameObject b = (GameObject)Instantiate(edge_block, new Vector3(line * block_size, -1, -1 * block_size), Quaternion.identity); b.transform.parent = this.transform; b.tag = "edge"; b = (GameObject)Instantiate(edge_block, new Vector3(line * block_size, -1, (size_y) * block_size), Quaternion.identity); b.transform.parent = this.transform; b.tag = "edge"; } for (int roll = 0; roll < size_y; roll++) { GameObject b = (GameObject)Instantiate(edge_block, new Vector3(-1 * block_size, -1, roll * block_size), Quaternion.identity); b.transform.parent = this.transform; b.tag = "edge"; b = (GameObject)Instantiate(edge_block, new Vector3((size_x) * block_size, -1, roll * block_size), Quaternion.identity); b.transform.parent = this.transform; b.tag = "edge"; } /**build env**/ for (int line = 0 - 5; line < size_x + 5 + 1; line++) { for (int roll = 0 - 7; roll < size_y + 7; roll++) { if (!(roll > -2 && roll < size_y + 1 && line > -2 && line < size_x + 1)) { int k = Random.Range(0, 101); GameObject b; if (k < 10) { b = (GameObject)Instantiate(env3, new Vector3(line * block_size, -1, roll * block_size), Quaternion.identity); } else if (k < 10) { b = (GameObject)Instantiate(env2, new Vector3(line * block_size, -1, roll * block_size), Quaternion.identity); } else { b = (GameObject)Instantiate(env1, new Vector3(line * block_size, -1, roll * block_size), Quaternion.identity); } b.transform.parent = this.transform; } } } }
// Update is called once per frame void Update() { blockController[] Controllers = pickupBoard.GetComponentsInChildren <blockController>(); foreach (var controller in Controllers) { if (controller.type == blockType.mouse) { mouseController = controller; } } switch (teachState) { case TeachState.NotTeaching: if (Input.anyKeyDown && isStartShowEnd) { if (lineInd != lines.Length) { ShowLines(lines[lineInd++]); } else { isEnd = true; panel.SetActive(false); } } break; case TeachState.TeachingCatScareMouse: if (mouseController.isChanged) { teachState = TeachState.NotTeaching; panel.SetActive(true); if (lineInd != lines.Length) { ShowLines(lines[lineInd++]); } else { isEnd = true; panel.SetActive(false); } } break; case TeachState.TeachingMouseAvoidCat: if (mouseController.isAtJigsawBoard) { teachState = TeachState.NotTeaching; panel.SetActive(true); if (lineInd != lines.Length) { ShowLines(lines[lineInd++]); } else { isEnd = true; panel.SetActive(false); } } break; default: break; } }
// Use this for initialization protected virtual void Awake() { mycustomNetworkManager = GameObject.Find("networkController").GetComponent<customNetworkManager>(); currentHealth = startingHealth; currentMana = startingMana; playerArrow = transform.Find("arrow parent").gameObject; myblockController = transform.Find("block").GetComponent<blockController>(); myUltiCamera = GameObject.FindGameObjectWithTag("ultimateCamera").GetComponent<ultimateCameraControllerNetwork>(); mymelee = transform.Find("melee trigger box").GetComponent<meleeNetwork>(); myaudio = GetComponent<AudioSource>(); rb = GetComponent<Rigidbody>(); isJumping = false; hasEnterGameOver = false; isAttack = false; isCastMode = false; playBlockAnimation = false; isLose = false; canMove = true; isWalking = false; isInResult = false; canCastUltimate = true; isPSActive = false; isPSArmor = false; isPSOTU = false; armorUICD = false; isNotEnoughMana = false; isKnockBack = true; isEndOfRangeAttack = true; isFinishCombo = true; isStun = false; isCrouch = false; canCombo = false; shouldWaitAnimationFinish = false; isBlocking = false; isDoubleTap = false; canRangeAttack = true; canMeleeAttack = true; speed = normalSpeed; jumpSpeed = lowJumpSpeed; // comboCount = 0; highestComboAchieve = 0; blockCount = maxBlockCount; stunRate = 1;//default spellCoolDownRate = 1;//how fast the spell cooldown, 1 is normal rate spellCoolDownRateNetwork = spellCoolDownRate; myserverLogic = GameObject.Find("server logic(Clone)").GetComponent<serverLogic>(); coolDownRangeTimer = 0; myDamageMultipler = 1; coolDownMeleeTimer = new float[2]; coolDownMeleeTimer[0] = coolDownMeleeAttackRate; isMeleeComboCount = new bool[3]; for (int i = 0; i < isMeleeComboCount.Length; i++) isMeleeComboCount[i] = false;//for melee combo animation myblockTimer = coolDownBlockTimer; stunTimer = coolDownStunRate; //comboText = combo.GetComponent<Text>(); //comboAnimation = combo.GetComponent<Animation>(); spellComboArmor = new float[3]; spellComboActive = new float[3]; spellComboPassive = new float[3]; for (int i = 0; i < spellComboArmor.Length; i++) { spellComboArmor[i] = 0; spellComboActive[i] = 0; spellComboPassive[i] = 0; } canCastSpell = new bool[3]; for (int i = 0; i < canCastSpell.Length; i++) canCastSpell[i] = true; }
//networking stuff // protected NetworkInstanceId mynetworkID; // Use this for initialization protected virtual void Awake() { // Setup player attributes currentHealth = startingHealth; currentMana = startingMana; myblockController = transform.Find("block").GetComponent<blockController>(); myUltiCamera = GameObject.FindGameObjectWithTag("ultimateCamera").GetComponent<ultimateCameraController>(); mymelee = transform.Find ("melee trigger box").GetComponent<melee> (); myaudio = GetComponent<AudioSource>(); rb = GetComponent<Rigidbody> (); isInUltimate = false; isJumping = false; isAttack = false; isCastMode = false; playBlockAnimation = false; isLose = false; canMove = true; isWalking = false; isPause = false; canCastUltimate = true; isGodMode = false; isUnlimitedSpell = false; isNotEnoughMana = false; isKnockBack = true; isEndOfRangeAttack = true; isFinishCombo = true; isUseHealthItem = false; isUseManaItem = false; isStun = false; isCrouch = false; canCombo = false; shouldWaitAnimationFinish = false; isBlocking = false; isDoubleTap = false; canRangeAttack = true; canMeleeAttack = true; speed = normalSpeed; jumpSpeed = lowJumpSpeed; comboCount = 0; myDamageMultipler = 1.0f;//default highestComboAchieve = 0; blockCount = maxBlockCount; stunRate = 1;//default spellCoolDownRate = 1;//how fast the spell cooldown, 1 is normal rate CurrentChargingBar = Mathf.Clamp01 (CurrentChargingBar); myGameController = GameObject.Find ("gameManager").GetComponent<gameController> (); //coolDownRangeTimer = coolDownRangeAttackRate; coolDownRangeTimer = 0; coolDownMeleeTimer = new float[2]; coolDownMeleeTimer[0] = coolDownMeleeAttackRate; isMeleeComboCount = new bool[3]; for (int i = 0; i < isMeleeComboCount.Length; i++) isMeleeComboCount[i] = false;//for melee combo animation myblockTimer = coolDownBlockTimer; stunTimer = coolDownStunRate; comboText = combo.GetComponent<Text>(); comboAnimation = combo.GetComponent<Animation>(); spellComboArmor = new float[3]; spellComboActive = new float[3]; spellComboPassive = new float[3]; for (int i = 0; i < spellComboArmor.Length; i++) { spellComboArmor[i] = 0; spellComboActive[i] = 0; spellComboPassive[i] = 0; } canCastSpell = new bool[3]; for (int i = 0; i < canCastSpell.Length; i++) canCastSpell[i] = true; StartCoroutine (regenMana (1.0f)); StartCoroutine(regenBlockCount(5.0f)); }