示例#1
0
    void Start()
    {
        Error();

        if (node)
        {
            spawn = node.GetComponent <spawnSoul> ();
            if (!spawn)
            {
                Debug.LogError("spawn (node) is null (pathFinding)");
            }

            StartCoroutine(WaitStart());
            InvokeRepeating("UpdateTarget", timeStart, timeRepeat);
        }

        enemy = GetComponent <enemyController> ();
        if (!enemy)
        {
            Debug.LogError("enemy (enemyController) is null (pathFinding)");
        }

        rotate  = transform.eulerAngles.z;
        isStart = false;

        path  = new List <tileMap.Node> ();
        open  = new List <tileMap.Node> ();
        close = new List <tileMap.Node> ();
    }
示例#2
0
 // Use this for initialization
 void Start()
 {
     if (GetComponent <enemyController>() is enemyController)
     {
         thisController = GetComponent <enemyController>();
     }
 }
示例#3
0
 // Awake func.
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
示例#4
0
    void Start()
    {
        GameObject enemyControllerObject = GameObject.FindWithTag("enemyController");

        if (enemyControllerObject != null)
        {
            con = enemyControllerObject.GetComponent <enemyController> ();
        }
        else
        {
            Debug.Log("找不到tag为enemyController的对象");
        }

        if (con == null)
        {
            Debug.Log("找不到 enemyController 脚本");
        }

        GameObject gameControllerObject = GameObject.FindWithTag("gameController");

        if (gameControllerObject != null)
        {
            game = gameControllerObject.GetComponent <gameController>();
        }
        else
        {
            Debug.Log("找不到tag为GameController的对象");
        }

        if (game == null)
        {
            Debug.Log("找不到 GameController 脚本");
        }
    }
    public void killEnemy(int enemyIndex)
    {
        enemyController enemy = enemyParty[enemyIndex].GetComponent <enemyController>();

        coinsWon          += enemy.coinsDropped;
        EXPEarned         += enemy.EXPValue;
        skillPointsGained += enemy.skillPointValue;
        determineDrops(enemy);

        foreach (GameObject target in targetsList)
        {
            Destroy(target);
        }
        numTargets = 0;
        targets.Remove(enemy.gameObject);
        Destroy(enemyParty[enemyIndex]);
        enemyParty.RemoveAt(enemyIndex);
        numEnemies--;

        if (numEnemies == 0)
        {
            endBattle();
        }

        loadTargets();
    }
示例#6
0
    void OnTriggerEnter2D(Collider2D other)
    {
        Obstacle        obstacle = other.GetComponent <Obstacle>();
        enemyController enemy    = other.GetComponent <enemyController>();

        if (obstacle != null) // if other is an obstacle, the folowing will play the correct sound clip and play the impact effect for the bullet. And make the obstacle take damage
        {
            Vector3 sound;
            sound.x = 0;
            sound.y = 0;
            sound.z = 0;
            AudioSource.PlayClipAtPoint(impactSound, sound, 0.7f);
            GameObject impact = Instantiate(impactEffect, transform.position, transform.rotation);
            obstacle.TakeDamage(damage);
            Destroy(gameObject);
            Destroy(impact, 0.05f);
        }
        if (enemy != null)   // if other is an enemy, the folowing will play the correct sound clip and play the impact effect for the bullet. And make the enemy take damage
        {
            Vector3 sound;
            sound.x = 0;
            sound.y = 0;
            sound.z = 0;
            AudioSource.PlayClipAtPoint(impactSound, sound, 0.7f);
            GameObject impact = Instantiate(impactEffect, transform.position, transform.rotation);
            enemy.TakeDamage(damage);
            Destroy(gameObject);
            Destroy(impact, 0.05f);
        }
    }
    private int index;                      //Seçili indis değerini tutacağız.

    void Awake()                            //Tetikleyici Metot instance yoksa oluşturuyor.
    {
        if (instance == null)               //objemizin değeri null ise referansını this ile veriyoruz.
        {
            instance = this;
        }
    }
 void Start()
 {
     currentHealth = maxHealth;
     healthBar.SetMaxHealth(maxHealth);
     activateRagdoll = GetComponent <ActivateRagdoll>();
     enemyController = GameObject.FindGameObjectWithTag("enemy").GetComponent <enemyController>();
     damageOverlay   = GameObject.Find("DamageOverlay").GetComponent <CanvasGroup>();
     PlayerCanDie    = true;
 }
 void Start()
 {
     enemyCont = GetComponent <enemyController>();
     if (enemyCont == null)
     {
         this.gameObject.AddComponent <enemyController>();
     }
     playerPos = GameControllerManager.getGameControllerManager().getPlayer().transform;
 }
示例#10
0
    //public bool isFlyer;
    //this is a statemachine that is attached to the enraged animation - it now handles movement toward the player.


    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        playerPos = GameObject.FindGameObjectWithTag("Player").transform;
        enemy     = animator.GetComponent <enemyController>();
        if (enemy.isFlyer == true)
        {
            enemy.SetGravity(0f);
        }
    }
示例#11
0
    public void createEnemy()
    {
        GameObject e = Instantiate(enemy,
                                   new Vector2(transform.position.x,
                                               transform.position.y - 1.0f),
                                   Quaternion.identity);
        enemyController enemyController = e.GetComponent <enemyController> ();

        enemyController.go(xSpeed, ySpeed);
    }
示例#12
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     enemy = animator.GetComponent <enemyController>();
     enemy.RunPatrolWait();
     enemy.RunFlipWait();
     if (enemy.isFlyer == true)
     {
         enemy.SetGravity(0f);
     }
 }
 // Start is called before the first frame update
 void Start()
 {
     rb         = gameObject.GetComponent <Rigidbody>();
     render     = gameObject.GetComponent <Renderer>();
     anim       = gameObject.GetComponentInChildren <Animator>();
     player     = GameObject.FindGameObjectWithTag("Player");
     NavMesh    = GetComponent <NavMeshAgent>();
     controller = GetComponent <enemyController>();
     getat      = GameObject.FindGameObjectWithTag("Player").GetComponent <Attacking>();
 }
示例#14
0
 public void determineDrops(enemyController enemy)
 {
     for (int i = 0; i < enemy.drops.Length; i++)
     {
         float random = Random.Range(0, 100);
         if (random <= enemy.dropRates[i])
         {
             drops.Add(enemy.drops[i]);
         }
     }
 }
示例#15
0
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.tag == "Enemy")
        {
            // Insert damage logic
            enemyController enemycontroller = col.gameObject.GetComponent <enemyController>();
            enemycontroller.takeDamage(bulletDamage);
        }

        Destroy(this.gameObject);
    }
示例#16
0
    private void OnTriggerEnter(Collider hitInfo)
    {
        enemyController enemy = hitInfo.GetComponent <enemyController>();

        if (enemy != null)
        {
            enemy.takeDamage(damage);
        }
        Debug.Log(hitInfo.name);
        Destroy(gameObject);
    }
示例#17
0
    // Update is called once per frame
    void Update()
    {
        if (timer <= 0f)
        {
            enemyController mob = Instantiate(spawningMob, this.transform);
            mob.target = player.transform;
            //Debug.Log("Mob Spawned");
            timer = 15f;
        }

        timer -= Time.deltaTime;
    }
    //start function, gets enemy parent, sets damage, and the attack and fire rates
    void Start()
    {
        thisEnemy = GetComponentInParent <enemyController>();

        damage = 0;

        attackRate = 1.0f;                                                                            //fire rate is set to 0.5.
        nextAttack = attackRate;                                                                      //next shot is set to the fire rate.

        fireRate = 1.0f;                                                                              //fire rate is set to 0.5.
        nextShot = attackRate;                                                                        //next shot is set to the fire rate.
    }
示例#19
0
    //public bool startRoof;

    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        enemy = animator.GetComponent <enemyController>();
        if (enemy.startOnRoof == false)
        {
            enemy.SetGravity(1f);
            enemy.RunIdleWait();
            enemy.RunFlipWait();
        }
        else
        {
            enemy.SetGravity(-1f);
        }
    }
示例#20
0
    //detects if hit an enemy, and tells the enemyController how much damage to take
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        enemyController enemy = hitInfo.GetComponent <enemyController>();
        bossController  boss  = hitInfo.GetComponent <bossController>();

        if (enemy != null)
        {
            enemy.TakeDamage(totalDamage);
        }
        else if (boss != null)
        {
            boss.TakeDamage(totalDamage);
        }
    }
示例#21
0
    void spawn()
    {
        if (skeletorList.Count <= 20)
        {
            GameObject newSkeletor = Instantiate(skeletor, m_current_transform.position + new Vector3(0.0f, 0.0f, -5.0f), skeletor.transform.rotation);
            skeletorList.Add(newSkeletor);
            //newSkeletor.transform.position = target.position;
            newSkeletor.name = "Spawned Skeletor";

            Rigidbody       enemyRigidbody = newSkeletor.GetComponent <Rigidbody> ();
            enemyController eC             = newSkeletor.GetComponent <enemyController> ();
            eC.startEnemy();
            eC.target = target.transform;
        }
    }
    void Start()
    {
        ec = parent.GetComponent<enemyController>();
        //make a new box collider that's the size of parent objects (the enemy) current one
        attackArea = GetComponent<BoxCollider2D>();
        Vector2 newSize = new Vector2(parent.GetComponent<BoxCollider2D>().size.x * 3/4, parent.GetComponent<BoxCollider2D>().size.y);

        //offset is used to make sure the new collider is facing in front of the object
        offset = 1;
        if (ec.facing()) offset = -1;
        Vector2 newOffset = new Vector2(attackArea.size.x * offset, 0.0f);

        attackArea.size = newSize;
        attackArea.offset = newOffset;
    }
示例#23
0
    // Use this for initialization
    void Start()
    {
        gm = GameObject.FindGameObjectWithTag("GameController");

        playerGO = GameObject.FindGameObjectWithTag("Player");
        playerT  = playerGO.transform;

        eC     = GetComponentInParent <enemyController> ();
        damage = weapon.weaponDamageAmount;
        //fireRate = weapon.fireRate;

        countDown       = Random.Range(shotTimerMin, shotTimerMax);
        enemyClipAmount = originalClipAmount;

        doReload = false;
    }
示例#24
0
    void OnTriggerStay(Collider other)
    {
        // Debug.Log(other.gameObject); // Change to a bool.
        if (other.gameObject.tag == "enemy")
        {
            // Debug.Log(other.gameObject); // Change to a bool.
            weaponColliding = true;

            // Get the enemy being struck
            enemy_controller = other.gameObject.GetComponentInParent <enemyController>();
            enemy_controller.hitEnemy(swordDamage, swingNum);
            int hitPoints = enemy_controller.getHitPoints();
            Debug.Log(hitPoints);
        }
        else
        {
            weaponColliding = false;
        }
    }
示例#25
0
    void OnCollisionEnter(Collision other)
    {
        // フィールドオブジェクトにあたった場合跳ね返る
        if (other.gameObject.tag == "NotBreakObject")
        {
            Velocity = Vector3.Reflect(Velocity, new Vector3(-1f, 0f, 0f));
        }        // if


        if (other.gameObject.tag == "Enemy" && State == ITEM_SHOOT_STATE.SHOOT)
        {
            enemyController ec = other.collider.GetComponent("enemyController") as enemyController;
            ec.Velocity = new Vector3(-0.1f, 0.1f, 0.1f);
        }
        if (other.gameObject.tag == "ItemShoot")
        {
            Destroy(other.gameObject);
        }
    }
示例#26
0
    void OnTriggerExit(Collider coll)
    {
        //Debug.Log(coll.gameObject.tag);
        if (coll.gameObject.tag == "Bolt" || coll.gameObject.tag == "enemyBullet")
        {
            Destroy(coll.gameObject);
        }
        else if (coll.gameObject.tag == "enemy")
        {
            GameObject go = GameObject.Find("enemy");
            if (go != null)
            {
                m_enemyController = go.GetComponent <enemyController>();
                m_enemyController.SetEnemyStatus(false);
            }

            Destroy(coll.gameObject);
        }
    }
示例#27
0
 // Update is called once per frame
 void Update()
 {
     if (timerSpawn.ElapsedMilliseconds > timeSpawn * 1000)
     {
         if (typeNME == "buff")
         {
             enemyController temp = Instantiate(enemyPrefab1, this.gameObject.transform.position, Quaternion.identity);
             temp.player       = player;
             temp.destinations = wayPoints;
         }
         else if (typeNME == "kamikaze")
         {
             enemyController temp = Instantiate(enemyPrefab2, this.gameObject.transform.position, Quaternion.identity);
             temp.player       = player;
             temp.destinations = wayPoints;
         }
         DestroyImmediate(this.gameObject);
     }
 }
 private void Start()
 {
     enemyCont = GetComponent <enemyController>();
     if (enemyCont == null)
     {
         enemyCont = this.gameObject.AddComponent <enemyController>();
         Debug.LogWarning("Te has dejau de poner el enemyController crack");
     }
     playerPos = GameControllerManager.getGameControllerManager().getPlayer().transform;
     if (Random.Range(0f, 1.0f) >= 0.5)
     {
         signRand = 1;
     }
     else
     {
         signRand = -1;
     }
     totalTime = Random.Range(0f, 10f);
 }
示例#29
0
    private IEnumerator BasicAttack()
    {
        damage    = 10;
        canAttack = false;
        canMove   = false;
        //Attack Animation
        anim.SetBool("isPunching", true);

        //Send raycast to get objects in line
        RaycastHit2D hit;

        if (direction == 1)
        {
            hit = Physics2D.Raycast(transform.position + new Vector3(0, 1, 0), transform.right, attackRange, layermask);
        }
        else
        {
            hit = Physics2D.Raycast(transform.position + new Vector3(0, -1, 0), -transform.right, attackRange, layermask);
        }
        if (hit.collider != null)
        {
            if (hit.collider.tag == "Enemy")
            {
                //my enemy controller for now
                enemyController enemy = hit.collider.GetComponent <enemyController>();
                enemy.HP -= damage;

                //can I implement knockback?
                enemy.GetComponentInParent <Rigidbody2D>().AddForce(direction * knockback);
            }
        }
        attackTimer = Time.fixedTime + attackSpeed;
        while (attackTimer > Time.fixedTime)
        {
            yield return(null);
        }
        anim.SetBool("isPunching", false);
        canAttack = true;
        canMove   = true;
        yield return(null);
    }
示例#30
0
    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            RaycastHit hit;

            if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity) && hit.collider.tag == "Enemy")
            {
                Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 100, Color.green);
                Instantiate(explosionPrefab, hit.point, Quaternion.identity);
                enemyController enemyController = hit.collider.GetComponent <enemyController> ();
                if (enemyController != null)
                {
                    enemyController.takeDamage(1);
                }
            }
            else
            {
                Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 100, Color.green);
            }
        }
    }
示例#31
0
 // Might have to queue up the damage.
 void OnTriggerEnter(Collider other)
 {
     // Debug.Log(other.gameObject);
     // Debug.Log(other.gameObject.tag);
     if (other.gameObject.tag == "enemy" || other.gameObject.tag == "enemy_col")
     {
         Debug.Log(other); // Change to a bool.
         // Get the enemy being struck
         enemyController enemy_controller = other.gameObject.GetComponentInParent <enemyController>();
         if (enemy_controller.checkForActiveFrames())
         {
             takeDamage(enemy_controller.attackDamage());
             // gotHit = true;
             // enemyDamage = enemy_controller.attackDamage();
             // enemy_controller.unTriggerColliders();
         }
     }
     else if (other.gameObject.tag == "duck") // Just for fun. Fix it.
     {
         Vector3 duckVelocity = other.gameObject.transform.forward * duckVel;
         other.gameObject.transform.rotation = this.transform.rotation;
         other.gameObject.GetComponent <CharacterController>().Move(duckVelocity * Time.deltaTime);
     }
 }