private void Start()
    {
        player         = GameObject.FindWithTag("Player");
        DetectRange    = 70.0f;
        enemyDetection = player.GetComponent <EnemyDetection>();
        healthBar      = gameObject.transform.Find("EnemyHealth/HealthBar").gameObject.GetComponent <Slider>();
        if (gameObject.transform.Find("guitar"))
        {
            guitar = gameObject.transform.Find("guitar").gameObject;
        }
        maxHealth          = health;
        healthBar.maxValue = maxHealth;
        healthBar.minValue = 0;
        healthBar.value    = maxHealth;
        gameObject.transform.Find("EnemyHealth/EnemyName").gameObject.GetComponent <Text>().text = enemyName;
        gameObject.transform.Find("EnemyHealth").gameObject.SetActive(false);
        nav = transform.parent.GetComponent <NavMeshAgent>();
        //PopUpParent = GameObject.FindGameObjectWithTag("PopUpParent");
        canMove   = true;
        canWander = true;
        //SeesPlayer = false;

        // Warp position to nav mesh.
        if (nav.enabled && !nav.isOnNavMesh)
        {
            var position = transform.position;
            NavMesh.SamplePosition(position, out hit, 10.0f, 1);
            position = hit.position;
            nav.Warp(position);
        }
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        fsm.ChangeState(States.Normal);

        //Movement Variables
        walkSpeed = WalkSpeed;

        //HB Bar UI
        MyGUI = GameObject.Find("Canvas");
        SetHPBar();

        //Visibility Zone
        EnemyVisibility  = VisibilityZone.GetComponentInChildren <EnemyVisibility>();
        InVisibilityZone = EnemyVisibility.InVisibilityZone;
        //Detection Zone
        EnemyDetection  = DetectionZone.GetComponentInChildren <EnemyDetection>();
        InDetectionZone = EnemyDetection.InDetectionZone;

        //Player find to follow
        Player = GameManager.instance.player.transform;

        if (BehaivourType == Behaivour.Flying)
        {
            GetComponent <AIDestinationSetter>().target = Player;
        }
    }
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Enemy")
     {
         m_enemyDetection = collision.gameObject.GetComponent <EnemyDetection>();
     }
 }
Beispiel #4
0
 // Start is called before the first frame update
 void Start()
 {
     ed = GetComponent <EnemyDetection>();
     ed.EnemyDetected += Aim;
     ed.OutOfRange    += OutOfRange;
     laserBullet       = GetComponent <AudioSource>();
 }
Beispiel #5
0
 // Start is called before the first frame update
 void Start()
 {
     ed = GetComponent <EnemyDetection>();
     ed.EnemyDetected += Lunch;
     rb            = GetComponent <Rigidbody>();
     bombTransform = transform;
     player        = GameObject.FindGameObjectWithTag("Player");
 }
 void Start()
 {
     enemyManager   = FindObjectOfType <EnemyManager>();
     animator       = GetComponent <Animator>();
     enemyDetection = GetComponentInChildren <EnemyDetection>();
     playerInput    = GetComponent <PlayerInput>();
     impulseSource  = GetComponentInChildren <CinemachineImpulseSource>();
 }
Beispiel #7
0
 protected virtual void Awake()
 {
     animationScript = GetComponent <EnemyAnimations>();
     detectionScript = GetComponent <EnemyDetection>();
     aI            = GetComponent <NavMeshAgent>();
     currentState  = EnemyState.Initial;
     awaitReaction = new WaitForSeconds(reactionTime);
 }
Beispiel #8
0
 private void Awake()
 {
     if (instance != null)
     {
         Debug.LogWarning("Il y a plus d'une instance de EnemyDetection dans la scène.");
         return;
     }
     instance = this;
 }
 void Start()
 {
     enemyManager   = FindObjectOfType <EnemyManager>();
     animator       = GetComponent <Animator>();
     enemyDetection = GetComponentInChildren <EnemyDetection>();
     //movementInput = GetComponent<MovementInput>();
     movementInput = GetComponent <ThirdPersonMovement>();
     impulseSource = GetComponentInChildren <CinemachineImpulseSource>();
 }
Beispiel #10
0
    // Start is called before the first frame update
    void Start()
    {
        enemyDetection = GetComponentInChildren <EnemyDetection>();
        playerCombat   = FindObjectOfType <CombatScript>();
        skinMeshList   = GetComponentsInChildren <SkinnedMeshRenderer>();

        anim              = GetComponent <Animator>();
        swordOrigRot      = sword.localEulerAngles;
        swordOrigPos      = sword.localPosition;
        swordMesh         = sword.GetComponentInChildren <MeshRenderer>();
        swordMesh.enabled = false;
    }
Beispiel #11
0
    private void MakeEnemy(float x, float y, GameObject prefab)
    {
        GameObject enemy = Object.Instantiate(prefab);
        Enemy      e     = enemy.GetComponent <Enemy>();

        e.battleSpawn = new GameObject[] { prefab, prefab };
        EnemyDetection detect = enemy.GetComponent <EnemyDetection>();

        detect.MaxRadius       = 1.4f;
        detect.DetectionRadius = 1.4f;
        detect.EncounterRadius = 1.4f;
        PutObject(x, y, enemy);
    }
Beispiel #12
0
    void Start()
    {
        Anim             = GetComponent <Animator>();
        Agent            = GetComponent <NavMeshAgent>();
        EnemyDetection   = GetComponent <EnemyDetection>();
        EnemyCollider    = GetComponent <CapsuleCollider>();
        SecondStageStand = GetComponent <ParticleSystem>();

        HearingZone            = GameObject.FindGameObjectWithTag("HearingZone").GetComponent <SphereCollider>();
        Agent.stoppingDistance = AttackRange;
        AttackCombo            = 5;
        IsCharge    = false;
        EnemyStatus = Enemy.Patrol;
    }
Beispiel #13
0
    void OnSceneGUI()
    {
        EnemyDetection fov = (EnemyDetection)target;

        Handles.color = Color.green;
        Handles.DrawWireArc(fov.transform.position, Vector3.up, Vector3.forward, 360, fov.viewRadius);
        Vector3 viewAngleA = fov.DirectionFromAngle(-fov.viewAngle / 2, false);
        Vector3 viewAngleB = fov.DirectionFromAngle(fov.viewAngle / 2, false);

        Handles.color = new Color(0, 1, 1, .2f);
        Handles.DrawLine(fov.transform.position, fov.transform.position + viewAngleA * fov.viewRadius);
        Handles.DrawLine(fov.transform.position, fov.transform.position + viewAngleB * fov.viewRadius);
        Handles.DrawSolidArc(fov.transform.position, fov.transform.up, viewAngleA, fov.viewAngle, fov.viewRadius);
    }
Beispiel #14
0
    void Start()
    {
        enemyManager = GetComponentInParent <EnemyManager>();

        animator            = GetComponent <Animator>();
        characterController = GetComponent <CharacterController>();

        playerCombat   = FindObjectOfType <CombatScript>();
        enemyDetection = playerCombat.GetComponentInChildren <EnemyDetection>();

        playerCombat.OnHit.AddListener((x) => OnPlayerHit(x));
        playerCombat.OnCounterAttack.AddListener((x) => OnPlayerCounter(x));
        playerCombat.OnTrajectory.AddListener((x) => OnPlayerTrajectory(x));

        MovementCoroutine = StartCoroutine(EnemyMovement());
    }
Beispiel #15
0
 // Since Enemy is never created as a gameobject, this is used instead of Unity's Start()
 protected void Start()
 {
     rb2d   = GetComponent <Rigidbody2D>();
     detect = GetComponent <EnemyDetection>();
     wall   = SpriteLibrary.library.Wall;
     if (textBox != null)
     {
         textBox = Instantiate(textBox, transform);
         textBox.transform.localPosition = Vector2.zero;
         Textbox box = textBox.GetComponent <Textbox>();
         box.AddTitle(GetName());
         foreach (GameObject backup in battleSpawn)
         {
             box.AddSub(backup.GetComponent <Enemy>().GetName());
         }
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        left  = transform.parent.transform.GetChild(6).GetComponent <LeftPlayers>();
        right = transform.parent.transform.GetChild(7).GetComponent <RightPlayers>();

        rotateObject = transform.parent.transform.GetChild(4).gameObject;
        // follow = GameObject.Find("EnemyFollow").GetComponent<EnemyFollow>();
        if (transform.parent.gameObject.tag == strings.PlayerGoal)
        {
            goalFlag = 1;
        }

        Time.timeScale = 1f;
        enemyScript    = GetComponentInParent <EnemyDetection>();
        ball           = GameObject.FindWithTag(strings.Ball);
        rbBall         = ball.GetComponent <Rigidbody>();
    }
Beispiel #17
0
    public void Update()
    {
        enemy = EnemyDetection.GetClosestEnemy(EnemyDetection.enemies, transform);
        //Add self created gravity
        rb.AddForce(new Vector3(0, -gravity * rb.mass, 0));



        StartCoroutine(Die());

        Sprint();
        Attack();
        PhaseAttack();
        PhaseDash();
        Health();
        PhaseCD();
    }
    private void OnSceneGUI()
    {
        EnemyDetection fow = (EnemyDetection)target;

        Handles.color = Color.white;
        Handles.DrawWireArc(fow.transform.position, Vector3.forward, Vector3.left, 360, fow.viewRadius);
        Vector3 viewAngleA = fow.DirFromAngle(-fow.viewAngle / 2, false);
        Vector3 viewAngleB = fow.DirFromAngle(fow.viewAngle / 2, false);

        Handles.DrawLine(fow.transform.position, fow.transform.position + viewAngleA * fow.viewRadius);
        Handles.DrawLine(fow.transform.position, fow.transform.position + viewAngleB * fow.viewRadius);

        Handles.color = Color.red;
        foreach (Transform visibleTarget in fow.visibleTargets)
        {
            Handles.DrawLine(fow.transform.position, visibleTarget.position);
            Debug.Log("Enemy detected");
        }
    }
Beispiel #19
0
 protected override void Init()
 {
     base.Init();
     navMeshAgent = GetComponent <NavMeshAgent>();
     if (Object_Camp == CampEnum.Alliance)
     {
         EnemyLayer = 9;
     }
     else
     {
         EnemyLayer = 8;
     }
     attack_Data          = GameMapManager.Instance.GetAttackData(Object_UnitName.ToString());
     StopToAttackDistance = attack_Data.maxDetectable_Range;
     shell_Type           = attack_Data.shell_Type;
     shell_Damage         = attack_Data.shell_Damage;
     attack_Speed         = attack_Data.attack_Speed;
     if (transform.Find("Detector") != null)
     {
         enemyDetection = transform.Find("Detector").GetComponent <EnemyDetection>();
         enemyDetection.Init(attack_Data, Object_Radius, GetComponent <IGameUnitBattleFun>());
     }
 }
    void FixedUpdate()
    {
        transform.position = new Vector3(transform.position.x, Mathf.Clamp(transform.position.x, 0.0f, 0.05f), transform.position.z);
        if (isActive == false)
        {
            this.gameObject.SetActive(false);
        }
        if (over == 1)
        {
            enemyAnim.SetBool("isRunning", false);
        }


        if (gameOverDisplay.activeSelf == true || levelCompleteDis.activeSelf == true)
        {
            over = 1;
        }

        for (int i = 0; i < go.Length; i++)
        {
            if (go[i].GetComponent <EnemyDetection>().possessBall == true && i != flagActive)
            {
                enemyDetectionScript = go[i].GetComponent <EnemyDetection>();
                PlayerDetection      = go[i].transform.GetChild(2).gameObject;
                possessScript        = PlayerDetection.GetComponent <BallPossesion>();
                active     = go[i];
                flagActive = i;
            }
        }

        if (enemyKickFlag == 0 && over == 0 && activeScript.activeBehaviour == 1)
        {
            enemyAnim.SetBool("isRunning", true);
            transform.LookAt(ball.transform);
            transform.Translate(Vector3.forward * enemySpeed * Time.deltaTime);
        }
    }
 private void Start()
 {
     player         = GameObject.FindWithTag("Player").transform;
     playerSpeed    = player.gameObject.GetComponent <PlayerController>().speed;
     enemyDetection = player.gameObject.GetComponentInChildren <EnemyDetection>();
 }
 void Start()
 {
     AI  = GetComponentInParent <EnemyAI>();
     Col = GetComponent <SphereCollider>();
     Ed  = GetComponentInParent <EnemyDetection>();
 }
Beispiel #23
0
 // Start is called before the first frame update
 void Start()
 {
     enemy = GetComponent <EnemyDetection>();
 }
Beispiel #24
0
 void Start()
 {
     ed = GameObject.FindObjectOfType <EnemyDetection>();
     pu = GameObject.FindObjectOfType <PlayerUI>();
     StartCoroutine("ResetUI");
 }
Beispiel #25
0
 void Start()
 {
     player = Player.Instance;
     enemy  = GameObject.FindGameObjectWithTag("Enemy").GetComponent <EnemyDetection>();
 }
Beispiel #26
0
    new void Update()
    {
        base.Update();
        // Update all collisions here
        wasOnGround = onGround;
        onGround    = OnGround();

        //Debug.Log(BehaivourType.ToString());

        //if (BehaivourType == Behaivour.Flying)
        //{
        //    float dist = Vector3.Distance(transform.position, Player.transform.position);

        //    if (dist < distanceDetecting)
        //    {
        //        Debug.Log("враг заметил");
        //        //TODO враг в зоне и движется
        //    }
        //}

        EnemyVisibility  = VisibilityZone.GetComponentInChildren <EnemyVisibility>();
        InVisibilityZone = EnemyVisibility.InVisibilityZone;

        EnemyDetection  = DetectionZone.GetComponentInChildren <EnemyDetection>();
        InDetectionZone = EnemyDetection.InDetectionZone;

        //Bow Attack timer
        if (bowAttackCooldownTimer > 0f)
        {
            bowAttackCooldownTimer -= Time.deltaTime;
        }

        //Bow Attack timer
        if (castAttackCooldownTimer > 0f)
        {
            castAttackCooldownTimer -= Time.deltaTime;
        }

        //Melee Attack timer
        if (meleeAttackCooldownTimer > 0f)
        {
            meleeAttackCooldownTimer -= Time.deltaTime;
        }

        if (firstSpecialAttackCooldownTimer > 0f)
        {
            firstSpecialAttackCooldownTimer -= Time.deltaTime;
        }

        if (secondSpecialAttackCooldownTimer > 0f)
        {
            secondSpecialAttackCooldownTimer -= Time.deltaTime;
        }

        if (thirdSpecialAttackCooldownTimer > 0f)
        {
            thirdSpecialAttackCooldownTimer -= Time.deltaTime;
        }

        if (blinkCooldownTimer > 0f)
        {
            blinkCooldownTimer -= Time.deltaTime;
        }

        if (expectationCooldownTimer > 0f)
        {
            expectationCooldownTimer -= Time.deltaTime;
        }

        if (turnCooldownTimer > 0f)
        {
            turnCooldownTimer -= Time.deltaTime;
        }

        //if (stunedCooldownTimer > 0f)
        //{
        //    stunedCooldownTimer -= Time.deltaTime;
        //}

        if (ShowHP != null)
        {
            // получаем экранные координаты расположения врага
            Vector3 screenPos = metka.transform.position;
            // задаем координаты расположения хп
            ShowHP.transform.position = screenPos;
        }
    }
Beispiel #27
0
 // Start is called before the first frame update
 void Start()
 {
     ed = GetComponent <EnemyDetection>();
     ed.EnemyDetected += Aim;
     ed.OutOfRange    += OutOfRange;
 }