コード例 #1
0
 private void Start()
 {
     p      = father.GetComponent <Patrol>();
     s      = father.GetComponent <EnemyFollow>();
     rb     = father.GetComponent <Rigidbody2D>();
     seeing = false;
 }
コード例 #2
0
 void Start()
 {
     health = GetComponent <EnemyHealth>();
     follow = GetComponent <EnemyFollow>();
     slowed = false;
     dotted = false;
 }
コード例 #3
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        EnemyPatrol enemy = hitInfo.GetComponent <EnemyPatrol>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
        }

        Destroy(gameObject);

        EnemyFollow enemy1 = hitInfo.GetComponent <EnemyFollow>();

        if (enemy1 != null)
        {
            enemy1.TakeDamage(damage);
        }

        Destroy(gameObject);

        EnemyAttack enemy2 = hitInfo.GetComponent <EnemyAttack>();

        if (enemy2 != null)
        {
            enemy2.TakeDamage(damage);
        }

        Destroy(gameObject);
    }
コード例 #4
0
 void Awake()
 {
     EnemyStates._states = States.Wander;
     _anim         = GetComponent <Animator>();
     _enemyFollow  = GetComponent <EnemyFollow> ();
     _playerTarget = _enemyFollow.PlayerTarget;
 }
コード例 #5
0
 void Start()
 {
     rg = GetComponent <Rigidbody2D>();
     perceptionComponent = GetComponentInChildren <Perception>();
     patrol      = GetComponent <Patrol>();
     enemyFollow = GetComponent <EnemyFollow>();
 }
コード例 #6
0
    public void createPyramid(Vector3 position)
    {
        EnemyFollow pyramid_radar_point =
            GameObject.FindGameObjectWithTag("EndPointTrack").GetComponent <EnemyFollow>();
        Vector3 current_pos   = position;
        float   cube_height   = pyramid_height / pyramid_total_cubes;
        Vector3 current_scale = new Vector3(pyramid_base_width, cube_height, pyramid_base_width);
        float   size_delta    = pyramid_base_width / pyramid_total_cubes;

        for (int i = 0; i < pyramid_total_cubes; ++i)
        {
            pyramid_cubes[i]       = GameObject.CreatePrimitive(PrimitiveType.Cube);
            pyramid_cubes[i].tag   = "EndPoint";
            pyramid_cubes[i].layer = LayerMask.NameToLayer("EndPoint");
            pyramid_cubes[i].GetComponent <BoxCollider>().isTrigger = true;
            pyramid_cubes[i].GetComponent <Renderer>().material     = pyramid_material;

            pyramid_cubes[i].transform.position   = current_pos;
            pyramid_cubes[i].transform.localScale = current_scale;
            current_pos.y   -= cube_height;
            current_scale.x -= size_delta;
            current_scale.z -= size_delta;
        }
        pyramid_radar_point.enemy = pyramid_cubes[0].gameObject;
        pyramid_created           = true;
        rotate_start_time         = Time.time;
    }
コード例 #7
0
    private void SpawnEnemy()
    {
        Entity  enemy    = GameDataManager.instance.Manager.Instantiate(enemyPrefabEntity);
        Vector3 position = MathFormulas.RandomCircle(Vector3.zero, AllSettings.Instance.GameAreaEdgeDistance, UnityEngine.Random.Range(-180f, 180f));

        GameDataManager.instance.Manager.SetComponentData(enemy, new Translation {
            Value = position
        });
        GameDataManager.instance.Manager.SetComponentData(enemy, new EnemyData
        {
            HealthNum    = currentWaveEnemyHp.Number,
            HealthExpo   = currentWaveEnemyHp.Exponent,
            moveSpeed    = EnemyMoveSpeed,
            moveDistance = position.normalized,
            HpPercent    = 1,
            Position     = position
        });

        if (EnemySpriteQueue.Count == 0 || EnemySpriteQueue.Peek().following)
        {
            EnemyFollow enemySprite = Instantiate(EnemySpritePrefab).GetComponent <EnemyFollow>();
            enemySprite.NewEnemy(enemy);
            EnemySpriteQueue.Enqueue(enemySprite);
        }
        else
        {
            EnemyFollow enemySprite = EnemySpriteQueue.Dequeue();
            enemySprite.NewEnemy(enemy);
            EnemySpriteQueue.Enqueue(enemySprite);
        }
    }
コード例 #8
0
 void Awake()
 {
     _player       = GameObject.FindGameObjectWithTag("Player");
     _playerHealth = _player.GetComponent <PlayerHealth> ();
     _enemyFollow  = GetComponent <EnemyFollow> ();
     _anim         = GetComponent <Animator> ();
 }
コード例 #9
0
    public override void Start()
    {
        player      = GameObject.Find("Player");
        enemyFollow = self.GetComponent <EnemyFollow> ();

        // Find my target or create one
        if (enemyFollow.target == null)
        {
            target = new GameObject();
        }
        else
        {
            target = enemyFollow.target;
        }

        // Define attack positions (offsets from the player's position)
        rightPositions = new Vector3[] {
            new Vector3(1, 0, 0),              // Rpos0: right
            new Vector3(1, 1f, 0),             // Rpos1: right & up
            new Vector3(1, -1f, 0),            // Rpos2: right & down
            new Vector3(2f, 0, 0),             // Rpos3: right 2x
            new Vector3(2f, 1f, 0),            // Rpos4: right 2x & up
            new Vector3(2f, -1f, 0)            // Rpos5: right 2x & down
        };
        leftPositions = new Vector3[] {
            new Vector3(-1, 0, 0),             // Lpos0: left
            new Vector3(-1, 1f, 0),            // Lpos1: left & up
            new Vector3(-1, -1f, 0),           // Lpos2: left & down
            new Vector3(-2f, 0, 0),            // Lpos3: left 2x
            new Vector3(-2f, 1f, 0),           // Lpos4: left 2x & up
            new Vector3(-2f, -1f, 0)           // Lpos5: left 2x & down
        };
    }
コード例 #10
0
 private void Start()
 {
     gm          = GameManager.GetInstance();
     enemyFollow = GetComponent <EnemyFollow>();
     pteranodon  = GetComponent <Pteranodon>();
     spino       = GetComponent <SpinoEnemy>();
 }
コード例 #11
0
ファイル: EnemyFollow.cs プロジェクト: Petubow/3DPeliProjekti
 public void Start()
 {
     EnemyAnim = GetComponent <Animator>();
     EHealth   = GetComponent <Enemy>();
     ph        = player.GetComponent <PlayerHealth>();
     ef        = GetComponent <EnemyFollow>();
 }
コード例 #12
0
ファイル: Bullet.cs プロジェクト: Tommy030/Twin-Stick
    private void OnCollisionEnter(Collision collision)
    {
        if (!ShotByPlayer)
        {
            if (collision.gameObject.tag == "Player")
            {
                PlayerStats HP = collision.gameObject.GetComponent <PlayerStats>();
                PopUp();
                HP.ShotAt(Damage, Shotby);
            }

            gameObject.SetActive(false);
        }
        if (ShotByPlayer)
        {
            if (collision.collider.tag == "Enemy")
            {
                EnemyFollow Enemy = collision.gameObject.GetComponent <EnemyFollow>();
                Enemy.Stats.HP -= Damage;

                PopUp();
                StaticStats.Stats.Hit   += 1;
                StaticStats.Stats.Score += 100;



                gameObject.SetActive(false);
            }
            else if (collision.collider.gameObject.layer != 9)
            {
                gameObject.SetActive(false);
            }
        }
    }
コード例 #13
0
 public override void Start()
 {
     enemyFollow = self.GetComponent <EnemyFollow> ();
     player      = GameObject.Find("Player");
     xDistance   = 1f;
     yDistance   = 1f;
     grabber     = player.GetComponent <Grabber> ();
 }
コード例 #14
0
 // Use this for initialization
 override public void Start()
 {
     player                 = GameObject.Find("Player");
     movement               = self.GetComponent <Movement>();
     enemyFollow            = self.GetComponent <EnemyFollow> ();
     enemyFollow.targetType = EnemyFollow.TargetType.Null;
     camera                 = GameObject.Find("Main Camera").GetComponent <Camera>();
 }
コード例 #15
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Enemy")
     {
         GameObject Enemy = collision.gameObject;
         enemy = Enemy.GetComponent <EnemyFollow>();
     }
 }
コード例 #16
0
    public void SpawnFollowerFromSpawnPoint(int index)
    {
        Transform spawnPoint = spawnPoints[index];

        GameObject  temp = Instantiate(follower, spawnPoint.position, spawnPoint.rotation);
        EnemyFollow ef   = temp.GetComponent <EnemyFollow>();

        EnemyDict.Add(ef.enemyId, ef);
    }
コード例 #17
0
    void DamageEnemy(Collider2D collision)
    {
        EnemyFollow enemy = collision.GetComponent <EnemyFollow>();

        if (enemy)
        {
            enemy.TakeDamage(EnemyHitDamage);
        }
    }
コード例 #18
0
    void SpawnFollower()
    {
        int         randomIndex = Random.Range(0, spawnPoints.Length);
        Transform   spawnPoint  = spawnPoints[randomIndex];
        GameObject  temp        = Instantiate(follower, spawnPoint.position, spawnPoint.rotation);
        EnemyFollow ef          = temp.GetComponent <EnemyFollow>();

        EnemyDict.Add(ef.enemyId, ef);
    }
コード例 #19
0
 void Awake()
 {
     _rnd         = new System.Random();
     health      += _rnd.Next(additionalHealthFloor, additionalHealthCeiling + 1);
     playerAttack = GameObject.Find("Player").GetComponent <Attack>();
     _blackboard  = GetComponent <Blackboard>();
     _enemyFollow = GetComponent <EnemyFollow>();
     alive        = true;
     grabbed      = GetComponent <Grabbable>();
 }
コード例 #20
0
    void Awake()
    {
        _scale              = transform.localScale;
        _enemyStates        = GetComponent <EnemyStates> ();
        _enemyStates.states = States.Wander;
        _anim = GetComponent <Animator>();

        _enemyFollow  = GetComponent <EnemyFollow> ();
        _playerTarget = _enemyFollow.PlayerTarget;
    }
コード例 #21
0
 void Start()
 {
     rb     = GetComponent <Rigidbody2D>();
     target = GameObject.FindGameObjectWithTag("Enemy").GetComponent <EnemyFollow>();
     if (target)
     {
         moveDirection = (target.transform.position - transform.position).normalized;
         rb.velocity   = moveDirection * speed;
     }
 }
コード例 #22
0
    // Start is called before the first frame update
    void Start()
    {
        Follow = GetComponent <EnemyFollow>();
        Patrol = GetComponent <Patrol>();
        LoS    = GetComponent <EnemyLineOfSight>();

        Patrol.enabled = true;
        LoS.enabled    = true;
        Follow.enabled = false;
    }
コード例 #23
0
ファイル: EnemyControl.cs プロジェクト: agehm/Metanoia-2D
    private IEnumerator WaitForActiveFollow()
    {
        yield return(new WaitForSeconds(initialAnimationTime));

        EnemyFollow enemyFollow = GetComponent <EnemyFollow>();

        if (enemyFollow != null)
        {
            enemyFollow.Active = true;
        }
    }
コード例 #24
0
    // Use this for initialization
    void Start()
    {
        initialHealth = Random.Range(minHealth, maxHealth);
        currentHealth = initialHealth;
        healthbarSize = healthbar.sizeDelta.x;
        isAlive       = true;
        gameManager   = GameObject.Find("GameManager").GetComponent <GameManager>();
        enemyFollow   = GetComponent <EnemyFollow>();

        anim = GetComponentInChildren <Animator>();
    }
コード例 #25
0
 public override void Start()
 {
     timer                  = 0;
     duration               = 2.5f;
     player                 = GameObject.Find("Player");
     baseCollision          = self.GetComponent <BaseCollision> ();
     movement               = self.GetComponent <Movement> ();
     enemyFollow            = self.GetComponent <EnemyFollow> ();
     enemyFollow.targetType = EnemyFollow.TargetType.Null;
     camera                 = GameObject.Find("Main Camera").GetComponent <Camera>();
 }
コード例 #26
0
    IEnumerator Slow(Collider enemy)
    {
        EnemyFollow moveSpeed = enemy.GetComponent <EnemyFollow>();

        moveSpeed.moveSpeed -= multiplier;


        yield return(new WaitForSeconds(duration));

        moveSpeed.moveSpeed /= multiplier;
    }
コード例 #27
0
    override public void Start()
    {
        player                = GameObject.Find("Player");
        enemyFollow           = self.GetComponent <EnemyFollow> ();
        layerMask             = LayerMask.GetMask("Environment");
        baseCollision         = self.GetComponent <BaseCollision> ();
        movement              = self.GetComponent <Movement> ();
        diagonalMovementSpeed = (movement.horizontalMovementSpeed + movement.vericalMovementSpeed) / 2;

        // Stop following
        enemyFollow.targetType = EnemyFollow.TargetType.Null;
    }
コード例 #28
0
    public void OnCollisionEnter2D(Collision2D collision)
    {
        EnemyAttack enemyAttack = collision.collider.GetComponent <EnemyAttack>();
        EnemyFollow enemyFollow = collision.collider.GetComponent <EnemyFollow>();
        EnemyPatrol enemyPatrol = collision.collider.GetComponent <EnemyPatrol>();
        EnemyShoot  enemyShoot  = collision.collider.GetComponent <EnemyShoot>();

        if (health <= 0 || enemyPatrol != null || enemyAttack != null || enemyFollow != null || enemyShoot != null)
        {
            Destroy(gameObject);
            FindObjectOfType <GameManager>().GameOver();
        }
    }
コード例 #29
0
    private void Awake()
    {
        _animator   = GetComponent <Animator>();
        _movement   = GetComponent <Movement>();
        _movementAI = GetComponent <EnemyFollow>();

        _collision      = GetComponent <BaseCollision>();
        _characterState = GetComponent <CharacterState>();
        _knockDown      = GetComponent <KnockDown>();
        _myLayer        = gameObject.layer;
        _blackboard     = GetComponent <Blackboard> ();

        wasThrown = false;
    }
コード例 #30
0
 override public void Start()
 {
     player      = GameObject.Find("Player");
     enemyFollow = self.GetComponent <EnemyFollow> ();
     if (enemyFollow.target != null)
     {
         target = enemyFollow.target;
     }
     else
     {
         target = player;
     }
     layerMask = LayerMask.GetMask("Environment");
 }