//シーン読み込み時に各種コンポーネントを取得するメソッド public void LoadComponents() { if (moveSceneManager.SceneName == "Title") { return; } wallSpawner = GameObject.FindGameObjectWithTag("WallSpawner").GetComponent <WallSpawner>(); mileageText = GameObject.Find(mileageTextName).GetComponent <Text>(); scoreText = GameObject.Find(scoreTextName).GetComponent <Text>(); highScoreText = GameObject.Find(highScoreTextName).GetComponent <Text>(); levelText = GameObject.Find(levelTextName).GetComponent <Text>(); //追加その2 gameOverCanvas = GameObject.Find(gameOverCanvasName).GetComponent <Canvas>(); retryButton = GameObject.Find(retryButtonName).GetComponent <Button>(); //追加その3 countdownText = GameObject.Find(countDownTextName).GetComponent <Text>(); //ボタンにクリック時の処理を登録 retryButton.onClick.AddListener(() => Retry()); //追加その4 coinSpawner = GameObject.FindGameObjectWithTag("CoinSpawner").GetComponent <CoinSpawner>(); }
void Start() { //get the width of the scrollable object SpriteRenderer[] srs = this.gameObject.GetComponentsInChildren <SpriteRenderer>(); bounds = new Bounds(this.transform.position, Vector3.zero); foreach (SpriteRenderer renderer in srs) { bounds.Encapsulate(renderer.bounds); } tileSizeX = bounds.size.x - screenWidth; //get the startposition Transform startTransform = GetComponent <Transform>(); startPosition.x = startTransform.position.x; startPosition.y = startTransform.position.y; //objCreationControl = true; isObjCreated = false; bgSpawner = FindObjectOfType <BGSpawner>(); obstacleSpawner = FindObjectOfType <ObstacleSpawner>(); coinSpawner = FindObjectOfType <CoinSpawner>(); gameEngine = FindObjectOfType <GameEngine>(); currentSpeedFactor = gameEngine.speedFactor; }
public IEnumerator spawns_coins_at_coin_spawn_rate() { // Arrange GameObject spawnManagerObject = new GameObject("SpawnManager"); SpawnManager spawnManager = spawnManagerObject.AddComponent <SpawnManager>(); CoinSpawner coinSpawner = spawnManagerObject.AddComponent <CoinSpawner>(); spawnManager.CoinSpawner = coinSpawner; spawnManager.CoinSpawner.SpawnRate = 0.30f; spawnManager.CoinSpawner.SpawnData.SpawnStartTime = 0.0f; spawnManager.CoinSpawner.SpawnData.PoolSize = 5; GameObject coinGameObject = new GameObject("Coin"); coinGameObject.transform.tag = "Coin"; coinGameObject.AddComponent <Obstacle>(); spawnManager.CoinSpawner.SpawnData.Prefabs = new GameObject[1]; spawnManager.CoinSpawner.SpawnData.Prefabs[0] = coinGameObject; // Act yield return(new WaitForSeconds(1.0f)); // Assert Assert.AreEqual(4, spawnManager.CoinSpawner.NumberSpawned); // Clean spawnManagerObject.SetActive(false); }
public CoinSpawner GetCoinSpawner() { if (_coinSpawner == null) { _coinSpawner = FindObjectOfType <CoinSpawner>(); } return(_coinSpawner); }
private CoinSpawner coinSpawner; // CoinSpawner for the platform void Awake() { // Get the Rigidbody2D component rb2d = GetComponent <Rigidbody2D>(); // Get the CoinSpawner component coinSpawner = GetComponent <CoinSpawner>(); }
void Awake() { SharedInstance = this; for (int i = 0; i < 36; i++) { coinClips.Add(Resources.Load("Audio/CoinSounds/Coins_Single (" + i + ")") as AudioClip); } }
public void CreateCoinSpawnsCoin() { GameObject coin = new GameObject(); GameObject coinSpawnerObject = new GameObject(); CoinSpawner coinSpawner = coinSpawnerObject.AddComponent <CoinSpawner>(); coinSpawner.coin = coin; Assert.IsNotNull(coinSpawner.CreateCoin()); }
// Start is called before the first frame update void Start() { endPanel.SetActive(false); Time.timeScale = 0; bulletSpawner = FindObjectOfType <BulletSpawner>(); coinSpawner = FindObjectOfType <CoinSpawner>(); currentGold = 0; currentTime = 0; goldText.text = "Gold: " + currentGold; }
public override void Init() { base.Init(); coinSpawner = GetComponentInChildren <CoinSpawner>(); base.Hp = Health; remainingHP = Health; healthBar.SetMaxHealth(Health); base.dmg = 10; base.gems = 3; }
void Start() { this.LevelCreator = this.GetComponent <LevelCreator>(); this.PayerController = this.GetComponent <PlayerSpawner>(); this.UserInputController = this.GetComponent <UserInputController>(); this.CoinSpawner = this.GetComponent <CoinSpawner>(); this.CoinController = this.GetComponent <CoinController>(); this.ZombieSpawner = this.GetComponent <ZombieSpawner>(); this.ZombieSpawner.LevelRoot = this.LevelRoot.transform; this.Camera = UnityEngine.Camera.main; this.StartGame(); }
void Awake () { // If not assigned we find a random one if (coinSpawner == null) coinSpawner = GameObject.FindObjectOfType<CoinSpawner>(); // If we have an spawner we subscribe if (coinSpawner != null) // Subscribe for spawn events coinSpawner.onSpawn += IncreaseCount; // Get the label reference if (label == null) label = GetComponent<Text>(); }
void Update() { if (_target == null) { // Haetaan viittaus scenessä olevaan CoinSpawneriin. CoinSpawner spawner = GameManager.Current.GetCoinSpawner(); // Haetaan CoinSpawnerilta lähimpänä oleva kolikko. _target = spawner.GetClosestCoin(transform.position); } if (_target != null) { // Liikutaan kohti kohdekolikkkoa, jos se löytyy (eli scenessä on ainakin // yksi kolikko). Mover.MoveForward(); Mover.RotateTowards(_target.transform.position); } }
void Start() { theCoinSpawner = FindObjectOfType <CoinSpawner>(); // Get width of platform platformWidths = new float[theObjectPools.Length]; // Declare widths of each platform: for (int i = 0; i < theObjectPools.Length; i++) { platformWidths[i] = theObjectPools[i].pooledObject.GetComponent <BoxCollider2D>().size.x; } //platformWidth = platform.GetComponent<BoxCollider2D>().size.x; minHeight = transform.position.y; maxHeight = maxHeightPoint.position.y; }
// Use this for initialization void Start() { //Debug.Log(Application.persistentDataPath); rb = GetComponent <Rigidbody>(); //start right dir = Vector3.right; startVec = gameObject.transform.position; gameScore = GameObject.Find(curGameLabel).GetComponent <Text>(); // Assign new string to "Text" field in that component //gameScore.text = PlayerSettingsScript.PlayerSettings.score.ToString(); GameSaveScr gss = GameObject.Find(GameSaveLabel).GetComponent <GameSaveScr>(); LocalScore = gss.score; gameScore.text = LocalScore.ToString(); CS_scriptRef = GameObject.Find(CoinSpawnerLabel).GetComponent <CoinSpawner>(); HS_TXT = GameObject.Find(HSLabel).GetComponent <Text>(); }
void Die() { audioManager.PlayDeathSFX(); isDead = true; myAnimator.SetBool("isDead", true); GetComponent <Collider2D>().enabled = false; Rigidbody2D myRigidBody = GetComponent <Rigidbody2D>(); myRigidBody.velocity = new Vector2(10f, 20f); CoinSpawner mySpawner = GetComponent <CoinSpawner>(); if (mySpawner) { mySpawner.Spawn(myRigidBody.position.x, myRigidBody.position.y, 1f); } }
private void BeginGame() { // Create a maze and initialize it. maze = Instantiate(mazePrefab) as Maze; maze.name = "Maze"; maze.Initialize(); // Initialize the coin spawner coinSpawner = Instantiate(coinSpawnerPrefab) as CoinSpawner; coinSpawner.name = "Spawned coins"; coinSpawner.Spawn(maze); // Initialize the enemy spawner enemySpawner = Instantiate(enemySpawnerPrefab) as EnemySpawner; enemySpawner.name = "Spawned enemies"; enemySpawner.setTarget(GameObject.FindGameObjectWithTag("Player").transform); enemySpawner.setPlayerController(playercontroller); enemySpawner.Spawn(maze); playercontroller.setCoinList(coinSpawner.spawnedCoins.Count); }
void Awake() { // If not assigned we find a random one if (coinSpawner == null) { coinSpawner = GameObject.FindObjectOfType <CoinSpawner>(); } // If we have an spawner we subscribe if (coinSpawner != null) { // Subscribe for spawn events coinSpawner.onSpawn += IncreaseCount; } // Get the label reference if (label == null) { label = GetComponent <Text>(); } }
void Awake() { // Save the original camera position cameraOriginalPosition = Camera.main.transform.position; // Make a copy of this for internal tracking internalShakeLength = shakeLength; // Find our coin manager coinManager = GameObject.FindWithTag("CoinManager").GetComponent <CoinManager>(); // Find our play field playFieldArea = GameObject.FindWithTag("CoinsPlayField").GetComponent <Transform>(); // Find our coin spawner coinSpawner = GameObject.FindWithTag("CoinSpawnerArea").GetComponent <CoinSpawner>(); // Find the collectableManager collectableManager = GameObject.FindWithTag("CollectableManager").GetComponent <CollectableManager>(); // Find the pusher pushBar = GameObject.FindWithTag("PushBar").GetComponent <Pusher>(); }
// Use this for initialization void Awake () { instance = this; }
private void Awake() { coinSpawnerInstance = this; }
// Update is called once per frame void Update() { /* GameObject menuGO = GameObject.Find("MainMenuSet(Clone)"); * if (menuGO) * { * MainMenuSet menuNew = menuGO.GetComponent<MainMenuSet>(); * if (menuNew && menuNew.gameRunNow == true) * { * foreach (GameObject _obj in Counters) * { * * _obj.SetActive(true); * } * } * }*/ ammountCoins = GameObject.FindGameObjectsWithTag("coin"); Player1 Player = Levels.CurrentLevel.PlayerGameObject.GetComponent <Player1>(); if (Player && (Player.newPlayerHP + PlayerData.ArmorUpgradeLevel <= 0)) { StartCoroutine(LoseSequence()); Debug.Log("KillPlayer Activated"); } /*if (Levels.CurrentLevel && Levels.CurrentLevel.PlayerGameObject) * { * Player1 player = Levels.CurrentLevel.PlayerGameObject.GetComponent<Player1>(); * * if (player && player.newPlayerHP <= 0) * { * StartCoroutine(CloseLevelAndFade()); * Debug.Log("KillPlayer Activated"); * } * } */ GameObject coinSpawnerGO = GameObject.Find("CoinSpawner"); if (coinSpawnerGO) { CoinSpawner coinSpawner = coinSpawnerGO.GetComponent <CoinSpawner>(); if (coinSpawner) { Invoke("CollectCoins", 1); //addCoinsNow = true; } } if (Levels.CurrentLevel && Levels.CurrentLevel.CurrentEnemy) { Bandit bandit = Levels.CurrentLevel.CurrentEnemy.GetComponent <Bandit>(); if (bandit && bandit.health <= 0 && updateScoreNow == true) { //newScore = newScore + 1; //scoreValue.text = "Score " + newScore; loadLevelNow = true; updateScoreNow = false; Shop(); } } if (PlayerData.BulletSpeedDecreaseLevel == 0) { bulletDecreasedValue.text = "Bullet Speed Reduction: " + PlayerData.BulletSpeedDecreaseLevel; } if (PlayerData.ArmorUpgradeLevel == 0) { armorBuffValue.text = "Armor Buff: " + PlayerData.ArmorUpgradeLevel; } if (PlayerData.CoinBoostLevel == 0) { coinBoostValue.text = "Coins Boost: " + PlayerData.CoinBoostLevel; } }
// Use this for initialization void Awake() { instance = this; }
private void Awake() { instance = this; }
private void Start() { coinSpawner = FindObjectOfType <CoinSpawner>(); }