Ejemplo n.º 1
0
 void Start()
 {
     Ps     = GameObject.FindObjectOfType <PlayerScript>();
     player = GameObject.FindGameObjectWithTag("Player").transform;
     B_H    = GetComponentInChildren <Enemy_HP>();
     ani    = GetComponentInChildren <Animator>();
 }
Ejemplo n.º 2
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Enemy")
        {
            _enemyMovement = other.gameObject.GetComponentInParent <Enemy_Movement>();
            _enemyHP       = other.gameObject.GetComponentInParent <Enemy_HP>();

            if (_enemyHP != null)
            {
                if (_enemyMovement != null)
                {
                    _enemyMovement.Knockback(250f, 250f);
                }
                _enemyHP.TakeDamage(10);
            }
            else
            {
                _fenrirHP       = other.gameObject.GetComponentInParent <Fenrir_HP>();
                _fenrirMovement = other.gameObject.GetComponentInParent <Fenrir_Movement>();

                _fenrirMovement.Knockback(250f, 250f);
                _fenrirHP.TakeDamage(10);
            }


            _fenrirHP      = null;
            _enemyHP       = null;
            _enemyMovement = null;
        }
        else if (other.gameObject.tag == "Head")
        {
            other.gameObject.GetComponent <Head>().SpillBlood();
        }
    }
Ejemplo n.º 3
0
 void Start()
 {
     rb     = GetComponent <Rigidbody2D>();
     FL     = GameObject.FindObjectOfType <FinishLevel>();
     Ps     = GameObject.FindObjectOfType <PlayerScript>();
     player = GameObject.FindGameObjectWithTag("Player").transform;
     E_H    = GetComponentInChildren <Enemy_HP>();
 }
Ejemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     myHP         = GetComponent <Enemy_HP>();
     myCamera     = myHP.myCamera;
     counter      = 0;
     timeStraight = 0;
     straight     = true;
 }
Ejemplo n.º 5
0
 // Use this for initialization
 void Awake()
 {
     _lokiMovement        = GetComponent <LokiMovement>();
     _lokiAttack          = GetComponent <LokiAttack>();
     _hp                  = GetComponent <Enemy_HP>();
     _playerHP            = FindObjectOfType <Player_HP>();
     _animationController = GetComponent <LokiAnimationController>();
     _cameraFollow        = FindObjectOfType <Player_CameraFollow>();
 }
 void Start()
 {
     timeToJump = Random.Range(0f, maxTimeToJump);
     myHP       = GetComponent <Enemy_HP>();
     myCamera   = myHP.myCamera;
     myPlayer   = myHP.myPlayer;
     myTilemap  = myHP.myTilemap;
     myAnimator = GetComponent <Animator>();
 }
Ejemplo n.º 7
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Enemy")
     {
         _enemyMovement = other.gameObject.GetComponentInParent <Enemy_Movement>();
         _enemyMovement.Knockback(250, 250);
         _enemyHP = other.gameObject.GetComponentInParent <Enemy_HP>();
         _enemyHP.TakeDamage(1);
     }
 }
Ejemplo n.º 8
0
 void Start()
 {
     myHP     = GetComponent <Enemy_HP>();
     myCamera = myHP.myCamera;
     moblinRB = GetComponent <Rigidbody2D>();
     //moveSwitcher = Random.Range(0, 4);
     moveSwitcher = 0;
     moveSwitcher = 0;
     modeSwitcher = 1;
     moving       = true;
     spearsThrown = 0;
     anim         = GetComponent <Animator>();
 }
Ejemplo n.º 9
0
    // Use this for initialization
    void Awake()
    {
        _enemyHp     = _boss.GetComponent <Enemy_HP>();
        _playerInput = FindObjectOfType <Player_InputController>();


        if (_enemyHp == null)
        {
            Debug.Log("NUULLL");
            _fenrirHp = _boss.GetComponent <Fenrir_HP>();
        }
        _cameraScript = FindObjectOfType <Player_CameraFollow>();
    }
Ejemplo n.º 10
0
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        Bot_Boss B_B = Animator.FindObjectOfType <Bot_Boss>();

        B_B.prepareAttack(1, "Attack" + random);
        pRandom = random;

        Enemy_HP B_H = Animator.FindObjectOfType <Bot_Boss>().B_H;

        if (B_H.HP <= B_H.MaxHP / 2)
        {
            animator.SetBool("State2", true);
        }
    }
 //When the player or an enemy entires the fire, they get damaged
 void OnTriggerEnter2D(Collider2D activator)
 {
     if (activator.CompareTag("PlayerCollision") && lifeTime <= maxLife * 0.75f) //Only damages player after it has been moving for a bit
     //Player takes damage and is pushed back
     {
         PlayerControl pControl = activator.GetComponent <PlayerCollisionInfo>().myPlayerControl;
         pControl.EnemyCollision(transform.position, -1);
     }
     else if (activator.CompareTag("Enemies"))
     {
         Enemy_HP enemyHP = activator.GetComponent <Enemy_HP>();
         enemyHP.TakeDamage(-1, false, transform.up);
         //Enemies are not pushed back, but they do take 1 damage
     }
 }
 // Start is called before the first frame update
 void Start()
 {
     explodeTime = startExplodeTime;
     //Have him hit enemies on start
     //Checks all colliders in its area
     Collider2D[] myColliders = Physics2D.OverlapCircleAll(transform.position, transform.localScale.x - 0.1f);
     for (int i = 0; i < myColliders.Length; i++)
     {
         if (myColliders[i].CompareTag("Enemies"))
         {
             Enemy_HP myEnemyHealth = myColliders[i].GetComponent <Enemy_HP>();
             myEnemyHealth.TakeDamage(-4, true, transform.up);
         }
     }
 }
    bool cameraTurnCause;//Boolean used if camera is the player's reason for turning

    // Start is called before the first frame update
    void Start()
    {
        myHP         = GetComponent <Enemy_HP>();
        myCamera     = myHP.myCamera;
        octorokRB    = GetComponent <Rigidbody2D>();
        counter      = 0;
        timeStraight = Random.Range(0f, max_timeStraight / 2f);
        timeShooting = 0;
        straight     = true;
        moving       = true;
        modeSwitcher = 0;
        rockShot     = 0;
        int random = Random.Range(0, 4);

        transform.localEulerAngles = new Vector3(0f, 0f, 90f * random);
    }
Ejemplo n.º 14
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Enemy")
        {
            _enemyHP = other.gameObject.GetComponentInParent <Enemy_HP>();

            if (_enemyHP == null)
            {
                _fenrirHP = other.gameObject.GetComponentInParent <Fenrir_HP>();
            }

            SoundManager.instance.PlaySound("sword_hit", _source, false);

            if (_enemyHP != null && !_enemyHP.thisIsABoss)
            {
                _enemyMovement = other.gameObject.GetComponentInParent <Enemy_Movement>();
                _enemyMovement.Knockback(250f, 250f);
            }

            if (_fenrirHP == null)
            {
                if (_enemyHP.HP > 0)
                {
                    _sword.AddCompletionByDamage(_specialCompletionPercent);
                }

                _enemyHP.TakeDamage(_damage);
            }
            else
            {
                if (_fenrirHP.HP > 0)
                {
                    _sword.AddCompletionByDamage(_specialCompletionPercent);
                }
                _fenrirHP.TakeDamage(_damage);
            }

            _fenrirHP      = null;
            _enemyHP       = null;
            _enemyMovement = null;
        }
        else if (other.gameObject.tag == "Head")
        {
            SoundManager.instance.PlaySound("sword_hit", _source, false);
            other.gameObject.GetComponent <Head>().SpillBlood();
        }
    }
    public void SpawnDeath()
    {
        Transform newEnemy = Instantiate(myEnemy, transform.position, transform.rotation);

        myManager.CurrentEnemyList[number] = newEnemy;
        newEnemy.gameObject.layer          = 8;
        Enemy_HP myEnemyHP = newEnemy.GetComponent <Enemy_HP>();

        if (myEnemyHP != null)
        {
            //Gives the enemy access to each of these variables, so that other scripts can reference them
            myEnemyHP.myCamera  = myCamera;
            myEnemyHP.myPlayer  = myPlayer;
            myEnemyHP.myTilemap = myTilemap;
            myEnemyHP.myManager = myManager;
        }
        Destroy(this.gameObject);
    }
Ejemplo n.º 16
0
    Vector3 flyDirection;//The direction this Peahat is currently flying in (determined semi-randomly)

    void Start()
    {
        myAnimator = GetComponent <Animator>();
        speed      = baseSpeed;
        flyTime    = Random.Range(0f, max_flyTime / 2);
        flying     = true;
        //Direction is determined to be a random direction
        float x = Random.Range(-1, 1);
        float y = Random.Range(-1, 1);

        //If direction is null, it is determined differently
        if (x == 0 && y == 0)
        {
            float rnd = Random.Range(0, 1f);
            if (rnd < 0.25f)
            {
                y = 1f;
            }
            else if (rnd < 0.5f)
            {
                y = -1f;
            }
            else if (rnd < 0.75f)
            {
                x = 1f;
            }
            else
            {
                x = -1f;
            }
        }
        flyDirection     = new Vector3(x, y, 0f).normalized;
        myHP             = GetComponent <Enemy_HP>();
        myCamera         = myHP.myCamera;
        mySpriteRenderer = GetComponent <SpriteRenderer>();
        //Determines a random spot to spawn in
        x = Random.Range(myCamera.transform.position.x - myCamera.aspect * myCamera.orthographicSize + 1f, myCamera.transform.position.x + myCamera.orthographicSize * myCamera.aspect - 1f);
        y = Random.Range(myCamera.transform.position.y - myCamera.orthographicSize + 1f, myCamera.transform.position.y + myCamera.orthographicSize - 1f - statBarOffset);
        //Debug.Log(myCamera.transform.position.ToString());
        //Debug.Log(x.ToString());
        //Debug.Log(y.ToString());
        transform.position = new Vector3(x, y, -1f);
    }
Ejemplo n.º 17
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Enemy")
        {
            _enemyMovement = other.gameObject.GetComponentInParent <Enemy_Movement>();
            _enemyHP       = other.gameObject.GetComponentInParent <Enemy_HP>();

            if (_enemyHP == null)
            {
                _fenrirMovement = other.gameObject.GetComponentInParent <Fenrir_Movement>();
                _fenrirHP       = other.gameObject.GetComponentInParent <Fenrir_HP>();
            }

            if (_enemyHP != null)
            {
                if (_enemyMovement != null)
                {
                    _enemyMovement.Stun(_stunTime);
                }
                else if (_enemyHP.gameObject.name.Contains("Surt"))
                {
                    _surt = _enemyHP.GetComponent <Surt_Movement>();
                    _surt.Stun(_stunTime);
                }
                _enemyHP.TakeDamage(_damage);
            }
            else if (_fenrirHP != null)
            {
                _fenrirMovement.Stun(_stunTime);
                _fenrirHP.TakeDamage(_damage);
            }

            _fenrirHP       = null;
            _fenrirMovement = null;
            _enemyHP        = null;
            _enemyMovement  = null;
        }
        else if (other.gameObject.tag == "Head")
        {
            other.gameObject.GetComponent <Head>().SpillBlood();
        }
    }
Ejemplo n.º 18
0
 BoxCollider2D myCollider;                                      //The collider box of this entity - activates and deactivates at different times
 void Start()
 {
     anim             = GetComponent <Animator>();
     myHP             = GetComponent <Enemy_HP>();
     myCollider       = GetComponent <BoxCollider2D>();
     myCamera         = myHP.myCamera;
     myTilemap        = myHP.myTilemap;
     myPlayer         = myHP.myPlayer;
     mySpriteRenderer = GetComponent <SpriteRenderer>();
     //get a list of tiles this guy can spawn on
     //For loop of y values, than x values
     for (int i = 0; i < myCamera.orthographicSize * 2 - statBarOffest; i++)
     {
         for (int j = 0; j < myCamera.orthographicSize * 2 * myCamera.aspect - 1; j++)
         {
             //x position is equal to bottom left corner plus j
             int x = (int)(myCamera.transform.position.x - myCamera.orthographicSize * myCamera.aspect) + j;
             //y position is equal to bottom left corner plus i
             int y = (int)(myCamera.transform.position.y - myCamera.orthographicSize) + i;
             //Check the tile at that position
             Tile myTile = myTilemap.GetTile <Tile>(new Vector3Int(x, y, 0));
             if (myTile != null)
             {
                 for (int k = 0; k < possibleWaterTiles.Count; k++)
                 {
                     if (myTile.sprite == possibleWaterTiles[k])
                     {
                         Debug.Log(x.ToString() + " " + y.ToString());
                         waterTiles.Add(new Vector3((float)x + 0.5f, (float)y, 0f));//y might need to have 0.5 added to it
                     }
                 }
             }
         }
     }
     //If there is at least 1 water tile, this enemy is teleported to 1 of them when it spawns
     if (waterTiles.Count > 0)
     {
         int rnd = Random.Range(0, waterTiles.Count - 1);
         transform.position = waterTiles[rnd];
     }
 }
 public void Attack()
 {
     //Play an attack animation
     //anim.SetTrigger("Attack");
     mySword.ThrowSword();//Tries to throw the sword, if they can
     //Detect enemies in range of attack
     attackPoint.position = transform.position + myControl.directionRecord;
     Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(attackPoint.position, attackRange);//, enemyLayers);
     Debug.DrawLine(transform.position, attackPoint.position);
     //Damage them
     foreach (Collider2D enemy in hitEnemies)
     {
         //enemy.GetComponent<Enemy>().TakeDamage(attackDamage);
         if (enemy.CompareTag("Enemies"))
         {
             //Enemy takes damage
             Enemy_HP enemyHP = enemy.GetComponent <Enemy_HP>();
             enemyHP.TakeDamage(-attackDamage, true, myControl.directionRecord);
         }
     }
 }
Ejemplo n.º 20
0
    private void CheckLists()
    {
        _hp = new ArrayList();

        foreach (GameObject enemy in _enemies)
        {
            Enemy_HP tmp = enemy.GetComponent <Enemy_HP>();

            if (tmp == null)
            {
                Fenrir_HP fenrirHP = enemy.GetComponent <Fenrir_HP>();
                _hp.Add(fenrirHP);
            }
            else
            {
                _hp.Add(tmp);
            }
        }

        foreach (GameObject ob in _objects)
        {
            ob.SetActive(false);
        }
    }
    void Update()
    {
        //detect which side Link is facing, and rotate the sword to that direction

        //when attack button is pressed, shoot the sword
        if (Input.GetKey(KeyCode.X))
        {
            if (hasSword && myHearts.curHealth == myHearts.maxHealth)
            {
                //shootSword = true;
            }
        }
        //And also make the sword shoot to different directions
        if (shootSword)
        {
            transform.position += moveSpeed * Time.deltaTime * direction;
            canShootSword       = false;
            GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 255);
            float rayLength = 0.4f;
            //use raycast to detect stuff ahead - needs to specifically hit enemies
            LayerMask enemyLayer = LayerMask.GetMask("Enemies");
            Ray2D     myRay      = new Ray2D(transform.position, transform.up);
            Debug.DrawRay(myRay.origin, myRay.direction * rayLength, Color.white);
            RaycastHit2D myRayHit = Physics2D.Raycast(myRay.origin, myRay.direction, rayLength, enemyLayer);
            if (myRayHit.collider != null)
            {
                Debug.Log("Hit something");
                //the sword disappear, return to the player's position
                //need to add animation
                if (myRayHit.collider.CompareTag("Enemies"))
                {
                    Enemy_HP enemyHP = myRayHit.collider.GetComponent <Enemy_HP>();
                    shootSword = false;
                    Instantiate(hitPrefab, transform.position + direction / 2f, Quaternion.identity);
                    enemyHP.TakeDamage(-1, true, myPlayer.directionRecord);
                    transform.position = myPlayer.transform.position;
                }
            }
            //Also needs to be stop if it gets too close to the edge of the screen
            else
            {
                //Each direction has its own test to see if it goes off screen
                if (direction.x > 0)
                {
                    if (transform.position.x > myCamera.transform.position.x + myCamera.aspect * myCamera.orthographicSize - 1f)
                    {
                        shootSword = false;
                        Instantiate(hitPrefab, transform.position + direction / 2f, Quaternion.identity);
                        transform.position = myPlayer.transform.position;
                    }
                }
                else if (direction.x < 0)
                {
                    if (transform.position.x < myCamera.transform.position.x - myCamera.aspect * myCamera.orthographicSize + 1f)
                    {
                        shootSword = false;
                        Instantiate(hitPrefab, transform.position + direction / 2f, Quaternion.identity);
                        transform.position = myPlayer.transform.position;
                    }
                }
                else if (direction.y > 0)
                {
                    if (transform.position.y > myCamera.transform.position.y + myCamera.orthographicSize - statBarOffset)
                    {
                        shootSword = false;
                        Instantiate(hitPrefab, transform.position + direction / 2f, Quaternion.identity);
                        transform.position = myPlayer.transform.position;
                    }
                }
                else if (direction.y < 0)
                {
                    if (transform.position.y < myCamera.transform.position.y - myCamera.orthographicSize)
                    {
                        shootSword = false;
                        Instantiate(hitPrefab, transform.position + direction / 2f, Quaternion.identity);
                        transform.position = myPlayer.transform.position;
                    }
                }
            }
        }
        //hide the sword when not in use
        if (shootSword == false)
        {
            GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0);
        }

        else
        {
        }
    }
Ejemplo n.º 22
0
        void Update_Info_thread(object obj)
        {
            byte g = (byte)obj;

            if (Player_HP.InvokeRequired)
            {
                Player_HP.Invoke(new MethodInvoker(delegate { Player_HP.Text = string.Format("HP: {0}/{1}", hero.HP, hero.FULLHP); }));
            }
            if (Enemy_HP.InvokeRequired)
            {
                Enemy_HP.Invoke(new MethodInvoker(delegate { Enemy_HP.Text = string.Format("HP: {0}/{1}", enemy.HP, enemy.FULLHP); }));
            }
            string Hero_text  = string.Format(@"Full HP: {0}
Damage: {1}
Evade Chance: {2}
Block Chance: {3}
CriticalDMG %: {4}
CriticalDMG: {5}%", hero.HP, hero.DMG, hero.EvadeChance, hero.BlockChance, hero.CriticalDMGChance, hero.CriticalDMG);
            string Enemy_text = string.Format(@"Full HP: {0}
Damage: {1}
Evade Chance: {2}
Block Chance: {3}
CriticalDMG %: {4}
CriticalDMG: {5}%", enemy.HP, enemy.DMG, enemy.EvadeChance, enemy.BlockChance, enemy.CriticalDMGChance, enemy.CriticalDMG);

            if (Hero_Stats.InvokeRequired)
            {
                Hero_Stats.Invoke(new MethodInvoker(delegate { Hero_Stats.Text = Hero_text; }));
            }
            if (Enemy_Stats.InvokeRequired)
            {
                Enemy_Stats.Invoke(new MethodInvoker(delegate { Enemy_Stats.Text = Enemy_text; }));
            }
            if (hero.HP <= 0)
            {
                Thread t = Thread.CurrentThread;
                fight = false;
                enemyRectanglepos.RemoveAt(g);
                enemys.RemoveAt(g);
                foreach (Thread thr in thList)
                {
                    thr.Resume();
                }
                LoadEnemySightAndWay();
                if (pictureBox2.InvokeRequired)
                {
                    pictureBox2.Invoke(new MethodInvoker(delegate { pictureBox2.Image = Image.FromFile(Environment.CurrentDirectory + "\\ImagesH\\Battle_tendence.png"); }));
                }
                if (Attack_Button.InvokeRequired)
                {
                    Attack_Button.Invoke(new MethodInvoker(delegate
                    {
                        Attack_Button.Enabled = false;
                        Attack_Button.Visible = false;
                    }));
                }
                if (STOIKA_BUTTON.InvokeRequired)
                {
                    STOIKA_BUTTON.Invoke(new MethodInvoker(delegate
                    {
                        STOIKA_BUTTON.Enabled = false;
                        STOIKA_BUTTON.Visible = false;
                    }));
                }
                if (Player_HP.InvokeRequired)
                {
                    Player_HP.Invoke(new MethodInvoker(delegate
                    {
                        Player_HP.Visible = false;
                    }));
                }
                if (Enemy_HP.InvokeRequired)
                {
                    Enemy_HP.Invoke(new MethodInvoker(delegate
                    {
                        Enemy_HP.Visible = false;
                    }));
                }
                if (Hero_Stats.InvokeRequired)
                {
                    Hero_Stats.Invoke(new MethodInvoker(delegate
                    {
                        Hero_Stats.Visible = false;
                    }));
                }
                if (Enemy_Stats.InvokeRequired)
                {
                    Enemy_Stats.Invoke(new MethodInvoker(delegate
                    {
                        Enemy_Stats.Visible = false;
                    }));
                }
                if (hodiki.InvokeRequired)
                {
                    hodiki.Invoke(new MethodInvoker(delegate
                    {
                        hodiki.Visible   = false;
                        hodiki.Text      = "<--Ваш ход";
                        hodiki.ForeColor = Color.Green;
                    }));
                }
                t.Abort();
            }
            else if (enemy.HP <= 0)
            {
                if (pictureBox2.InvokeRequired)
                {
                    pictureBox2.Invoke(new MethodInvoker(delegate { pictureBox2.Image = Image.FromFile(Environment.CurrentDirectory + "\\ImagesH\\Battle_tendence.png"); }));
                }
                Thread t = Thread.CurrentThread;
                fight = false;
                enemyRectanglepos.RemoveAt(g);
                enemys.RemoveAt(g);
                foreach (Thread thr in thList)
                {
                    thr.Resume();
                }
                LoadEnemySightAndWay();
                if (hodiki.InvokeRequired)
                {
                    hodiki.Invoke(new MethodInvoker(delegate
                    {
                        hodiki.Visible   = false;
                        hodiki.Text      = "<--Ваш ход";
                        hodiki.ForeColor = Color.Green;
                    }));
                }
                if (Attack_Button.InvokeRequired)
                {
                    Attack_Button.Invoke(new MethodInvoker(delegate
                    {
                        Attack_Button.Enabled = false;
                        Attack_Button.Visible = false;
                    }));
                }
                if (STOIKA_BUTTON.InvokeRequired)
                {
                    STOIKA_BUTTON.Invoke(new MethodInvoker(delegate
                    {
                        STOIKA_BUTTON.Enabled = false;
                        STOIKA_BUTTON.Visible = false;
                    }));
                }
                if (Player_HP.InvokeRequired)
                {
                    Player_HP.Invoke(new MethodInvoker(delegate
                    {
                        Player_HP.Visible = false;
                    }));
                }
                if (Enemy_HP.InvokeRequired)
                {
                    Enemy_HP.Invoke(new MethodInvoker(delegate
                    {
                        Enemy_HP.Visible = false;
                    }));
                }
                if (Hero_Stats.InvokeRequired)
                {
                    Hero_Stats.Invoke(new MethodInvoker(delegate
                    {
                        Hero_Stats.Visible = false;
                    }));
                }
                if (Enemy_Stats.InvokeRequired)
                {
                    Enemy_Stats.Invoke(new MethodInvoker(delegate
                    {
                        Enemy_Stats.Visible = false;
                    }));
                }
                t.Abort();
            }
            else
            {
                if (Hero_Attacked)
                {
                    Turn_Enemy.Invoke(this, new NumOfEnemy {
                        i = g
                    });
                }
                else
                {
                    Turn_Hero.Invoke(this, new NumOfEnemy {
                        i = g
                    });
                }
            }
        }
Ejemplo n.º 23
0
 void Start()
 {
     timeLeft = timeMax;
     workHP   = GetComponentInParent <Enemy_HP>();
 }
Ejemplo n.º 24
0
 void Start()
 {
     EH   = GetComponentInChildren <Enemy_HP>();
     T    = GetComponentInChildren <Timer>();
     PM_H = GetComponentInChildren <PlayerMini_HP>();
 }
Ejemplo n.º 25
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     B_H          = Animator.FindObjectOfType <Bot_Boss>().B_H;
     B_H.isIFlame = true;
 }
Ejemplo n.º 26
0
 void Start()
 {
     EnemyData = new Enemy_HP(HP);
     Debug.Log(gameObject.name + "의 체력 : " + EnemyData.getHP());
 }
 // Update is called once per frame
 void Update()
 {
     if (roomEnter)
     {
         //if the room has reset, you create enemies from the starting list
         if (roomReset)
         {
             while (CurrentEnemyList.Count > 0)
             {
                 CurrentEnemyList.RemoveAt(0);
             }
             float spawn = 0.01f;
             for (int i = 0; i < StartEnemyList.Count; i++)
             {
                 if (StartEnemySpawner[i])
                 {
                     Transform newEnemy = Instantiate(EnemySpawnerPrefab, myCamera.transform.position, Quaternion.Euler(0f, 0f, 0f));
                     CurrentEnemyList.Add(newEnemy);
                     CurrentEnemySpawner.Add(StartEnemySpawner[i]);
                     EnemySpawn myEnemySpawn = newEnemy.GetComponent <EnemySpawn>();
                     if (myEnemySpawn != null)
                     {
                         //Gives the enemy access to each of these variables, so that other scripts can reference them
                         myEnemySpawn.myCamera  = myCamera;
                         myEnemySpawn.myPlayer  = myPlayer;
                         myEnemySpawn.myTilemap = myTilemap;
                         myEnemySpawn.spawnTime = spawn;
                         myEnemySpawn.myManager = this;
                         myEnemySpawn.spawnTime = spawn;
                         myEnemySpawn.myEnemy   = StartEnemyList[i];
                         myEnemySpawn.number    = CurrentEnemyList.Count - 1;
                         Debug.Log(myEnemySpawn.myEnemy.ToString());
                         spawn += spawnTimeIncrease;
                     }
                 }
                 else
                 {
                     Transform newEnemy = Instantiate(StartEnemyList[i], myCamera.transform.position, Quaternion.Euler(0f, 0f, 0f));
                     CurrentEnemyList.Add(newEnemy);
                     CurrentEnemySpawner.Add(StartEnemySpawner[i]);
                     newEnemy.gameObject.layer = 8;
                     Enemy_HP myEnemyHP = newEnemy.GetComponent <Enemy_HP>();
                     if (myEnemyHP != null)
                     {
                         //Gives the enemy access to each of these variables, so that other scripts can reference them
                         myEnemyHP.myCamera  = myCamera;
                         myEnemyHP.myPlayer  = myPlayer;
                         myEnemyHP.myTilemap = myTilemap;
                         myEnemyHP.spawnTime = spawn;
                         myEnemyHP.myManager = this;
                     }
                 }
             }
             roomReset = false;
         }
         else
         {
             //otherwise, enemies are created from the current enemy list
             float spawn = 0.01f;
             for (int i = 0; i < CurrentEnemyList.Count; i++)
             {
                 //Only creates the enemy if it really exists
                 if (CurrentEnemyList[i] != null)
                 {
                     if (CurrentEnemySpawner[i]) //If the current enemy uses a spawner, they get one
                     {
                         Transform newEnemy = Instantiate(EnemySpawnerPrefab, myCamera.transform.position, Quaternion.Euler(0f, 0f, 0f));
                         CurrentEnemyList[i] = newEnemy;
                         EnemySpawn myEnemySpawn = newEnemy.GetComponent <EnemySpawn>();
                         if (myEnemySpawn != null)
                         {
                             //Gives the enemy access to each of these variables, so that other scripts can reference them
                             myEnemySpawn.myCamera  = myCamera;
                             myEnemySpawn.myPlayer  = myPlayer;
                             myEnemySpawn.myTilemap = myTilemap;
                             myEnemySpawn.spawnTime = spawn;
                             myEnemySpawn.myManager = this;
                             myEnemySpawn.spawnTime = spawn;
                             myEnemySpawn.myEnemy   = StartEnemyList[i];
                             myEnemySpawn.number    = i;
                             spawn += spawnTimeIncrease;
                         }
                     }
                     else
                     {
                         Transform newEnemy = Instantiate(CurrentEnemyList[i], myCamera.transform.position, Quaternion.Euler(0f, 0f, 0f));
                         CurrentEnemyList[i]       = newEnemy;
                         newEnemy.gameObject.layer = 8;
                         Enemy_HP myEnemyHP = newEnemy.GetComponent <Enemy_HP>();
                         if (myEnemyHP != null)
                         {
                             //Gives the enemy access to each of these variables, so that other scripts can reference them
                             myEnemyHP.myCamera  = myCamera;
                             myEnemyHP.myPlayer  = myPlayer;
                             myEnemyHP.myTilemap = myTilemap;
                             myEnemyHP.spawnTime = spawn;
                             myEnemyHP.myManager = this;
                         }
                     }
                 }
             }
         }
         //Some enemy types have additional considerations
         //Then, the room enter finishes
         roomEnter = false;
     }
     if (roomLeave)
     {
         //Have to do this for loop in the opposite direction, because some of these elements may be deleted
         for (int i = CurrentEnemyList.Count - 1; i >= 0; i--)
         {
             if (CurrentEnemyList[i] == null)
             {
                 CurrentEnemySpawner[i] = false;
                 //Do nothing;
             }
             else
             {
                 //Destroy the object, and then replaces it with the corresponding prefab
                 Destroy(CurrentEnemyList[i].gameObject);
                 CurrentEnemyList[i]    = StartEnemyList[i];
                 CurrentEnemySpawner[i] = StartEnemySpawner[i];
             }
         }
         while (CurrentPickupList.Count > 0)
         {
             if (CurrentPickupList[0] != null)
             {
                 Destroy(CurrentPickupList[0].gameObject);
             }
             CurrentPickupList.RemoveAt(0);
         }
         roomLeave = false;
     }
 }
Ejemplo n.º 28
0
 void Start()
 {
     EH = GetComponentInParent <Enemy_HP>();
 }