Exemplo n.º 1
0
    void Start()
    {
        // Setting up the references.
        ai   = GetComponent <EnemyAI2>();
        anim = GetComponent <Animator>();
        //enemyAudio = GetComponent<AudioSource>();
        //hitParticles = GetComponentInChildren<ParticleSystem>();
        circleCollider = GetComponent <CircleCollider2D>();
        loot           = GetComponent <LootDrops>();
        // Setting the current health when the enemy first spawns.
        currentHealth  = startingHealth;
        previousHealth = startingHealth;
        healthbar.SetActive(false);
        rez        = GetComponent <Resurrectable>();
        spriteRend = GetComponent <SpriteRenderer>();

        if (isStunnable)
        {
            stunnable = GetComponent <Stunnable>();
        }
        var prefabs = GameObject.FindGameObjectWithTag("Load").GetComponent <LoadedPrefabs>().prefabs;

        foreach (var prefab1 in prefabs)
        {
            if (prefab1.name == "CritAnim")
            {
                critPrefab = prefab1;
                break;
            }
        }
        CheckOnFire();
        CheckFrozen();
    }
Exemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (!playerMissing)
        {
            EnemyAI2 script = other.GetComponent <EnemyAI2>();

            if (other.gameObject.name == "Player")
            {
                DestroyProjectile();

                other.GetComponent <PlayerHealth>().DamagePlayer(damage);
            }

            else if (script == null)
            {
                DestroyProjectile();
                if (other.GetComponent <EnemyHealth>())
                {
                    other.GetComponent <EnemyHealth>().DamageEnemy(damage);
                }
            }

            else if (other.gameObject.name == "Swing_Effect")
            {
                DestroyProjectile();
            }
        }
    }
Exemplo n.º 3
0
 // Start is called before the first frame update
 void Start()
 {
     ai     = GetComponentInParent <EnemyAI2>();
     cc     = GetComponent <CircleCollider2D>();
     player = GameObject.FindGameObjectWithTag("Player");
     ph     = player.GetComponent <PlayerHealth>();
 }
Exemplo n.º 4
0
 // Start is called before the first frame update
 void Awake()
 {
     ai    = GetComponent <EnemyAI2>();
     sw    = GetComponentInChildren <SM_ElectroWaveAttack>();
     anim  = GetComponent <Animator>();
     rezAb = GetComponent <ResurrectAbility>();
 }
Exemplo n.º 5
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Obstacle" || other.tag == "NPC")
        {
            OGController.currentCrystals = maxCrystals;
            OGController.finalCrystal    = gameObject;
            StartCoroutine(EndChain());
            return; //end the chain upon impact with an obstacle
        }

        if (cc.isTrigger == true && other.tag == "Enemy")
        {
            float critChance = Random.Range(0f, 1f);
            Debug.Log(critChance);
            bool criticalHit;
            if (critChance <= stats.criticalChance)
            {
                criticalHit = true;
            }
            else
            {
                criticalHit = false;
            }
            var calculatedDamage = baseDamage / 100f * stats.iceDamage;
            Debug.Log(calculatedDamage);
            int damage = player.GetComponentInChildren <IceBarrier>().baseDamage;
            damage = Mathf.RoundToInt(calculatedDamage);
            Debug.Log(gameObject.name + " sending " + damage + " damage.");
            EnemyHealth enemy = other.GetComponent <EnemyHealth>();
            enemy.TakeDamage(damage, damageType, criticalHit, enemy.transform.position + new Vector3(0f, 0.4f, 0f));
            EnemyAI2 ai = other.GetComponent <EnemyAI2>();
            ai.Knockback((Vector2)gameObject.transform.position);
        }
    }
Exemplo n.º 6
0
 // Start is called before the first frame update
 void Start()
 {
     ai     = GetComponent <EnemyAI2>();
     player = GameObject.FindGameObjectWithTag("Player");
     ph     = player.GetComponent <PlayerHealth>();
     ps     = GetComponentInChildren <ParticleSystem>();
     pm     = player.GetComponent <PlayerMovement>();
     rb     = GetComponent <Rigidbody2D>();
 }
Exemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     _animator     = GetComponent <Animator>();
     _navMeshAgent = GetComponent <NavMeshAgent>();
     enemyai       = GetComponent <EnemyAI2>();
     enemy         = GetComponent <NPC>();
     //for fluidity
     _navMeshAgent.stoppingDistance = 0.3f;
 }
Exemplo n.º 8
0
 private void Start()
 {
     //player = GameObject.FindGameObjectWithTag("Player");
     lootTable = GameObject.FindGameObjectWithTag("GameController").GetComponent <LootTable>();
     if (gameObject.GetComponent <EnemyAI2>() != null)
     {
         fromEnemy = true;
         ai        = gameObject.GetComponent <EnemyAI2>();
     }
 }
Exemplo n.º 9
0
    void Start()
    {
        ps        = GetComponent <ParticleSystem>();
        anim      = GetComponent <Animator>();
        eh        = GetComponentInParent <EnemyHealth>();
        stunnable = GetComponentInParent <Stunnable>();
        ai        = GetComponentInParent <EnemyAI2>();

        StartCoroutine(StunRune());
    }
Exemplo n.º 10
0
    /**
     * Collider for laser prefab.
     * Upon contact with enemy, destroys itself with an explosion.
     */
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Enemy")
        {
            EnemyAI  enemy1 = other.GetComponent <EnemyAI>();
            EnemyAI2 enemy2 = other.GetComponent <EnemyAI2>();
            BossAI   boss1  = other.GetComponent <BossAI>();

            if (enemy1 != null || enemy2 != null || boss1 != null)
            {
                StartCoroutine(ExplosionRoutine());
            }
        }
    }
Exemplo n.º 11
0
    void Update()
    {
        enemy = GetComponent<EnemyAI2> ();
        if (oldmode != enemy.patrolmode) 				// if there is a change in mode
        {												//  swap bodies
            temp = current;
            Destroy (current);
            currPos = gameObject.transform.position; 	// get position and rotation of
            currQuart = gameObject.transform.rotation;	//  sphere

            if (enemy.patrolmode == false) 				// if in chase mode or running away
            {
                    current = GameObject.Instantiate (ghostChase, currPos, currQuart) as GameObject;
            }
            else
            {											// else if in patrol mode
                    current = GameObject.Instantiate (ghostNormal, currPos, currQuart) as GameObject;
            }
            current.transform.parent = gameObject.transform;	// Set ghostHead as ghostBody's parent
            current.AddComponent ("ClothMovement");				// Add ClothMovement script to ghost's body
            current.AddComponent("ColorTest");
            oldmode = enemy.patrolmode;
        }
    }
Exemplo n.º 12
0
 // Start is called before the first frame update
 void Start()
 {
     anim = GetComponent <Animator>();
     ai   = GetComponent <EnemyAI2>();
 }
Exemplo n.º 13
0
 void Start()
 {
     stats = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerStats>();
     eh    = GetComponent <EnemyHealth>();
     ai    = GetComponent <EnemyAI2>();
 }
Exemplo n.º 14
0
 void Start()
 {
     cc = GetComponent <CircleCollider2D>();
     ai = GetComponentInParent <EnemyAI2>();
     gs = GetComponentInParent <GoblinSpearman>();
 }
Exemplo n.º 15
0
 void Start()
 {
     bc     = GetComponent <BoxCollider2D>();
     ai     = GetComponentInParent <EnemyAI2>();
     parent = ai.gameObject;
 }
Exemplo n.º 16
0
 // Start is called before the first frame update
 void Start()
 {
     ai = GetComponent <EnemyAI2>();
     InvokeRepeating("CheckResurrection", 0f, 20f);
 }
Exemplo n.º 17
0
 void Start()
 {
     ai = GetComponentInParent <EnemyAI2>();
     cc = GetComponent <CircleCollider2D>();
 }
Exemplo n.º 18
0
 void Start()
 {
     ai             = GetComponent <EnemyAI2>();
     eh             = GetComponent <EnemyHealth>();
     circleCollider = GetComponent <CircleCollider2D>();
 }
Exemplo n.º 19
0
 // Start is called before the first frame update
 void Start()
 {
     ai = GetComponent <EnemyAI2>();
     dt = ai.dt;
 }
Exemplo n.º 20
0
 // Start is called before the first frame update
 void Start()
 {
     ai = GetComponent <EnemyAI2>();
 }