Пример #1
0
    // Update is called once per frame
    void Update()
    {
        player = RandomEnemySpawn.getClosestPlayer(transform, RandomEnemySpawn.playerCenterList).gameObject;
        float disToPlayer = Vector3.Distance(transform.position, player.transform.position);

        transform.rotation = Quaternion.LookRotation(rb.velocity);
        //Debug.Log("Player position is " + player.transform.position);
        if (disToPlayer <= idleBehaviorRadius && disToPlayer > attackRadius)
        {
            neutralMovement();
        }
        else if (disToPlayer <= attackRadius)
        {
            //center = player.GetComponent<SkinnedMeshRenderer>().bounds.center;
            //speed = GetComponent<StatManager>().shly.enemyStats.getSpeed();
            speed           = GetComponent <StatManager>().shly.enemyStats.getSpeed();
            bullChargeSpeed = GetComponent <StatManager>().shly.getBullChargeSpeed();
            //transform.LookAt(player.transform);
            if (shly == null)
            {
                shly = GetComponent <StatManager>().shly;
            }
            if (shly.getAggregateNum() > 1)
            {
                if (!shly.sprainActive)
                {
                    bullCharge(player.transform.position);
                }
            }
            else
            {
                if (!shly.sprainActive)
                {
                    PelletDrop();
                }
            }
            shly.sprain(sprainEffectRadius);
        }
        else
        {
            rb.velocity = Vector3.zero;
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        player = RandomEnemySpawn.getClosestPlayer(transform, RandomEnemySpawn.playerCenterList).gameObject;
        //Logic for running behaviors, ground pound is a close range attack, charge is mid-range attack and projectile launch is far range-attack
        float playerDist = Vector3.Distance(player.transform.position, transform.position);

        if (playerDist < groundPoundRange)
        {
            //mainCamera.GetComponent<cameraSoundManager>().enemyInRange = true;
            groundPound();
        }
        else if (playerDist > groundPoundRange && playerDist < chargeRange)
        {
            //mainCamera.GetComponent<cameraSoundManager>().enemyInRange = true;
            charge();
        }
        else if (playerDist > chargeRange && playerDist < shootRange)
        {
            //mainCamera.GetComponent<cameraSoundManager>().enemyInRange = true;
            setShootTrigger();
        }
        else if (playerDist > shootRange && playerDist < noActionRange)
        {
            //mainCamera.GetComponent<cameraSoundManager>().enemyInRange = false;
            Debug.Log("Golem is too far from player to enact behavior");
            idleTimer -= Time.deltaTime;
            if (idleTimer <= 0)
            {
                targetPoint           = randomPointInRadius();
                searchForNewIdlePoint = false;
                idleTimer             = oIdleTimer;
            }
            if (!searchForNewIdlePoint)
            {
                sphericalMovement(targetPoint, speed);
            }
            if (Vector3.Distance(transform.position, targetPoint) <= 0.8f)
            {
                rb.velocity           = Vector3.zero;
                searchForNewIdlePoint = true;
            }
        }
    }
Пример #3
0
    // Update is called once per frame

    void Update()
    {
        player    = RandomEnemySpawn.getClosestPlayer(transform, RandomEnemySpawn.playerList).gameObject;
        diveSpeed = GetComponent <StatManager>().flyingKam.getDiveSpeed();
        transform.LookAt(player.transform); //Ensures they're always looking at the player
        Vector3 playerPos = player.transform.position;
        Vector3 enemyPos  = transform.position;

        //Debug.Log("Player position is " + playerPos);
        //Debug.Log("Distance between player and kamikaze is " + Vector3.Distance(playerPos, enemyPos));
        if (Vector3.Distance(playerPos, enemyPos) < distance)
        {
            anim.SetTrigger("Dive");
            Debug.Log("Player is at " + playerPos);
            r.velocity = (playerPos - enemyPos).normalized * diveSpeed; //Kamikazes move towards player when player is within certain distance
        }
        else
        {
            neutralMovement();
        }
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        player             = RandomEnemySpawn.getClosestPlayer(transform, RandomEnemySpawn.playerList).gameObject;
        leftPlayerLeg      = RandomEnemySpawn.getClosestPlayer(transform, leftLegList).gameObject;
        rightPlayerLeg     = RandomEnemySpawn.getClosestPlayer(transform, rightLegList).gameObject;
        shrabMovementSpeed = GetComponent <StatManager>().shrabMovementSpeed;
        float raycastDistancePlayer = Vector3.Distance(transform.position, findRaycastPointOnSphere(player.transform.position));

        //transform.LookAt(player.transform);
        if (raycastDistancePlayer <= attackRadius)
        {
            pincerMovement();
        }
        else if (raycastDistancePlayer <= idleRadius && raycastDistancePlayer > attackRadius)
        {
            idleTimer -= Time.deltaTime;
            if (idleTimer <= 0)
            {
                targetPoint           = randomPointInRadius();
                searchForNewIdlePoint = false;
                idleTimer             = oIdleTimer;
            }
            if (!searchForNewIdlePoint)
            {
                shrabSphereMovement(targetPoint);
            }
            if (Vector3.Distance(transform.position, targetPoint) <= 0.5f)
            {
                rb.velocity           = Vector3.zero;
                searchForNewIdlePoint = true;
            }
        }
        else if (raycastDistancePlayer > idleRadius)
        {
            rb.velocity = Vector3.zero;
            //rb.freezeRotation = true;
        }
        RaycastHit hit;
        int        layerMask = ~LayerMask.GetMask("Self");

        if (Physics.Raycast(transform.position + transform.position.normalized * 10.0f, (planet.transform.position - transform.position).normalized, out hit, Mathf.Infinity, layerMask))
        {
            transform.position = hit.point;
        }

        /* if(Vector3.Distance(transform.position, player.transform.position) > 3.0f)
         * {
         *   waterShurikenAttack();
         * }
         * /*
         * foreach(Shrab s in Shrab.shrabList)
         * {
         *   if(Vector3.Distance(s.referenceObject.transform.position, transform.position) < pincerMovementRange)
         *   {
         *       shrabsInRange.Add(s);
         *   }
         * }
         * int numShrabs = 0;
         * foreach(Shrab s in shrabsInRange)
         * {
         *   numShrabs += s.getNumShrabs();
         * }
         * if(numShrabs >= 12)
         * {
         *   pincerMovement();
         * }
         */
    }