public void initializeNullifyPowerUp(string powerUpClicked) { isCalledNullify = false; isNullifyButtonClickedA = false; isNullifyButtonClickedB = false; List <PowerUpBase> playerPowerUps_1; List <PowerUpBase> playerPowerUps_2; playerPowerUps_1 = listPowerUp1.GetActivePowerUps(); playerPowerUps_2 = listPowerUp2.GetActivePowerUps(); if (turn == 1) { var nullifyPowerUp = playerPowerUps_2.FirstOrDefault(x => x.GetType().Equals("nullify")); var explodePowerUp = playerPowerUps_1.FirstOrDefault(x => x.GetType().Equals(powerUpClicked)); listPowerUp1.DisablePowerUp(explodePowerUp); listPowerUp2.DisablePowerUp(nullifyPowerUp); } else { var nullifyPowerUp = playerPowerUps_1.FirstOrDefault(x => x.GetType().Equals("nullify")); var explodePowerUp = playerPowerUps_2.FirstOrDefault(x => x.GetType().Equals(powerUpClicked)); listPowerUp2.DisablePowerUp(explodePowerUp); listPowerUp1.DisablePowerUp(nullifyPowerUp); } initializePowerUp(); }
public void UseShieldPowerUp(int index) { try { tileArray[blockedIndex].setUnblock(); } catch (Exception e) { } blockedIndex = index; explodeSelect.gameObject.SetActive(false); List <PowerUpBase> playerPowerUps; if (turn == 1) { playerPowerUps = listPowerUp1.GetActivePowerUps(); } else { playerPowerUps = listPowerUp2.GetActivePowerUps(); } var shieldPowerUp = playerPowerUps.FirstOrDefault(x => x.GetType().Equals("shield")); PowerUpTilesDto powerUpTilesDto = getPowerUpDto(index, -1, ScoreA: scoreValA, ScoreB: scoreValB, PreviousScoreA: preScoreValA, PreviousScoreB: preScoreValB); powerUpTilesDto = shieldPowerUp.Use(powerUpTilesDto); if (turn == 1) { listPowerUp1.DisablePowerUp(shieldPowerUp); } else { listPowerUp2.DisablePowerUp(shieldPowerUp); } usedPowerUpList.Append("shield|"); takeSnapShot(powerUpTilesDto); initializePowerUp(); turn *= -1; checkTurnPowerUp(); turnDisable(); checkWinCon(); shieldCancel = true; shieldPowerUpInUse = false; EventSystem.current.SetSelectedGameObject(null); }
public void UseExplodePowerUp(int indexToBeBlocked) { turn *= -1; explodeSelect.gameObject.SetActive(false); List <PowerUpBase> playerPowerUps; if (turn == 1) { playerPowerUps = listPowerUp1.GetActivePowerUps(); } else { playerPowerUps = listPowerUp2.GetActivePowerUps(); } var explodePowerUp = playerPowerUps.FirstOrDefault(x => x.GetType().Equals("explode")); PowerUpTilesDto powerUpTilesDto = getPowerUpDto(-1, indexToBeBlocked); powerUpTilesDto = explodePowerUp.Use(powerUpTilesDto); powerUpTilesDto.TileArray.CopyTo(tileArray, 0); if (turn == 1) { listPowerUp1.DisablePowerUp(explodePowerUp); } else { listPowerUp2.DisablePowerUp(explodePowerUp); } initializePowerUp(); //to disable used powerup enableTiles(); turn *= -1; turnDisable(); explodePowerUpInUse = false; EventSystem.current.SetSelectedGameObject(null); }