Example #1
0
    private IEnumerator Cycle()
    {
        transform.parent = funnelsParent;

        while (true)
        {
            Vector3 pos = Lect.RandomPosOnCenter(player.position, minDis, maxDis);
            float   _y  = 0f;
            _y = Random.Range(player.position.y - yInterval, player.position.y + yInterval);
            if (_y < groundY)
            {
                _y = groundY;
            }
            else if (_y > skyY)
            {
                _y = skyY;
            }
            pos.y = _y;

            float val = 0f;
            while (val < funnelCycle)
            {
                transform.position = Vector3.Lerp(transform.position, pos, moveSpeed * Time.fixedDeltaTime);

                val += Time.fixedDeltaTime;
                yield return(new WaitForFixedUpdate());
            }
        }
    }
Example #2
0
    private IEnumerator Shoot()
    {
        while (true)
        {
            int count = 0;
            while (count < attackCount)
            {
                count++;

                Vector3 dest = Lect.RandomPosOnCenter(player.position, 0f, 2f);

                line.enabled = true;
                line.SetPosition(1, dest + Vector3.up * 5f);

                if (Vector3.Distance(player.position, dest) < 0.5f)
                {
                    //맞았을 경우 대미지
                    if (!playerHit.IsInvincible)
                    {
                        playerHUD.DecreaseHp(damage);
                        //playerHit.FrontBackCheck(player, transform);
                        //playerHit.GunHit(1);
                        if (Flat.Instance.GetGround())
                        {
                            playerHit.BeHitGun();
                        }
                        else
                        {
                            playerHit.BeHitAir();
                        }
                    }
                }

                float val2 = 1f;
                while (val2 > 0f)
                {
                    line.SetPosition(0, transform.position);

                    val2           -= Time.fixedDeltaTime * attackSpeed;
                    line.startWidth = val2;
                    line.endWidth   = val2;

                    yield return(new WaitForFixedUpdate());
                }
                line.enabled = false;
            }

            yield return(new WaitForSeconds(Mathf.Abs(attackCycle)));
        }
    }
Example #3
0
    public Vector3 RandomNavmeshLocation(float _radius)
    {
        if (player == null)
        {
            player = GameObject.FindGameObjectWithTag("Player").transform;
        }

        Vector3 randomDirection = Lect.RandomPosOnCenter(player.position, _radius, _radius);
        Vector3 finalPosition   = GetClosePosition();

        randomDirection += player.position;
        NavMeshHit hit;

        if (NavMesh.SamplePosition(randomDirection, out hit, _radius, 1))
        {
            finalPosition = hit.position;
        }

        return(finalPosition);
    }
Example #4
0
    protected void SetDest1()
    {
        Vector3 temp = ifCenterNull;

        if (player != null)
        {
            if (player.gameObject.activeSelf)
            {
                temp = player.position;
            }
        }
        float dis = (transform.position - dest).sqrMagnitude;

        while (dis < 50f)
        {
            dest = Lect.RandomPosOnCenter(temp, minDis, maxDis);
            dis  = (transform.position - dest).sqrMagnitude;
        }
        dest = new Vector3(dest.x, 0f, dest.z);
    }