Ejemplo n.º 1
0
    public override void OnStateEnter()
    {
        //Debug.Log("Entered Patrol state");

        thisAgent      = agent.GetComponent <NavMeshAgent>();
        agentHealth    = agent.GetComponent <Health>();
        shootingScript = agent.GetComponent <EnemyShooting>();
        doubleStats    = agent.GetComponent <DoubleStatsSpecial>();

        if (doubleStats != null && doubleStats._areStatsBuffed)
        {
            defaultAiSpeed = agent._mech.fowardMoveSpeed * 2;
        }
        else
        {
            defaultAiSpeed = agent._mech.fowardMoveSpeed;
        }

        thisAgent.SetDestination(agent.transform.position);

        agentHealth._myAttacker = null;
        agent.getValidTargets.Clear();

        timerCount = patrolTimer;
    }
Ejemplo n.º 2
0
    void Update()
    {
        //Health
        if (curHealth <= 0)
        {
            transform.position = new Vector3(-7, -2, -4);
            curHealth          = maxHealth;
            score.MinusScoreDeath();
        }

        // Walk
        if (Input.GetKey("d"))
        {
            transform.position += Vector3.right * speed * Time.deltaTime;
            attackPos           = attackPosR;
        }
        if (Input.GetKey("a"))
        {
            transform.position += Vector3.left * speed * Time.deltaTime;
            attackPos           = attackPosL;
        }
        //Jump
        if (Input.GetKey("w") && Mathf.Abs(_rigidbody.velocity.y) < 0.001f)
        {
            _rigidbody.AddForce(new Vector2(0, JumpForce), ForceMode2D.Impulse);
        }
        //Attack
        if (timeBtwAttack <= 0)
        {
            if (Input.GetKey(KeyCode.Space))
            {
                Collider2D[] enemiesToDamage = Physics2D.OverlapCircleAll(attackPos.position, attackRange, whatIsEnemies);
                for (int i = 0; i < enemiesToDamage.Length; i++)
                {
                    SlimeEnemyMovement Senemy = enemiesToDamage[i].GetComponent <SlimeEnemyMovement>();
                    if (Senemy != null)
                    {
                        Senemy.TakeDamage(damage);
                    }

                    EnemyShooting Eenemy = enemiesToDamage[i].GetComponent <EnemyShooting>();
                    if (Eenemy != null)
                    {
                        Eenemy.TakeDamage(damage);
                    }

                    ShootingBoss Benemy = enemiesToDamage[i].GetComponent <ShootingBoss>();
                    if (Benemy != null)
                    {
                        Benemy.TakeDamage(damage);
                    }
                }
            }
            timeBtwAttack = startTimeBtwAttack;
        }
        else
        {
            timeBtwAttack -= Time.deltaTime;
        }
    }
Ejemplo n.º 3
0
    public override void OnStateEnter()
    {
        //Debug.Log("Entered Chase state");
        thisAgent       = agent.GetComponent <NavMeshAgent>();
        shootingScript  = agent.GetComponent <EnemyShooting>();
        thisAgentHealth = agent.GetComponent <Health>();

        doubleStats = agent.GetComponent <DoubleStatsSpecial>();

        if (doubleStats != null && doubleStats._areStatsBuffed)
        {
            dashSpeed      = agent._mech.dashSpeed * 2;
            dashTimeLimit  = agent._mech.dashTimeLimit * 2;
            defaultAiSpeed = agent._mech.fowardMoveSpeed * 2;
        }
        else
        {
            dashSpeed      = agent._mech.dashSpeed;
            dashTimeLimit  = agent._mech.dashTimeLimit;
            defaultAiSpeed = agent._mech.fowardMoveSpeed;
        }

        minRangeBeforeDashAllowed = agent._mech.range / 2;
        maxStoppingDist           = agent._mech.range - 20f;

        thisAgent.SetDestination(agent.transform.position);
    }
Ejemplo n.º 4
0
 void Start()
 {
     animator         = GetComponent <Animator>();
     rb               = GetComponent <Rigidbody2D>();
     shooting         = GetComponent <EnemyShooting>();
     shooting.enabled = false;
 }
Ejemplo n.º 5
0
    private void Awake()
    {
        Health        health   = GetComponent <Health>();
        EnemyShooting shooting = GetComponent <EnemyShooting>();

        shooting.ShotFired += () => onShotFiredAudio.Play(audioSource);
    }
Ejemplo n.º 6
0
    public GameObject createEnemy()
    {
        GameObject      gameObject      = Instantiate(enemyPrefab);
        EnemyController enemyController = gameObject.GetComponentInChildren <EnemyController> ();
        EnemyMovement   enemyMovement   = gameObject.GetComponentInChildren <EnemyMovement> ();
        EnemyShooting   enemyShooting   = gameObject.GetComponentInChildren <EnemyShooting> ();

        enemyController.energy      = energy;
        enemyController.energyDelay = energyDelay;
        enemyController.energyLimit = energyLimit;

        enemyController.health      = health;
        enemyController.healthDelay = healthDelay;
        enemyController.healthLimit = healthLimit;

        enemyMovement.playerTracking = playerTracking;
        enemyMovement.runningCost    = runningCost;
        enemyMovement.runningDelay   = runningDelay;
        enemyMovement.runningSpeed   = runningSpeed;
        enemyMovement.walkSpeed      = walkSpeed;

        for (int i = 0; i < weaponModels.Length; i++)
        {
            GameObject weapon = weaponModels [i].create();
            weapon.transform.SetParent(gameObject.transform.Find("Brain"));
            weapon.transform.position = new Vector3(0.0f, 0f, 0.6f);
        }

        return(gameObject);
    }
Ejemplo n.º 7
0
    // Start is called before the first frame update
    void Start()
    {
        phase3Backend  = new GameObject();
        phase3Frontend = new GameObject();

        explosionDeathInstance = Instantiate(
            explosionDeath,
            Vector3.zero,
            explosionDeath.transform.rotation
            );

        InitVulnerableParts();

        flyToLinear       = GetComponent <FlyToLinear>();
        bossBodyTransform = transform.Find("Boss Body");
        spinning          = GetComponent <RotateAroundLinear>();
        spinAround        = GetComponent <Spinning>();
        enemyShooting     = GetComponent <EnemyShooting>();
        floating          = bossBodyTransform.GetComponent <Floating>();

        rocket1Spawn = lowerRocketParts.transform.Find("Lower Rocket Jet").gameObject;
        rocket2Spawn = upperRocketParts.transform.Find("Upper Rocket Jet").gameObject;
        hangarSpawn  = hangarParts.transform.Find("Hangar Opening").gameObject;

        rocket1 = lowerRocketParts.transform.Find("Lower Rocket Open").GetComponent <RotateAroundLinear>();
        rocket2 = upperRocketParts.transform.Find("Upper Rocket Open").GetComponent <RotateAroundLinear>();
        hangar  = hangarParts.transform.Find("Hangar Door").GetComponent <RotateAroundLinear>();

        roundDone = true;

        initMoveSpeed     = moveSpeed;
        initRotationSpeed = spinning.speed;
    }
Ejemplo n.º 8
0
    void Start()
    {
        movement = GetComponent <PathMovement>();
        aiming   = GetComponent <EnemyAiming>();
        shooting = GetComponent <EnemyShooting>();

        player = FindObjectOfType <PlayerController>();
    }
Ejemplo n.º 9
0
 void GetEnemy()
 {
     if (friendlyQueue.Count > 0 && friendlyQueue != null)
     {
         enemyUnit = friendlyQueue.Peek();
         enemyProp = enemyUnit.GetComponent <EnemyShooting>();
     }
 }
Ejemplo n.º 10
0
 private void Update()
 {
     aliveTime += Time.deltaTime;
     if (EnemyShooting.DistanceBetween(this.gameObject.transform.position, GameObject.FindGameObjectWithTag("Player").transform.position) > despawnDistance || aliveTime > aliveDuration)
     {
         Destroy(this.gameObject);
     }
 }
Ejemplo n.º 11
0
 void Awake()
 {
     _enShooting = GetComponent <EnemyShooting>();
     _move       = GetComponent <EnemyMovement>();
     // RangeDistance = 10f;
     // RangeAngle = 30f;
     Debug.Log(RangeAngle);
     Debug.Log(RangeDistance);
 }
Ejemplo n.º 12
0
 // Start is called before the first frame update
 void Start()
 {
     agent          = GetComponent <NavMeshAgent>();
     enemyHealth    = GetComponent <EnemyHealth>();
     player         = FindObjectOfType <PlayerStateMachine>();
     enemyShoots    = GetComponent <EnemyShooting>();
     origTBS        = timeBetweenShots;
     origAgentSpeed = agent.speed;
 }
Ejemplo n.º 13
0
    private void Start()
    {
        shootingScript = GetComponent <EnemyShooting>();
        fsm            = GetComponent <AICharacter>();

        viewRadius = mech.range;

        StartCoroutine("SearchForTgts", searchDelay);
    }
Ejemplo n.º 14
0
 private void Start()
 {
     //StartCoroutine(GetPattern());
     enemyShooting = gameObject.GetComponent <EnemyShooting>();
     enemyMoving   = true;
     isExistTarget = true;
     StartCoroutine(ActivateEnemy());
     count++;
 }
Ejemplo n.º 15
0
    private void Start()
    {
        agent          = GetComponent <NavMeshAgent>();
        animator       = GetComponentInChildren <Animator>();
        shootingScript = GetComponent <EnemyShooting>();
        agentHealth    = GetComponent <Health>();

        SetState(new PatrolState(this, "initial state is patrol"));
    }
Ejemplo n.º 16
0
    bool eShot = false;              //射撃許可

    // Start is called before the first frame update
    void Start()
    {
        agent             = GetComponent <NavMeshAgent>();
        desPoints         = GameObject.FindGameObjectsWithTag("Pillar"); //Pillarを目的地に設定
        agent.destination = desPoints[nextRoute].transform.position;     //目的地を判別
        myRigidbody       = GetComponent <Rigidbody>();
        player            = GameObject.Find("Player");
        redWall           = GameObject.Find("RedWall");                                      //シーン中のRedWall
        eShooting         = GameObject.Find("EnemyShooting").GetComponent <EnemyShooting>(); //Enemyの射撃のスクリプトを取得
    }
Ejemplo n.º 17
0
    void Start()
    {
        Debug.Log("===EnemyMovement Start===");
        player        = GameObject.FindGameObjectWithTag("Player").transform;
        playerHealth  = player.GetComponent <TankHealth> ();
        enemyShooting = transform.GetComponent <EnemyShooting> ();
        navAgent      = GetComponent <NavMeshAgent> ();

        InvokeRepeating("ReadyToFire", 4f, 3f);
    }
Ejemplo n.º 18
0
    // Use this for initialization
    void Start()
    {
        an     = GetComponent <Animator>();
        agent  = GetComponent <NavMeshAgent> ();
        shoot  = GetComponent <EnemyShooting>();
        health = GetComponent <EnemyHealth> ();

        delayTime         = startDelayTime;
        agent.autoBraking = false;
    }
Ejemplo n.º 19
0
 // Use this for initialization
 void Start()
 {
     agent             = GetComponent <NavMeshAgent>();
     oldPos            = transform.position;
     newPos            = new Vector3(transform.position.x + 20, transform.position.y, transform.position.z + 20);
     agent.destination = new Vector3(transform.position.x + 20, transform.position.y, transform.position.z + 20);
     oldPosAt          = false;
     InvokeRepeating("Patrol", 5, 5);
     enemy = GetComponent <EnemyShooting>();
 }
Ejemplo n.º 20
0
 // Start is called before the first frame update
 void Start()
 {
     agent              = GetComponent <NavMeshAgent>();
     enemyHealth        = GetComponent <EnemyHealth>();
     player             = FindObjectOfType <PlayerStateMachine>();
     enemyShooting      = GetComponent <EnemyShooting>();
     origTBS            = timeBetweenShots;
     transform.position = patrolPoints[0].position;
     curState           = EnemyState.Patrol;
 }
Ejemplo n.º 21
0
    bool isSinking;                             // Whether the enemy has started sinking through the floor.


    void Awake()
    {
        boxCollider = GetComponent <BoxCollider>();

        enemyTurretRotation = GetComponentInChildren <EnemyTurretRotation>();
        shooting            = GetComponentInChildren <EnemyShooting>();

        // Setting the current health when the enemy first spawns.
        currentHealth = startingHealth;
    }
Ejemplo n.º 22
0
    NavMeshAgent nav;               // Reference to the nav mesh agent.

    void Start()
    {
        // Set up the references.
        player               = GameObject.FindGameObjectWithTag("Player").transform;
        playerHealth         = player.GetComponent <PlayerHealth>();
        enemyHealth          = GetComponent <EnemyHealth>();
        enemyShooting        = GetComponent <EnemyShooting>();
        nav                  = GetComponent <NavMeshAgent>();
        nav.stoppingDistance = enemyShooting.distanceToAttack;
        nav.speed            = speed;
    }
Ejemplo n.º 23
0
    // Use this for initialization
    void Start()
    {
        fightStarted           = false;
        audioSource            = GetComponent <AudioSource>();
        boss                   = GameObject.FindGameObjectWithTag("Boss");
        bossFinalPosition      = boss.transform.position;
        bossShooting           = boss.GetComponent <EnemyShooting>();
        player                 = GameObject.FindGameObjectWithTag("Player");
        playerOriginalPosition = player.transform.position;
        ui               = GameObject.FindGameObjectWithTag("UI");
        mainLight        = GameObject.FindGameObjectWithTag("MainLight").GetComponent <Light>();
        bossLife         = boss.GetComponent <DestructibleByPlayer>();
        originalBossLife = bossLife.lifePoints;
        foxUI            = transform.Find("FoxUI").gameObject;

        foreach (GameObject shot in bossShooting.shots)
        {
            shot.transform.localScale = new Vector3(1f, 1f, 1f);
        }

        foxUI.SetActive(false);

        boss.transform.position = bossOriginalPosition;
        bossShooting.enabled    = false;
        player.GetComponent <PlayerShooting>().enabled = false;
        ui.SetActive(false);
        mainLightIntensity  = mainLight.intensity;
        mainLight.intensity = 0f;

        try
        {
            fox = GameManager.IsFoxMode();
        }
        catch (NullReferenceException e)
        {
            fox = false;
        }

        audioSource.clip = fox ? introFox : intro;
        audioSource.Play();

        if (fox)
        {
            player.transform.Find("Player").transform.localScale = Vector3.zero;
            player.GetComponent <PlayerLife>().life = 50;
            player.GetComponent <PlayerLife>().invulnerableDuration = 2f;
            player.GetComponent <PlayerShooting>().fireDelta        = 0.05f;
            player.GetComponent <PlayerShooting>().shotSpeed        = 40f;
        }
        else
        {
            player.transform.Find("Fox").transform.localScale = Vector3.zero;
        }
    }
Ejemplo n.º 24
0
 // Start is called before the first frame update
 void Start()
 {
     spawnPoint = transform.position;
     health     = 3;
     reloading  = false;
     ammo       = 30;
     patrol     = GetComponent <EnemyPatrol>();
     ES         = GetComponent <EnemyShooting>();
     player     = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
     playerpos  = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();
     randSpot   = Random.Range(0, patrol.moveSpots.Count - 1);
     direction  = Vector3.forward;
 }
Ejemplo n.º 25
0
	// Use this for initialization
	void Start () {
		moveEnemyScript = gameObject.GetComponent<MoveEnemy> ();
     	attackScript = gameObject.GetComponent<Attack> ();
     	enemyShootingScript = gameObject.GetComponent<EnemyShooting> ();
		upgradeManagementScript = GameObject.FindWithTag ("GameController").GetComponent<UpgradeManagement> ();

		moveEnemyScript.upgradeSpeedMultiplier = upgradeManagementScript.speed;
		attackScript.upgradeIncubatorDelay = upgradeManagementScript.incubatorDelay;
		attackScript.upgradeSurvivalOfSneezeChance = upgradeManagementScript.survivalOfSneezeChance;
		enemyShootingScript.upgradeBulletLifespan = upgradeManagementScript.bulletLifespan;
		enemyShootingScript.upgradeBulletNumber = upgradeManagementScript.bulletNumber;
		enemyShootingScript.upgradeBulletSpeed = upgradeManagementScript.bulletSpeed;
		enemyShootingScript.upgradeBulletSpread = upgradeManagementScript.bulletSpread;
	}
Ejemplo n.º 26
0
    void OnTriggerEnter(Collider col)
    {
        Debug.Log("Entered:" + col.name);
        if (col.gameObject.tag == "EnemyUnits")
        {
            Debug.Log("here");
            friendlyQueue.Enqueue(col.gameObject);
            Debug.Log("Queue:" + friendlyQueue);
        }

        enemyUnit = friendlyQueue.Peek();

        enemyProp = enemyUnit.GetComponent <EnemyShooting>();
    }
    private void OnEnable()
    {
        suiciderScript = suiciderObject.GetComponent <EnemySuiciderAI>();
        spawnScript    = spawnObject.GetComponent <SpawnEnemies>();
        shootingScript = shooterObject.GetComponent <EnemyShooting>();
        playerInScene  = FindObjectsOfType <Player>();

        suiciderScript.suiciderMoveSpeed = GlobalControl.Instance.suiciderMoveSpeed;
        shootingScript.shooterFireRate   = GlobalControl.Instance.shooterFireRate;

        spawnScript.enemyOneSpawnCount   = GlobalControl.Instance.enemyOneSpawnCount;
        spawnScript.enemyTwoSpawnCount   = GlobalControl.Instance.enemyTwoSpawnCount;
        spawnScript.enemyThreeSpawnCount = GlobalControl.Instance.enemyThreeSpawnCount;
    }
Ejemplo n.º 28
0
    private int wayPointIndex = 0;                              // A counter for the way point array.


    void Awake()
    {
        // Setting up the references.
        HealthPack         = GameObject.FindGameObjectWithTag("HealthPack").transform;
        enemySight         = GetComponent <EnemySight>();
        nav                = GetComponent <UnityEngine.NavMeshAgent>();
        player             = GameObject.FindGameObjectWithTag(Tags.player).transform;
        playerHealth       = player.GetComponent <PlayerHealth>();
        lastPlayerSighting = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <DoneLastPlayerSighting>();
        enemyShooting      = GetComponent <EnemyShooting> ();
        for (wayPointIndex = 0; wayPointIndex < 4; wayPointIndex++)
        {
            patrolWayPoints[wayPointIndex] = new Vector3(Random.Range(0, 500), 0, Random.Range(0, 500));
        }
    }
 /// <summary>
 ///
 /// </summary>
 void Start()
 {
     // Atribui o estado inicial caso seja valido.
     if (initialState == null || initialState.gameObject != gameObject)
     {
         Debug.LogError("No initial state.");
     }
     else
     {
         state    = initialState;
         moving   = GetComponent <EnemyMoving>();
         shooting = GetComponent <EnemyShooting>();
         dying    = GetComponent <EnemyDying>();
     }
 }
Ejemplo n.º 30
0
    void Shoot()
    {
        Debug.Log("Shoot");

        shootTimer -= Time.deltaTime;

        /*   if (enemyUnit != null)
         * {
         *     laserShotLine.SetPosition(0, laserShotLine.transform.position);
         *     laserShotLine.SetPosition(1, enemyUnit.transform.position + Vector3.up);
         *     laserShotLine.enabled = true;
         * }
         */
        if (friendlyQueue.Count > 0)
        {
            var dir = enemyUnit.transform.position - transform.position;
            //    dir.y = 0;
            var rotation = Quaternion.LookRotation(dir);
            transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 2);
            Rigidbody instantiatedProjectile = Instantiate(projectile,
                                                           bulletSpawnPoint.transform.position,
                                                           transform.rotation) as Rigidbody;


            instantiatedProjectile.velocity = transform.TransformDirection(Vector3.forward * 100);
        }

        /*      if (enemyUnit != null)
         *    {
         *        transform.LookAt(enemyUnit.transform);
         *        GameObject go = (GameObject)Instantiate(bullet, bulletSpawnPoint.position, Quaternion.identity);
         *        go.GetComponent<Rigidbody>().AddForce(bulletSpawnPoint.forward * 5000);
         *    }
         */
        enemyProp.TakeDamage(10);
        if (enemyProp.health < 0)
        {
            enemyProp.destroyed = true;
            friendlyQueue.Dequeue();
            if (friendlyQueue.Count > 0)
            {
                enemyUnit = friendlyQueue.Peek();
                enemyProp = enemyUnit.GetComponent <EnemyShooting>();
            }
        }
    }
Ejemplo n.º 31
0
    public void Setup()
    {
        m_Movement         = m_Instance.GetComponent <EnemyMovement>();
        m_Shooting         = m_Instance.GetComponent <EnemyShooting>();
        m_CanvasGameObject = m_Instance.GetComponentInChildren <Canvas>().gameObject;

        //m_Movement.m_PlayerNumber = m_PlayerNumber;
        //m_Shooting.m_PlayerNumber = m_PlayerNumber;

        m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_EnemyColor) + ">ENEMY " + m_EnemyNumber + "</color>";

        MeshRenderer[] renderers = m_Instance.GetComponentsInChildren <MeshRenderer>();

        for (int i = 0; i < renderers.Length; i++)
        {
            renderers[i].material.color = m_EnemyColor;
        }
        //DisableControl ();
    }
Ejemplo n.º 32
0
 public BCWaves(EnemyShooting shooting)
 {
     this.shooting = shooting;
     nextBulletTime = Time.time;
 }
	public override void Start (AI ai)
	{
		enemyShoot = ai.Body.GetComponent<EnemyShooting>();
		playerTarget = ai.WorkingMemory.GetItem<GameObject>("PlayerTargetDetected");
	}
Ejemplo n.º 34
0
 // Use this for initialization
 void Start()
 {
     m_eGun = gameObject.GetComponent<EnemyShooting>();
     m_fShotTimer = m_fShotCoolDown;
 }
Ejemplo n.º 35
0
 public BCLoops(EnemyShooting shooting)
 {
     this.shooting = shooting;
     currentDirection = Random.Range(0, 360f);
     nextBulletTime = Time.time;
 }
Ejemplo n.º 36
0
 public BCRandomSpray(EnemyShooting shooting)
 {
     this.shooting = shooting;
     currentDirection = Random.seed % 4 * 90 + 10f;
     nextBulletTime = Time.time;
 }
Ejemplo n.º 37
0
 public BCRings(EnemyShooting shooting)
 {
     this.shooting = shooting;
     angleGap = 360f / count;
     nextBulletTime = Time.time;
 }
Ejemplo n.º 38
0
 public BCSpiral(EnemyShooting shooting)
 {
     this.shooting = shooting;
     currentDirection1 = Random.Range(0, 360f);
     currentDirection2 = Random.Range(0, 360f);
     nextBulletTime = Time.time;
 }