예제 #1
0
    protected override void Awake()
    {
        base.Awake();

        m_Cursor = transform.Find("CursorRotation");
        if (!m_Cursor)
        {
            Debug.LogError("Player could not find cursor rotation!");
        }
        else
        {
            m_ShootSystem = m_Cursor.GetComponentInChildren <ParticleSystem>();
        }

        m_PauseCirle = transform.Find("PauseCircle");
        if (!m_PauseCirle)
        {
            Debug.LogError("Player could not find pause circle!");
        }

        m_PauseScale            = m_PauseCirle.localScale;
        m_PauseCirle.localScale = Vector3.zero;

        m_DashChargeSystem = transform.Find("PlayerDashChargeParticles").GetComponent <ParticleSystem>();

        var cds = FindObjectsOfType <DashCooldown>();

        if (cds.Length > 0)
        {
            m_CooldownCharges = cds.Length;
            for (int i = 0; i < cds.Length; i++)
            {
                m_Cooldowns.Add(cds[i]);
            }

            for (int write = 0; write < m_Cooldowns.Count; write++)
            {
                for (int sort = 0; sort < m_Cooldowns.Count - 1; sort++)
                {
                    if (m_Cooldowns[sort].m_ID > m_Cooldowns[sort + 1].m_ID)
                    {
                        DashCooldown temp = m_Cooldowns[sort];
                        m_Cooldowns[sort]     = m_Cooldowns[sort + 1];
                        m_Cooldowns[sort + 1] = temp;
                    }
                }
            }
        }
        else
        {
            Debug.LogError("Player could not find any cooldown sliders!");
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        transform.position.Set(transform.position.x, y, transform.position.z);
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical   = Input.GetAxis("Vertical");

        if (!canDash && !dashing)
        {
            dashTimer += Time.deltaTime;
            DashCooldown.UpdateCooldown(dashTimer, dashCooldown);
            if (dashTimer >= dashCooldown)
            {
                canDash   = true;
                dashTimer = 0f;
            }
        }

        input = (transform.right * moveHorizontal + transform.forward * moveVertical).normalized;
        if (Input.GetKeyDown(KeyCode.R) && canDash)
        {
            canDash = false;
            dashing = true;
        }

        if (dashing)
        {
            input     *= dashSpeed;
            dashTimer += Time.deltaTime;
            if (dashTimer >= dashTime)
            {
                dashing   = false;
                dashTimer = 0f;
            }
        }
        else
        {
            input *= moveSpeed;
        }

        input.y       = moveDirection.y;
        moveDirection = Vector3.Lerp(moveDirection, input, Time.deltaTime);

        controller.Move(input * Time.deltaTime);

        /*
         * input = (transform.right * moveHorizontal + transform.forward * moveVertical).normalized;
         * input *= moveSpeed;
         * input.y = moveDirection.y;
         * moveDirection = Vector3.Lerp(moveDirection, input, Time.deltaTime);
         *
         * controller.Move(input * Time.deltaTime);
         */
    }
예제 #3
0
    protected override void Update()
    {
        base.Update();

        if (!isABoss)
        {
            img_Health.fillAmount    = Health.GetCurrentValue() / Health.GetBaseValue();
            img_StunMeter.fillAmount = StunMeterCurrentValue / StunMeterMaximumValue;
            img_Barrier.fillAmount   = Barrier.GetCurrentValue() / Health.GetBaseValue();
        }
        if (target == null)
        {
            return;
        }
        if (Vector3.Distance(target.transform.position, transform.position) <= attackRangeDetection && Vector3.Distance(target.transform.position, transform.position) > walkBackRangeDetection)
        {
            RaycastHit hitray;

            Rotation();
            if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hitray, 1000) && CanAttack)
            {
                if (hitray.collider.tag == "Player")
                {
                    UseBasicAttack(target);
                }
                Debug.DrawLine(transform.position, transform.TransformDirection(Vector3.forward) * 1000, Color.yellow);
            }
        }
        else
        {
            if (TargetDetection())
            {
                Rotation();
            }



            if (CanMove)
            {
                Movement();
            }

            if (DashCooldown.IsFinish())
            {
                StartCoroutine(ActivateDash());
            }
        }

        Death();
    }
예제 #4
0
    // Update is called once per frame
    protected override void Update()
    {
        base.Update();
        if (target == null)
        {
            target = GameObject.FindGameObjectWithTag("Player").transform;
        }


        if (Vector3.Distance(target.transform.position, transform.position) <= attackRangeDetection && Vector3.Distance(target.transform.position, transform.position) > walkBackRangeDetection && TargetDetection())
        {
            RaycastHit hitray;

            Rotation();
            if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hitray, 1000) && CanAttack)
            {
                if (hitray.collider.tag == typeOfTarget.ToString())
                {
                    UseBasicAttack(target);
                }
                Debug.DrawLine(transform.position, transform.TransformDirection(Vector3.forward) * 1000, Color.yellow);
            }
        }
        else
        {
            if (TargetDetection())
            {
                Rotation();
            }

            if (CanMove)
            {
                Movement();
            }

            if (DashCooldown.IsFinish())
            {
                StartCoroutine(ActivateDash());
            }
        }
    }
예제 #5
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (m_IsDash)
        {
            string tag = col.gameObject.tag;
            if (tag != "Enemy" && tag != "Projectile")
            {
                InterruptDash();
            }

            PhysicsEntity pEntity = col.gameObject.GetComponent <PhysicsEntity>();
            if (pEntity)
            {
                pEntity.OnHit();

                DashCooldown cd = GetFirstActiveCooldown();
                if (cd)
                {
                    cd.Reset();
                }
            }
        }
    }