Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    private void Die()
    {
        GameObject spawnerObj = GameObject.FindWithTag("EnemySpawner");

        if (spawnerObj != null)
        {
            SpawnEnemies spawner = spawnerObj.GetComponent <SpawnEnemies>();
            int          ind     = spawner.enemies.IndexOf(gameObject);

            if (ind >= 0)
            {
                spawner.enemies.Remove(gameObject);

                StartCoroutine(spawner.Spawn());

                Debug.Log(" enemy count: ");
                Debug.Log(spawner.enemies.Count);
            }
        }



        Destroy(UIobj);

        Destroy(gameObject);
    }
Ejemplo n.º 2
0
 private void Start()
 {
     spawner = FindObjectOfType <SpawnEnemies>();
     Instantiate(enemy, transform.position, transform.rotation);
     enemy.health = Mathf.RoundToInt(spawner.enemyHealth);
     enemy.damage = Mathf.RoundToInt(spawner.enemyDamage);
 }
Ejemplo n.º 3
0
 // Update is called once per frame
 void Update()
 {
     if (GameObject.FindGameObjectWithTag("Player") != null)
     {
         Player = GameObject.FindGameObjectWithTag("Player").transform.position;
     }
     else
     {
         Player = new Vector3(0, 0, 9);
     }
     if (checkDead())
     {
         Points          p      = (Points)GameObject.FindObjectOfType(typeof(Points));                   //get the score object
         PlayerBehaviour player = (PlayerBehaviour)GameObject.FindObjectOfType(typeof(PlayerBehaviour)); //get the player
         player.killedThisWave++;                                                                        //keep count of the wave
         SpawnEnemies se = (SpawnEnemies)GameObject.FindObjectOfType(typeof(SpawnEnemies));
         p.points += 10 * se.wave;                                                                       //update the points
         if (Random.Range(0f, 1f) <= dropChance)                                                         //check whether it should drop
         {
             drop = (GameObject)Instantiate(Resources.Load("pre_healthPickup"));
             drop.transform.position = transform.position;
         }
         if (player.killedThisWave >= se.totalThisWave)                                                      //if wave is finished, then advance
         {
             se.advanceWave();
             player.killedThisWave = 0;
         }
         Object.Destroy(this.gameObject);
     }
     doMove();
 }
Ejemplo n.º 4
0
    void Start()
    {
        enemy = Resources.Load <GameObject>("Prefabs/Invader1");

        _spawnEnemies = new SpawnEnemies(enemy, _rowAmount, _enemiesInRow, _rowLocationX, _rowLocationY, _nextRowLocationX, _nextEnemyPosY);
        _enemy        = new Enemy();
    }
Ejemplo n.º 5
0
 void OnDestroy()
 {
     if (instance == this)
     {
         instance = null;
     }
 }
Ejemplo n.º 6
0
 void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.layer == LayerMask.NameToLayer(layerToHit))
     {
         if (layerToHit.Equals("Enemy"))
         {
             Destroy(col.gameObject);
             Destroy(gameObject);
             AudioSource.PlayClipAtPoint(splat, transform.position);
             SpawnEnemies controller = GameObject.FindGameObjectWithTag("GameController").GetComponent <SpawnEnemies>();
             controller.setScore(1);
         }
         else
         {
             InputController hand = col.gameObject.GetComponent <InputController>();
             if (hand.heldObject == null)
             {
                 hand.catchArrow(gameObject);
                 moveSpeed  = 0;
                 layerToHit = "Enemy";
                 this.gameObject.GetComponent <Collider>().enabled = false;
             }
         }
     }
     else if (col.gameObject.layer != LayerMask.NameToLayer("Missile") && col.gameObject.layer != LayerMask.NameToLayer("Hand") &&
              col.gameObject.layer != LayerMask.NameToLayer("Body"))
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 7
0
    // Start is called before the first frame update
    void Start()
    {
        float        screenAspect = (float)Screen.width / Screen.height;
        float        cameraHeight = Camera.main.orthographicSize;
        float        cameraWidth  = cameraHeight * screenAspect;
        SpawnEnemies spawnScript  = GetComponent <SpawnEnemies>();
        float        spawnerY     = cameraHeight * 1.1f; // We offset by an additional 10% so that the enemies spawn out of bounds
        float        spawnerX     = cameraWidth * 1.1f;

        switch (spawnerDirection)
        {
        case Direction.Up:
            spawnScript.transform.position = new Vector2(0, spawnerY);
            spawnScript.xVariance          = cameraWidth;
            break;

        case Direction.Down:
            spawnScript.transform.position = new Vector2(0, -spawnerY);
            spawnScript.xVariance          = cameraWidth;
            break;

        case Direction.Left:
            spawnScript.transform.position = new Vector2(-spawnerX, 0);
            spawnScript.yVariance          = cameraHeight;
            break;

        case Direction.Right:
            spawnScript.transform.position = new Vector2(spawnerX, 0);
            spawnScript.yVariance          = cameraHeight;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
Ejemplo n.º 8
0
    void Start()
    {
        rooms        = new int[7, 7];
        spawnEnemies = manager.GetComponent <SpawnEnemies>();

        dungeonManager = GameObject.FindGameObjectWithTag("DungeonManager").GetComponent <DungeonManager>();
        switch (dungeonManager.dungeonName)
        {
        case "Plains":
            tilePrefab = Resources.Load <GameObject>("Tiles/Tile2").transform;
            break;

        case "Caves":
            tilePrefab = Resources.Load <GameObject>("Tiles/Tile1").transform;
            break;

        case "Chasm":
            tilePrefab = Resources.Load <GameObject>("Tiles/Tile3").transform;
            break;
        }

        generateFloor();
        //Debug.Log(numRooms);

        UpdateConnections();
    }
Ejemplo n.º 9
0
 // Use this for initialization
 void Start()
 {
     gameManager  = GameObject.Find("GameManager");
     spawnEnemies = gameManager.GetComponent <SpawnEnemies>();
     spawnPoints  = spawnEnemies.GetSpawnPoints();
     InvokeRepeating("Teleport", 2f, 2.5f);
 }
    private HealthController healthControllerClassReference;            //Referencia a la clase "HealthController".

    void Awake()
    {
        UXControllerClassReference     = GameObject.FindWithTag("GameController").GetComponent <UXController> ();
        spawnEnemiesClassReference     = GameObject.FindWithTag("GameController").GetComponent <SpawnEnemies> ();
        nextSceneClass                 = GameObject.FindWithTag("GameController").GetComponent <NextScene>();
        healthControllerClassReference = gameObject.GetComponent <HealthController>();
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.GetComponent <RightCollider>())
        {
            Destroy(gameObject);
            Ship.TurnOffActiveShot();
        }
        else if (other.tag == "Enemy")
        {
            Destroy(gameObject);
            Destroy(other.gameObject);
            Transform particles = Instantiate(enemyParticlesPrefab,
                                              other.transform.position, Quaternion.identity);
            Destroy(particles.gameObject, 1f);
            Ship.TurnOffActiveShot();
            Ship.AddScore();
            SpawnEnemies.RemoveEnemy();

            if (SpawnEnemies.GetAmountOfEnemies() == 0 &&
                !SpawnEnemies.StartedGame())
            {
                SceneManager.LoadScene("MainMenu");
            }
        }
        else if (other.gameObject.GetComponent <EnemyShot>())
        {
            Destroy(gameObject);
            Destroy(other.gameObject);
            Ship.TurnOffActiveShot();
        }
    }
Ejemplo n.º 12
0
 // Use this for initialization
 void Start()
 {
     spawnScript = GameObject.FindGameObjectWithTag("Spawner").GetComponent <SpawnEnemies>();
     if (canFlash)
     {
         FlashInitialize();
     }
 }
Ejemplo n.º 13
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     gameStarted = false;
 }
Ejemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     spawnEnemies = gameObject.GetComponent <SpawnEnemies> ();
     if (spawnEnemies.endlessMode == false)
     {
         NextWave();
     }
 }
Ejemplo n.º 15
0
 void Awake()
 {
     uxControllerClassReference = GetComponent <UXController> ();
     nextSceneClass             = GetComponent <NextScene>();
     spawnEnemiesClassReference = GameObject.FindWithTag("GameController").GetComponent <SpawnEnemies> ();
     playerTransformReference   = GameObject.FindWithTag("Player").GetComponent <Transform>();
     playerController           = GameObject.FindWithTag("Player").GetComponent <PlayerController>();
 }
Ejemplo n.º 16
0
 // Use this for initializat;ion
 void Start()
 {
     spawnEnemies     = GetComponent <SpawnEnemies>();
     healthController = GetComponent <HealthConroller>();
     startWait        = new WaitForSeconds(startDelay);
     endWait          = new WaitForSeconds(endDelay);
     StartCoroutine(GameLoop());
 }
Ejemplo n.º 17
0
 // Start is called before the first frame update
 void Start()
 {
     _swordThrowing = GetComponent <SwordThrowing>();
     _rigid         = gameObject.GetComponent <Rigidbody2D>();
     _spawn         = GameObject.Find("SpawnArea").GetComponent <SpawnEnemies>();
     _master        = GameObject.Find("GameMaster").GetComponent <MasterCounter>();
     _init          = GetComponent <Init>();
 }
Ejemplo n.º 18
0
    // Use this for initialization
    void Start()
    {
        currentHealth = startingHealth;
        healthBar     = gameObject.GetComponentInChildren <EnemyHealthBar>();
        spawnManager  = GameObject.Find("EnemyManager").GetComponent <SpawnEnemies>();
        scoreManager  = GameObject.Find("ScoreManager").GetComponent <ScoreManager>();

//		healthBar.value = calculatedHealth ();
    }
Ejemplo n.º 19
0
    // Start is called before the first frame update
    void Start()
    {
        playerHealth = 3;
        h            = spawnManager.GetComponent <SpawnEnemies>();
        myAnim       = gameObject.GetComponent <Animator>();

        GameObject.Find("GameStatusText").GetComponent <Text>().text = "";
        GameObject.Find("DayText").GetComponent <Text>().text        = "";
    }
Ejemplo n.º 20
0
    void Awake()
    {
        constChangeRate = ChangeRate;

        player              = GameObject.FindGameObjectWithTag("Player");
        playerhp            = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealth>();
        EnemySpawn          = GameObject.FindGameObjectWithTag("Spawner").GetComponent <SpawnEnemies>();
        EnemySpawn.MaxSpawn = 1;
    }
Ejemplo n.º 21
0
    void Start()
    {
        topDoor   = this.gameObject.transform.GetChild(0).gameObject;
        botDoor   = this.gameObject.transform.GetChild(1).gameObject;
        rightDoor = this.gameObject.transform.GetChild(2).gameObject;
        leftDoor  = this.gameObject.transform.GetChild(3).gameObject;

        enemySpawner = GetComponentInChildren <SpawnEnemies>();
    }
 void Awake()
 {
     spawnEnemiesClass         = GameObject.FindWithTag("GameController").GetComponent <SpawnEnemies> ();
     audioGame                 = GameObject.FindWithTag("GameController").GetComponent <AudioSource> ();
     UnityADSInterstitialClass = GameObject.FindWithTag("GameController").GetComponent <UnityADSInterstitial>();
     fireButtonAnimator        = fireButton.GetComponent <Animator>();
     shellButtonAnimator       = shellButton.GetComponent <Animator>();
     shellButtonImage          = shellButton.GetComponent <Image>();
     missileButtonImage        = missileButton.GetComponent <Image>();
 }
Ejemplo n.º 23
0
    /// /////
    //Yellow objects switch spots when halfway along their path
    ////////

    // Start is called before the first frame update
    void Start()
    {
        newspot = transform.position.x * (-1f); //opposite end of the screen is the newspot the ball will move to

        transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z + 0.25f);

        SE = GameObject.FindGameObjectWithTag("Spawner").GetComponent <SpawnEnemies>();

        ChangePoint = 2f * Camera.main.orthographicSize / 2; //the interval at which the balll will switch sides
    }
Ejemplo n.º 24
0
 void Start()
 {
     difficultyLevel  = PlayerPrefs.GetInt("difficultyLevel", 0);
     player           = GameObject.Find("Player");
     playerVal        = player.GetComponent <PlayerValues>();
     spawnEnemies     = player.GetComponent <SpawnEnemies>();
     metersWalkedText = GameObject.Find("InGameCanvas/MetersWalked").GetComponent <Text>();
     recordText       = GameObject.Find("StartCanvas/Record");
     GameObject.Find("WeaponsCanvas/DifficultyLevel").GetComponent <Text>().text = difficultyLevel.ToString();
 }
Ejemplo n.º 25
0
 // Use this for initializat;ion
 void Start()
 {
     enemiesKilled    = new Dictionary <string, int>();
     highScore.text  += PlayerPrefs.GetInt("highScore");
     spawnEnemies     = GetComponent <SpawnEnemies>();
     healthController = GetComponent <HealthConroller>();
     startWait        = new WaitForSeconds(startDelay);
     endWait          = new WaitForSeconds(endDelay);
     StartCoroutine(GameLoop());
     Reset();
 }
Ejemplo n.º 26
0
 void Start()
 {
     score        = FindObjectOfType <Score>();
     spawnEnemies = FindObjectOfType <SpawnEnemies>();
     y            = 0f;
     originalX    = coordonates2Reach.x;
     shootPeriod  = Random.Range(shootTime, shootTime + 2f);
     StartCoroutine(ShootDelay(shootPeriod));
     positionReach = false;
     newCoords     = coordonates2Reach;
 }
Ejemplo n.º 27
0
    public void Enter()
    {
        Debug.Log("entering spawn state");

        playerPrefab = Resources.Load <GameObject>("Prefabs/Ship");
        enemy        = Resources.Load <GameObject>("Prefabs/Invader1");

        MyPS.PlayerObject(playerPrefab);

        _spawnEnemies = new SpawnEnemies(enemy, _rowAmount, _enemiesInRow, _rowLocationX, _rowLocationY, _nextRowLocationX, _nextEnemyPosY);
    }
Ejemplo n.º 28
0
 // Start is called before the first frame update
 void Start()
 {
     timeIHaveBeenDrained = 0f;
     alreadyDied          = false;
     eAnim        = gameObject.GetComponent <Animator>();
     spawnManager = GameObject.Find("SpawnManager");
     waveNum      = GameObject.Find("WaveText").GetComponent <Text>();
     s            = spawnManager.GetComponent <SpawnEnemies>();
     player       = GameObject.Find("Player");
     w            = player.GetComponent <UseTheWand>();
 }
Ejemplo n.º 29
0
    // Start is called before the first frame update
    void Start()
    {
        // Convert the mouse coordinates
        Vector3 worldMousePos = Input.mousePosition;

        mousePos    = Camera.main.ScreenToWorldPoint(new Vector3(worldMousePos.x, worldMousePos.y, 10));
        mouseRadius = 0.5f;
        wandNum     = 0;
        myAnim      = gameObject.GetComponent <Animator>();
        playerMana  = 0f;
        s           = spawnManager.GetComponent <SpawnEnemies>();
    }
Ejemplo n.º 30
0
 // Use this for initialization
 void Start()
 {
     locker = GetComponentInParent<LockGates>();
     locked = true;
     anim = GetComponent<Animation>();
     player = GameObject.Find ("Warrior");
     roomspawner = GameObject.Find("Room Spawner").GetComponent<RoomSpawner>();
     enemies = GameObject.Find ("Spawner").GetComponent<SpawnEnemies>();
     exp = GameObject.Find ("Warrior").GetComponent<Experience>();
     ga = GameObject.Find ("Spawner").GetComponent<GeneticAlgorithm>();
     enemyspawner = GameObject.Find ("Spawner").GetComponent<SpawnEnemies>();
 }
Ejemplo n.º 31
0
 private void Awake()
 {
     if (SE == null)
     {
         SE = this;
     }
     else
     {
         Destroy(this);
         return;
     }
 }
Ejemplo n.º 32
0
 void Start()
 {
     renderer = GetComponent<SpriteRenderer>();
     colors[1] = renderer.material.color;
     waypoints = GameObject.FindGameObjectWithTag("Waypoints")
         .GetComponent<WaypointController>().waypoints;
     maxWaypoints = waypoints.Length;
     spawner = GameObject.Find("SpawnPoint").GetComponent<SpawnEnemies>();
     enemyList = spawner.enemies;
     if (spawnedByEnemy)
         return;
     nextWaypoint = 1;
     target = waypoints[0].transform;
 }
Ejemplo n.º 33
0
 // Use this for initialization
 void Start()
 {
     if (spawnEnemiesGO)
     {
         _spawnEnemies = spawnEnemiesGO.GetComponent<SpawnEnemies>();
         if (_spawnEnemies == null)
         {
             foreach (Transform child in spawnEnemiesGO.transform)
             {
                 var otherSpawnEnemies = child.GetComponent<SpawnEnemies>();
                 if (otherSpawnEnemies != null)
                 {
                     _spawnEnemies = otherSpawnEnemies;
                     break;
                 }
             }
         }
     }
 }
Ejemplo n.º 34
0
    //#################################################################################################
    //### UnityEngine
    void Start()
    {
        currentHealthPoints = healthPoints;

        if(gameObject.CompareTag("Enemy"))
        {
            amEnemy = true;
        }

        if(!spawner)
        {
            spawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent<SpawnEnemies>();
        }
    }
Ejemplo n.º 35
0
 // Use this for initialization
 void Start()
 {
     spawner = GetComponent<SpawnEnemies>();
     numEnemies = spawner.NumberOfEnemies;
 }
Ejemplo n.º 36
0
    void Start()
    {
        rooms = new int[7,7];
        spawnEnemies = manager.GetComponent<SpawnEnemies>();

        dungeonManager = GameObject.FindGameObjectWithTag("DungeonManager").GetComponent<DungeonManager>();
        switch(dungeonManager.dungeonName)
        {
            case "Plains":
                tilePrefab = Resources.Load<GameObject>("Tiles/Tile2").transform;
                break;
            case "Caves":
                tilePrefab = Resources.Load<GameObject>("Tiles/Tile1").transform;
                break;
            case "Chasm":
                tilePrefab = Resources.Load<GameObject>("Tiles/Tile3").transform;
                break;
        }

        generateFloor();
        //Debug.Log(numRooms);

        UpdateConnections();
    }
Ejemplo n.º 37
0
    //#################################################################################################
    //### UnityEngine
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");
        playerHealth = player.GetComponent<HasHealth>();
        health = gameObject.GetComponent<HasHealth>();
        range = Global.global.levelSize / 2.0f;

        if(!spawner)
        {
            spawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent<SpawnEnemies>();
        }
    }
Ejemplo n.º 38
0
    void Start()
    {
        rooms = new int[7,7];
        spawnEnemies = manager.GetComponent<SpawnEnemies>();

        dungeonManager = GameObject.FindGameObjectWithTag("DungeonManager").GetComponent<DungeonManager>();

        generateFloor();
        //Debug.Log(numRooms);

        UpdateConnections();
    }
Ejemplo n.º 39
0
 // Use this for initialization
 void Start()
 {
     destroyed = false;
     holding = false;
     start = true;
     position = transform.position;
     rb = GetComponent<Rigidbody2D>();
     rb.isKinematic = true;
     enemies = GameObject.FindGameObjectWithTag("Castle").GetComponent<SpawnEnemies>();
     enemy2 = GameObject.FindGameObjectWithTag("Castle").GetComponent<SpawnEnemy2>();
 }