예제 #1
0
    void R()
    {
        ClearRange();
        selected = 'R';
        ShowRange(RRANGE);
        GLOBAL.DrawLine(transform.position + offset, RF.Mouse.transform.position, Color.red, .1f, RRANGE);

        if (GLOBAL.LeftClickHit())
        {
            RaycastHit h = GLOBAL.MousePosRay();
            Character  c = h.collider.GetComponent <Character>();
            if (GLOBAL.CheckCharacter(character, c))
            {
                target = h.transform;
                CharacterPlayerNav.MoveTo(c.transform.position);
                chasing = true;
            }
            else
            {
                target  = null;
                chasing = false;
            }
        }

        if (target != null && GLOBAL.HasReached(transform.position, target.position, BrandAbilities.RRANGE))
        {
            Shoot(selected);
        }
    }
예제 #2
0
    void Travel()
    {
        GLOBAL.Homing(rb, target, velocity, TurnRadius);

        if (GLOBAL.HasReached(transform.position, target.position, transform.localScale.x * .5f))
        {
            DealDamage();
        }
    }
예제 #3
0
    void W()
    {
        ClearRange();
        selected = 'W';
        ShowRange(WRANGE);
        RF.Mouse.SetRange(3);
        GLOBAL.DrawLine(transform.position + offset, RF.Mouse.transform.position, Color.red, .1f, WRANGE);

        if (GLOBAL.LeftClickHit())
        {
            target = RF.Mouse.transform;
            CharacterPlayerNav.MoveTo(target.position);
            chasing = true;

            if (GLOBAL.HasReached(transform.position, target.position, BrandAbilities.WRANGE))
            {
                Shoot(selected);
            }
        }
    }
예제 #4
0
    void CheckChase()
    {
        if (chasing)
        {
            if (target != null)
            {
                switch (selected)
                {
                case 'Q':
                    if (GLOBAL.HasReached(transform.position, target.position, BrandAbilities.QRANGE))
                    {
                        Shoot(selected);
                    }
                    break;

                case 'W':
                    if (GLOBAL.HasReached(transform.position, target.position, BrandAbilities.WRANGE))
                    {
                        Shoot(selected);
                    }
                    break;

                case 'E':
                    if (GLOBAL.HasReached(transform.position, target.position, BrandAbilities.ERANGE))
                    {
                        Shoot(selected);
                    }
                    break;

                case 'R':
                    if (GLOBAL.HasReached(transform.position, target.position, BrandAbilities.RRANGE))
                    {
                        Shoot(selected);
                    }
                    break;
                }
            }
        }
    }
예제 #5
0
파일: Character.cs 프로젝트: WichaelMu/ROFL
    void BasicAttack()
    {
        #region ignore
        //Ray ray = new Ray(transform.position, Camera.main.ScreenToWorldPoint(Input.mousePosition));
        //if (Physics.Raycast(ray, out RaycastHit hit, range, 9))
        //{
        //    Transform t = hit.collider.gameObject.transform;
        //    Character c = hit.collider.GetComponent<Character>();
        //    if (c != null && c.range >= Vector3.Distance(transform.position, t.position))
        //    {

        //    }
        //}

        #endregion

        if (GLOBAL.RightClick())
        {
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
            {
                Character c = hit.collider.GetComponent <Character>();

                //  If a character is hit and is not yourself.
                if (GLOBAL.CheckCharacter(this, c))
                {
                    //  Set the target to the clicked character.
                    target = c.transform;

                    //  In range.
                    if (GLOBAL.HasReached(transform.position, target.position, AutoRange))
                    {
                        AutoAttack();
                    }

                    //  Chase this character.
                    chasing = true;
                }
                else
                {
                    //  Do nothing and move there.
                    target  = null;
                    chasing = false;
                }
            }
        }

        //  Chase target.
        if (chasing)
        {
            //  In range.
            if (GLOBAL.HasReached(transform.position, target.position, AutoRange))
            {
                AutoAttack();
            }
            else
            {
                //  Out of range.
                Invoke(nameof(MaintainDistance), .5f);
            }
        }
    }