private void Awake() { instance = this; towersNotSelected = new TowerScript[(Towers.Length - towersSelected.Length)]; if (SaveSystem.testExist()) { loadData(); } else { music = true; vibrate = true; notification = true; soundEffect = true; CurrentLevel = 0; FirstTime = true; winCount = 0; loseCount = 0; damageDone = 0; gamePlayed = 0; playerPicture = (byte)UnityEngine.Random.Range(1, Pictures.Length); playerName = "player(" + UnityEngine.Random.Range(1, 255) + ")"; GunSelected = guns[0]; setPlayer(players[0]); remplirSelectedTower(); players[0].level = 1; players[0].locked = false; for (int i = 1; i < players.Length; i++) { players[i].level = 1; players[i].locked = true; } guns[0].level = 1; guns[0].locked = false; for (int i = 1; i < guns.Length; i++) { guns[i].locked = true; guns[i].level = 1; } for (int i = 0; i < Towers.Length; i++) { Towers[i].level = 1; if (i > 5) { Towers[i].locked = true; } else { Towers[i].locked = false; } } diamond = 0; TowersNumber = 9; XP = 0; SaveSystem.SavePlayer(); } FillTowersNotSelected(); //Debug.Log(getGun().name); }
// Start is called before the first frame update void Start() { Debug.Log("Player start"); main = GameObject.Find("Main"); sfx = GameObject.Find("SoundManager"); rb = GetComponent <Rigidbody>(); player = GetComponent <Transform>(); guns = player.GetComponentInChildren <GunsScript>(); Debug.Log(guns); }
void Start() { timer = 80; switch (GameManager.instance.winCount) { case 0: enemy = GameManager.instance.players[0]; enemyGun = GameManager.instance.guns[0]; break; default: enemy = GameManager.instance.players[Random.Range(0, 4)]; enemyGun = GameManager.instance.guns[Random.Range(0, 5)]; break; } //enemy = GameManager.instance.players[Random.Range(0, 4)]; //enemyGun = GameManager.instance.guns[Random.Range(0, 5)]; tm = StartCoroutine(timing()); player = GameManager.instance.getPlayer(); playerGun = GameManager.instance.getGun(); //Debug.Log(player.name); setMagic(); towersSelected = GameManager.instance.GetSelectedTowers(); ChangeSprites(); instantiatePrefabs(); playerCoinsTxt.text = playerCoins.ToString(); //enemyCoinsTxt.text = enemyCoins.ToString(); }
public void setGun(GunsScript gun) { GunSelected = gun; }
private void loadData() { PlayerData data = SaveSystem.loadPlayerData(); music = data.music; vibrate = data.vibrate; notification = data.notification; soundEffect = data.soundEffect; CurrentLevel = data.currentLevel; winCount = data.winCount; loseCount = data.loseCount; damageDone = data.damageDone; gamePlayed = data.gamePlayed; playerPicture = data.playerPicture; playerName = data.PlayerName; diamond = data.diamonds; for (int i = 0; i < players.Length; i++) { if (players[i].name == data.SelectedPlayer) { playerSelected = players[i]; } players[i].locked = data.lockPlayersData[i]; players[i].level = data.playersLevel[i]; } for (int i = 0; i < guns.Length; i++) { if (guns[i].name == data.selectedGun) { GunSelected = guns[i]; } guns[i].locked = data.gunsLocked[i]; guns[i].level = data.gunsLevel[i]; } int k = 0; for (int i = 0; i < TowersNumber; i++) { for (int j = 0; j < 6; j++) { if (Towers[i].name == data.SelectedTowers[j]) { towersSelected[k] = Towers[i]; k++; break; } } Towers[i].locked = data.lockTowersData[i]; Towers[i].level = data.towersLevel[i]; } if (Towers.Length > TowersNumber) { for (int i = TowersNumber; i < Towers.Length; i++) { Towers[i].locked = true; Towers[i].level = 1; } TowersNumber = (byte)Towers.Length; } //Debug.Log(TowersNumber); XP = data.XP; if (CurrentLevel != (int)(0.1f * Mathf.Sqrt(XP))) { testLevelUp = true; // if( SceneManager.GetActiveScene().name=="") } CurrentLevel = (int)(0.1f * Mathf.Sqrt(XP)); }