示例#1
0
    ///<summary>
    /// Spawns a pistol enemy
    ///</summary>
    private void SpawnEnemyPistol()
    {
        Enemy_Controller enemy = Instantiate(enemyPistol, GetSpawnPosition(), transform.rotation)
                                 .GetComponent <Enemy_Controller>();

        enemy.onEnemyDeath += EnemyPistolDeath;
    }
示例#2
0
    void Shoot()
    {
        sound.Play();
        particle.Play();
        RaycastHit hit;

        if (Physics.Raycast(player.position, player.forward, out hit, range))
        {
            Debug.Log(hit.transform.name);
            Enemy_Controller    target         = hit.transform.GetComponent <Enemy_Controller>();
            Minotaur_Controller targetMinotaur = hit.transform.GetComponent <Minotaur_Controller>();
            Boss_Controller     targetBoss     = hit.transform.GetComponent <Boss_Controller>();
            if (target != null)
            {
                target.TakeDamage(damage);
            }
            if (targetMinotaur != null)
            {
                targetMinotaur.TakeDamage(damage);
            }
            if (targetBoss != null)
            {
                targetBoss.TakeDamage(damage);
            }
        }
    }
    void Attack(Slashing slash)
    {
        int numVictims = Physics2D.LinecastNonAlloc(slash.startPoint, slash.endPoint, slashResults, slashMask);

        for (int i = 0; i < numVictims; i++)
        {
            Enemy_Controller victim = slashResults[i].collider.GetComponent <Enemy_Controller>();

            if (victim.InputUserSlash((slash.endPoint - slash.startPoint).normalized))
            {
                // hit
                UISlashShow.Slash(Vector2.Lerp(slash.endPoint, slash.startPoint, 0.5f), (slash.endPoint - slash.startPoint).normalized);
                if (victim.CompareTag("BasicEnemy"))
                {
                    Player_Controller.instance.Attack(victim);
                }
            }
            else
            {
                if (victim.CompareTag("BasicEnemy"))
                {
                    Player_Controller.instance.Attack(victim);
                }
            }
        }
    }
 public EnemyState(Enemy_Controller enemyController)
 {
     enemy  = enemyController;
     grid   = GameObject.FindGameObjectWithTag(Tags.World).GetComponent <World>().grid;
     player = GameObject.FindGameObjectWithTag(Tags.Player);
     route  = new LinkedList <Location>();
 }
 public void Attack(Enemy_Controller victim)
 {
     if (!victims.Contains(victim))
     {
         victims.Add(victim);
     }
 }
	// Use this for initialization
	void Start () {
		rbd2D = GetComponent<Rigidbody2D> ();
		anim = GetComponent<Animator> ();
		aL = (Arrow_Launch)FindObjectOfType (typeof(Arrow_Launch));
		directEnemy = (Enemy_Controller)FindObjectOfType (typeof(Enemy_Controller));
		pStatus = (Player_Status)FindObjectOfType (typeof(Player_Status));
	}
示例#7
0
 public ChaseState(Enemy_Controller enemyController) : base(enemyController)
 {
     enemy       = enemyController;
     grid        = GameObject.FindGameObjectWithTag(Tags.World).GetComponent <World>().grid;
     player      = GameObject.FindGameObjectWithTag(Tags.Player);
     previousPos = enemy.transform.position;
     isDone      = true;
 }
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (Input.GetMouseButtonDown(0) && collision.CompareTag("Enemy"))
     {
         Enemy_Controller E_C = collision.gameObject.GetComponent <Enemy_Controller>();
         E_C.TakeDamage(damage);
     }
 }
示例#9
0
    //private Enemy_Controller enemy;
    //GameObject player;

    public PatrolState(Enemy_Controller enemyController) : base(enemyController)
    {
        enemy           = enemyController;
        nextPatrolPoint = 1;
        if (enemy.patrolPoints.Length > 0)
        {
            patrol();
        }
        previousPos = enemy.transform.position;
    }
示例#10
0
 void Update()
 {
     timer += Time.deltaTime;
     if ((timer > spawnRate) && (spawns.Count < spawnLimit))
     {
         timer = 0.0f;
         Enemy_Controller spawn = Instantiate(spawnType, transform.position, Quaternion.identity);
         spawn.Spawner = this;
         spawns.Add(spawn);
     }
 }
    public static void LoseScenario(Enemy_Controller killer)
    {
        isGameOver = true;

        instance.enabled             = false;
        instance.waveSpawner.enabled = false;

        StopScrollingScenery();

        Enemy_Controller.LoseScenario(killer);
        Player_Controller.LoseScenario(killer);
    }
示例#12
0
    public void OnTriggerEnter(Collider other)
    {
        enemyControl = GameObject.Find("EnemyTrial").GetComponent <Enemy_Controller>();

        if (other.tag == "Player")
        {
            enemyControl.enemy.theEnemyFront = Enemy_View.CharacterViewFront.right;
            enemyControl.transform.Rotate(0, 90, 0);

            Debug.Log("ve a la derecha");
        }
    }
    public static void LoseScenario(Enemy_Controller killer)
    {
        isGameOver = true;

        instance.enabled = false;
        instance.waveSpawner.enabled = false;

        StopScrollingScenery();

        Enemy_Controller.LoseScenario(killer);
        Player_Controller.LoseScenario(killer);
    }
 /// <summary>
 /// Adds an Enemy to the Enemy pool
 /// </summary>
 /// <param name="enemy">The Enemy object to add to the Enemy pool</param>
 public void addToPool(Enemy_Controller enemy)
 {
     if (head == null)
     {
         head = enemy;
         tail = enemy;
     }
     else
     {
         tail.next = enemy;
         tail      = enemy;
     }
 }
    public static void LoseScenario(Enemy_Controller killer)
    {
        instance.enabled = false;
        instance.StopAllCoroutines();

        if(killer.CompareTag("BasicEnemy")){
            instance.transform.position = killer.player_attack_position.position;

            instance.animator.SetTrigger("StopDash");

            StopRunning();
        }
    }
示例#16
0
    void OnCollisionEnter2D(Collision2D other)
    {
        Enemy_Controller enemy = other.collider.GetComponent <Enemy_Controller>();

        if (enemy != null)
        {
            enemy.Fix();
        }

        //sents message to terminal to confirm collision
        Debug.Log("Projectile collision with" + other.gameObject);
        Destroy(gameObject);
    }
    public static void LoseScenario(Enemy_Controller killer)
    {
        instance.enabled = false;
        instance.StopAllCoroutines();

        if (killer.CompareTag("BasicEnemy"))
        {
            instance.transform.position = killer.player_attack_position.position;

            instance.animator.SetTrigger("StopDash");

            StopRunning();
        }
    }
示例#18
0
    void Update()
    {
        Enemy_Controller me = gameObject.GetComponent <Enemy_Controller>();

        health = me.health;
        if (health <= healthToSpawn && didSpawn)
        {
            foreach (var ally in allies)
            {
                ally.SetActive(true);
            }
            didSpawn = false;
        }
    }
示例#19
0
    void OnTriggerEnter2D(Collider2D col)
    {
        // Assigning gameObjects with the EnemyController script the 'col' variable so only they can trigger this function
        Enemy_Controller enemy = col.GetComponent <Enemy_Controller>();

        Debug.Log(col.name);

        // Checking if enemy exists, then enemy takes damage.
        if (enemy != null)
        {
            enemy.TakeDamage(20);
        }
        Destroy(gameObject);
    }
 private void OnCollisionEnter2D(Collision2D collision)
 {
     {
         if (collision.gameObject.CompareTag("Other"))
         {
             Destroy(gameObject);
         }
         if (collision.gameObject.CompareTag("Enemy") && !enemyBullet)
         {
             Enemy_Controller E_C = collision.gameObject.GetComponent <Enemy_Controller>();
             E_C.TakeDamage(damage);
             Destroy(gameObject);
         }
     }
 }
示例#21
0
    // Start is called before the first frame update
    void Start()
    {
        target        = GameObject.FindObjectOfType <Player_Controller>();
        enemy         = GameObject.FindObjectOfType <Enemy_Controller>();
        moveDirection = (target.transform.position - transform.position).normalized;
        Debug.Log(moveDirection);

        rb.velocity = new Vector2(velocity.x, velocity.y);

        Debug.Log(enemy.transform.localScale.x);


        //Debug.DrawRay(transform.position, moveDirection, Color.green, 1);
        Destroy(gameObject, (float)2.5);
    }
示例#22
0
        void restartKinematics(int i)
        {
            GameObject car = cars [i];

            car.GetComponent <Rigidbody> ().isKinematic = true;
            car.GetComponent <Rigidbody> ().isKinematic = false;
            if (i < 3)
            {
                CarController cc = car.GetComponent <CarController> ();
                cc.restartWheels();
            }
            else
            {
                Enemy_Controller ec = car.GetComponent <Enemy_Controller> ();
                ec.restartWheels();
            }
        }
    /*
    public bool DidUserKillEnemy(){

        float angle = Vector2.Angle(userInputDir, killDir);

        if(angle <= killAngleDeathzone){
            animator.Play(State_die, 0, 0.0f);
            GetComponent<SpriteRenderer>().sortingOrder = -1;

            Sounds_dying.PlaySound();
            Sounds_gore.PlaySound();

            Destroy(gameObject, 1.0f);
            return true;
        }else{
            Game_Controller.LoseScenario(this);
            return false;
        }
    }
    */
    /// <summary>
    /// called by Game_Controller
    /// </summary>
    /// <param name="killer">Killer.</param>
    public static void LoseScenario(Enemy_Controller killer)
    {
        BasicEnemy_Controller basicGuy = null;

        foreach(Enemy_Controller wolf in controllers){

            if(wolf.CompareTag("BasicEnemy")){

                basicGuy = (BasicEnemy_Controller) wolf;
                basicGuy.LoseScenario_Called(killer);
            }else{
                //MiniBoss_Controller miniBoss = (MiniBoss_Controller) wolf;

                Player_Controller.PlayDeath();
            }

        }
    }
示例#24
0
    /*
     * public bool DidUserKillEnemy(){
     *
     *      float angle = Vector2.Angle(userInputDir, killDir);
     *
     *      if(angle <= killAngleDeathzone){
     *              animator.Play(State_die, 0, 0.0f);
     *              GetComponent<SpriteRenderer>().sortingOrder = -1;
     *
     *              Sounds_dying.PlaySound();
     *              Sounds_gore.PlaySound();
     *
     *              Destroy(gameObject, 1.0f);
     *              return true;
     *      }else{
     *              Game_Controller.LoseScenario(this);
     *              return false;
     *      }
     * }
     */

    /// <summary>
    /// called by Game_Controller
    /// </summary>
    /// <param name="killer">Killer.</param>

    public static void LoseScenario(Enemy_Controller killer)
    {
        BasicEnemy_Controller basicGuy = null;

        foreach (Enemy_Controller wolf in controllers)
        {
            if (wolf.CompareTag("BasicEnemy"))
            {
                basicGuy = (BasicEnemy_Controller)wolf;
                basicGuy.LoseScenario_Called(killer);
            }
            else
            {
                //MiniBoss_Controller miniBoss = (MiniBoss_Controller) wolf;

                Player_Controller.PlayDeath();
            }
        }
    }
示例#25
0
 public void setStiffness(float value)
 {
     for (int i = 0; i < 12; i++)
     {
         if (cars[i] != null)
         {
             if (i < 3)
             {
                 CarController cc = cars [i].gameObject.GetComponent <CarController> ();
                 cc.setStiffness(value);
             }
             else
             {
                 Enemy_Controller ec = cars [i].gameObject.GetComponent <Enemy_Controller> ();
                 ec.setStiffness(value);
             }
         }
     }
 }
    // Checks if there is a collision between the player and any enemies
    void OnCollisionEnter2D(Collision2D collision)
    {
        Enemy_Controller enemy = collision.collider.GetComponent <Enemy_Controller>();

        if (enemy != null)
        {
            bool enemyHurt = false;
            enemyLayer = collision.gameObject.layer;
            foreach (ContactPoint2D point in collision.contacts)
            {
                if (point.normal.y >= 0.9f)
                {
                    Vector2 velocity = myBody.velocity;
                    velocity.y      = jumpForce / 2;
                    myBody.velocity = velocity;
                    enemy.Hurt();
                    enemyHurt = true;
                }
            }
            if (!enemyHurt && !isShielded)
            {
                Hurt();
            }
            if (isShielded)
            {
                // Ignore layer "Enemy"
                Physics2D.IgnoreLayerCollision(enemyLayer, gameObject.layer, true);
            }
        }

        if (collision.collider.tag == "Kill zone")
        {
            Application.LoadLevel("Game over");
        }
        // TODO: Fix so that the player doesn't die when getting hit by falling objects.
    }
示例#27
0
 public FleeState(Enemy_Controller enemyController) : base(enemyController)
 {
     enemy = enemyController;
 }
    private float _currentHitDistance;                    //Расстояние от нашего противника до объекта который попал в радиус нашей окружности.

    private void Start()
    {
        _enemy_Controller = GetComponent <Enemy_Controller>();//Передаём компонент Enemy_Controller для дальнейшей работы.
    }
示例#29
0
 private void Awake()
 {
     enemy = GetComponentInParent <Enemy_Controller>();
 }
示例#30
0
 // Use this for initialization
 void Awake()
 {
     enemycontroller = GameObject.FindWithTag("Enemy").GetComponent<Enemy_Controller>();
 }
示例#31
0
 public GuardState(Enemy_Controller enemyController) : base(enemyController)
 {
     enemy = enemyController;
 }
 /// <summary>
 /// Adds an Enemy to the Enemy pool
 /// </summary>
 /// <param name="enemy">The Enemy object to add to the Enemy pool</param>
 public void addToPool(Enemy_Controller enemy)
 {
     if(head == null)
     {
         head = enemy;
         tail = enemy;
     }
     else
     {
         tail.next = enemy;
         tail = enemy;
     }
 }
示例#33
0
 public SearchState(Enemy_Controller enemyController) : base(enemyController)
 {
     enemy          = enemyController;
     rotationAmount = 90.0f;
 }
	// Use this for initialization
	void Start () 
	{
		myController = GetComponentInParent<Enemy_Controller>();
	}
 public AttackState(Enemy_Controller enemyController) : base(enemyController)
 {
     enemy         = enemyController;
     inCover       = true; // set to true until cover mechanic implemented and the default to false
     fireRateTimer = 0;
 }
    /// <summary>
    /// Spawns an enemy
    /// Uses the Enemy Pool, if it isn't empty (head != null)
    /// </summary>
    private void spawnEnemy()
    {
        //Retrieve enemy to spawn
        Enemy_Controller enemyToSpawn;

        //If the Enemy pool isn't empty, get it there
        if (head != null)
        {
            head.gameObject.SetActive(true);
            enemyToSpawn      = head;
            head              = head.next;
            enemyToSpawn.next = null;
        }//Otherwise, make a new enemy
        else
        {
            enemyToSpawn = (Instantiate(EnemyPrefab, transform.position, Quaternion.identity) as GameObject).GetComponent <Enemy_Controller>();
        }
        Enemy_Controller.EnemyType type = Enemy_Controller.EnemyType.Simple;
        //Determine the Enemy type based on wave number and a bit of randomness
        if (wave == 1)
        {
            type = Enemy_Controller.EnemyType.Simple;
        }
        else if (wave < 4)
        {
            int temp = (int)Mathf.Round(Random.Range(0.0f, 0.6f + (0.2f * (wave - 2))));
            if (temp == 1)
            {
                type = Enemy_Controller.EnemyType.Sin;
            }
        }
        else if (wave < 7)
        {
            int temp = (int)Random.Range(0.0f, 2.25f + (0.2f * (wave - 2)));
            if (temp == 1)
            {
                type = Enemy_Controller.EnemyType.Sin;
            }
            else if (temp == 2)
            {
                type = Enemy_Controller.EnemyType.Traveler;
            }
        }
        else
        {
            int temp = (int)Random.Range(0.0f, 3.25f + (0.2f * (wave - 7)));
            if (temp > 3)
            {
                temp = (wave * temp) % 4;
            }
            if (temp == 1)
            {
                type = Enemy_Controller.EnemyType.Sin;
            }
            else if (temp == 2)
            {
                type = Enemy_Controller.EnemyType.Traveler;
            }
            else if (temp == 3)
            {
                type = Enemy_Controller.EnemyType.Chaser;
            }
        }
        //Setup the enemy and have it start
        enemyToSpawn.setUpEnemy(type, wave, halfWindowSize);
    }
 /// <summary>
 /// Spawns an enemy
 /// Uses the Enemy Pool, if it isn't empty (head != null)
 /// </summary>
 private void spawnEnemy()
 {
     //Retrieve enemy to spawn
     Enemy_Controller enemyToSpawn;
     //If the Enemy pool isn't empty, get it there
     if(head != null)
     {
         head.gameObject.SetActive(true);
         enemyToSpawn = head;
         head = head.next;
         enemyToSpawn.next = null;
     }//Otherwise, make a new enemy
     else
     {
         enemyToSpawn = (Instantiate(EnemyPrefab, transform.position, Quaternion.identity) as GameObject).GetComponent<Enemy_Controller>();
     }
     Enemy_Controller.EnemyType type = Enemy_Controller.EnemyType.Simple;
     //Determine the Enemy type based on wave number and a bit of randomness
     if(wave == 1)
     {
         type = Enemy_Controller.EnemyType.Simple;
     }
     else if(wave < 4)
     {
         int temp = (int)Mathf.Round(Random.Range(0.0f, 0.6f + (0.2f * (wave - 2))));
         if(temp == 1)
         {
             type = Enemy_Controller.EnemyType.Sin;
         }
     }
     else if(wave < 7)
     {
         int temp = (int)Random.Range(0.0f, 2.25f + (0.2f * (wave - 2)));
         if (temp == 1)
         {
             type = Enemy_Controller.EnemyType.Sin;
         }
        else if (temp == 2)
         {
             type = Enemy_Controller.EnemyType.Traveler;
         }
     }
     else
     {
         int temp = (int)Random.Range(0.0f, 3.25f + (0.2f * (wave - 7)));
         if(temp > 3)
         {
             temp = (wave * temp) % 4;
         }
         if (temp == 1)
         {
             type = Enemy_Controller.EnemyType.Sin;
         }
         else if (temp == 2)
         {
             type = Enemy_Controller.EnemyType.Traveler;
         }
         else if (temp == 3)
         {
             type = Enemy_Controller.EnemyType.Chaser;
         }
     }
     //Setup the enemy and have it start
     enemyToSpawn.setUpEnemy(type, wave, halfWindowSize);
 }
 public void Attack(Enemy_Controller victim)
 {
     if(!victims.Contains(victim))
         victims.Add(victim);
 }
示例#39
0
 // Use this for initialization
 void Start()
 {
     myController = GetComponentInParent <Enemy_Controller>();
 }