// Start is called before the first frame update void Start() { rightSideCurrent = -1; leftSideCurrent = -1; playersResources = GetComponent <CollectingResources>(); allowedToFire = true; }
private void Awake() { GameObject hs = GameObject.Find("Health Slider"); GameObject ht = GameObject.Find("Health Count"); GameObject ftb = GameObject.Find("FadeToBlack Canvas"); playerSpawnPoint = GameObject.Find("PlayerSpawnPoint").transform; playersResources = GetComponent <CollectingResources>(); fadeToBlackImage = ftb.GetComponentInChildren <Image>(); slider = hs.GetComponent <Slider>(); healthCount = ht.GetComponent <Text>(); cam = GameObject.Find("Main Camera").transform; }
private void Start() { islandsStashOfGold = 1000f; playersCollection = FindObjectOfType <CollectingResources>(); gameBrain = GameObject.Find("GameBrain").GetComponentInChildren <PlayerSpawnIn>(); pS = GetComponentInChildren <ParticleSystem>(); pS.Stop(); digging = GetComponentInParent <DiggingUpTresure>(); audioSource = GetComponent <AudioSource>(); }
private void Update() { if (isOnIsland) { if (Input.GetKey(KeyCode.Space)) { playersCollection = FindObjectOfType <CollectingResources>(); if (islandsStashOfGold > 0 && playersCollection.playersGold <= playersCollection.playersMaxGold) { islandsStashOfGold -= 1 * speedOfLooting * Time.deltaTime; playersCollection.playersGold += 1 * speedOfLooting * Time.deltaTime; digging.treasureChest.transform.position += new Vector3(0, 0.001f, 0); float distance = digging.treasureChest.transform.position.y - digging.treasureChestStartingPos.y; if (!audioSource.isPlaying) { audioSource.PlayOneShot(digginSounds[Random.Range(0, digginSounds.Length)], 0.3f); } if (islandsStashOfGold <= 0) { if (!playChestOpen) { audioSource.PlayOneShot(chestOpen, 0.5f); audioSource.PlayOneShot(goldCoins, 0.25f); playChestOpen = true; playersCollection.playerscannonBalls += 10; FindObjectOfType <PlayersHealth>().currentHealth += 25f; } pS.Play(); Invoke("StopPlayingPS", 5); digging.treasureChest.GetComponent <MeshRenderer>().enabled = false; digging.openTreasureChest.GetComponent <MeshRenderer>().enabled = true; digging.openLid.GetComponent <MeshRenderer>().enabled = true; displayWarning = true; } if (gameBrain.timesSpawned < 2) { if (!displayHoldSpace) { audioSource.PlayOneShot(squark, 0.5f); displayHoldSpace = true; } gameBrain.instructionsText.text = "HOLD SPACE\n\nNow we will start to steal ol' Sealeg's Gold\n\n" + "Legend states that he will return from the dead to hunt down the Pirate that stole his gold!\n\n" + "All of 'SeaLegs' chests are located on the Map, we are the BLUE Marker."; } } } } if (displayWarning) { if (gameBrain.timesSpawned < 2) { audioSource.PlayOneShot(squark, 0.5f); gameBrain.instructionsText.text = "WARNING!\n\nThe more of his gold on your ship the more of his" + " undead fleet he will send after you to claim it back\n\nThe skull is your Reputation. " + "The higher it is the more ships will be after our stolen gold\n\n" + "Sail EAST, I see an Enemy ship!"; displayWarning = false; } } }
// Start is called before the first frame update void Start() { bossHealth = GetComponent <Health>(); playersResources = FindObjectOfType <CollectingResources>(); }
private void Awake() { playersResources = FindObjectOfType <CollectingResources>(); }
// Update is called once per frame void Update() { playersResources = FindObjectOfType <CollectingResources>(); if (playersResources.playersNotoriety >= playersResources.playersMaxNotoriety / 100 * 25 && playersResources.playersNotoriety <= playersResources.playersMaxNotoriety / 100 * 49) { if (releaseTheEnemies == false) { for (int i = 0; i < 2; i++) { GameObject newEnemy = Instantiate(EnemyLVL1, spawnPoints[i].position, Quaternion.identity); EnemyChase enemyChase = newEnemy.GetComponent <EnemyChase>(); enemyChase.isPatrolling = false; Transform player = GameObject.FindGameObjectWithTag("Player").transform; enemyChase.shipTarget = player; } releaseTheEnemies = true; } } if (playersResources.playersNotoriety >= playersResources.playersMaxNotoriety / 100 * 50 && playersResources.playersNotoriety <= playersResources.playersMaxNotoriety / 100 * 74) { if (releaseTheEnemiesAgain == false) { for (int i = 0; i < 4; i++) { GameObject newEnemy = Instantiate(EnemyLVL2, spawnPoints[i].position, Quaternion.identity); EnemyChase enemyChase = newEnemy.GetComponent <EnemyChase>(); enemyChase.isPatrolling = false; Transform player = GameObject.FindGameObjectWithTag("Player").transform; enemyChase.shipTarget = player; } releaseTheEnemiesAgain = true; } } if (playersResources.playersNotoriety >= playersResources.playersMaxNotoriety / 100 * 75 && playersResources.playersNotoriety <= playersResources.playersMaxNotoriety / 100 * 99) { if (releaseTheEnemiesAgainAgain == false) { for (int i = 0; i < 4; i++) { GameObject newEnemy = Instantiate(EnemyLVL3, spawnPoints[i].position, Quaternion.identity); EnemyChase enemyChase = newEnemy.GetComponent <EnemyChase>(); enemyChase.isPatrolling = false; Transform player = GameObject.FindGameObjectWithTag("Player").transform; enemyChase.shipTarget = player; } releaseTheEnemiesAgainAgain = true; } } if (playersResources.playersNotoriety >= playersResources.playersMaxNotoriety) { if (releaseTheEnemiesAgainAgainAgain == false) { for (int i = 0; i < 3; i++) { GameObject newEnemy = Instantiate(EnemyLVL4, spawnPoints[i].position, Quaternion.identity); EnemyChase enemyChase = newEnemy.GetComponent <EnemyChase>(); enemyChase.isPatrolling = false; Transform player = GameObject.FindGameObjectWithTag("Player").transform; enemyChase.shipTarget = player; } for (int i = 0; i < 1; i++) { GameObject newEnemy = Instantiate(Boss, spawnPoints[i].position, spawnPoints[i].rotation); EnemyChase enemyChase = newEnemy.GetComponent <EnemyChase>(); enemyChase.isPatrolling = false; Transform player = GameObject.FindGameObjectWithTag("Player").transform; enemyChase.shipTarget = player; floor.GetComponent <MeshRenderer>().enabled = false; audioSource.clip = bossSong; audioSource.Play(); } releaseTheEnemiesAgainAgainAgain = true; } } }
// Start is called before the first frame update void Start() { playersResources = FindObjectOfType <CollectingResources>(); releaseTheEnemies = false; audioSource = GetComponent <AudioSource>(); }