Example #1
0
    // Update is called once per frame
    void Update( )
    {
        /*     *
         *
         *
         *
         *
         *
         *
         *  'R'                      ---------cd---------
         */

        if ((Input.GetKeyDown(KeyCode.R) || launched) && m_property.curMana > manaCost && curCd <= 0)
        {
            launched = false;
            curCd    = cd;
            List <GameObject> _keys = new List <GameObject>(m_collector.enemies.Keys);
            m_property.UseMana(manaCost);
            m_animator.SetBool("r", true);
            for (int i = 0; i < _keys.Count; i++)
            {
                float _dis = Vector3.Distance(_keys[i].transform.position, transform.position);
                if (_dis < range)
                {
                    m_targets.Add(_keys[i].transform);
                    // the direction of knocking back
                    Vector3 _dir = (_keys[i].transform.position - transform.position).normalized;
                    // the enemy will be knocked back to here
                    m_targetPosition.Add(_dir * knockBackDis + m_targets[i].position);

                    // Knockback adnormalstate
                    AdnormalState _adstt = new AdnormalState(GameCode.AdnormalStateCode.KnockBack, 0.5f, 0.0f);
                    m_collector.enemies[_keys[i]].SetAdnormalState(_adstt);
                    m_collector.enemies[_keys[i]].Damaged(atk);
                }
            }
        }


        if (curCd > 0)
        {
            curCd -= Time.deltaTime;
        }

        AnimatorStateInfo _asi = m_animator.GetCurrentAnimatorStateInfo(0);

        if (_asi.IsName("Base.r"))
        {
            m_animator.SetBool("r", false);
            m_agent.Stop();
            // enemy that closed to zhaoxin will be knocked back
            if (_asi.normalizedTime > 0.4f)
            {
                for (int i = 0; i < m_targets.Count; i++)
                {
                    m_targets[i].position = Vector3.Lerp(m_targets[i].position, m_targetPosition[i], 0.5f * Time.deltaTime);
                }
            }
        }
    }
Example #2
0
 // Use this for initialization
 void Awake( )
 {
     adnormalStates = new List <AdnormalState>();
     for (int i = 0; i < GameCode.numberAdStt; i++)
     {
         AdnormalState _admnStt = new AdnormalState((GameCode.AdnormalStateCode)i, 0.0f, 0.0f);
         adnormalStates.Add(_admnStt);
     }
 }
Example #3
0
 public void SetAdnormalState(AdnormalState _adnmStt)
 {
     adnormalStates[(int)_adnmStt.adnmStt] = _adnmStt;
 }
Example #4
0
    // Update is called once per frame
    void Update( )
    {
        /*
         *
         *
         *
         *
         *
         *
         *
         * ---press E, set cursor---click a enemy, CD--------------------
         */

        if (enabled &&
            (Input.GetKeyDown(KeyCode.E) || launched) &&
            curCd <= 0 && manaCost <= m_property.curMana)
        {
            m_heroCtrl.SetCursor(GameCode.CursorCode.SingleSkill);
            hasPrepared = true;
            launched    = false;
        }

        if (Input.GetMouseButtonDown(1))
        {
            hasPrepared = false;
        }

        if (hasPrepared && Input.GetMouseButtonDown(0))
        {
            if (m_heroCtrl.leftMouseClkGo != null &&
                range > Vector3.Distance(m_heroCtrl.leftMouseClkGo.transform.position, transform.position))
            {
                string _group = m_heroCtrl.leftMouseClkGo.tag;
                if (m_heroCtrl.AtDifferentGroup(_group, gameObject.tag))
                {
                    m_target = m_heroCtrl.leftMouseClkGo;
                    m_property.UseMana(manaCost);
                    hasPrepared = false;
                    curCd       = cd;
                    //print("zhaoxin use E!!!!!!!!!" + m_heroCtrl.leftMouseClkGo.name);
                    AdnormalState _teleport = new AdnormalState(GameCode.AdnormalStateCode.Teleport, 0.2f, 0.0f);
                    m_property.SetAdnormalState(_teleport);
                    m_heroCtrl.rightMouseClkGo = m_target;
                    m_heroCtrl.target          = m_target;
                    m_animator.SetBool("atk1", true);
                    m_heroCtrl.SetCursor(GameCode.CursorCode.Normal);

                    // slow the target
                    BaseProperty _p = m_target.GetComponent <BaseProperty>();
                    _p.Damaged(damage);
                    AdnormalState _slow = new AdnormalState(GameCode.AdnormalStateCode.Slow, duration, slowDown);
                    _p.SetAdnormalState(_slow);
                    _p.moveSpeed *= (1 - slowDown);
                }
            }
            hasPrepared = false;
        }

        if (curCd > 0)
        {
            curCd -= Time.deltaTime;
            // dash to enemy
            if (m_property.adnormalStates[(int)GameCode.AdnormalStateCode.Teleport].duration >= 0)
            {
                transform.position = Vector3.Lerp(
                    transform.position,
                    m_target.transform.position,
                    Time.deltaTime * 5);
            }
        }
    }
Example #5
0
    // Update is called once per frame
    void Update( )
    {
        /*
         *             *
         *             *
         *              *
         *                *
         *                  *
         *                     *
         *                         *
         * ----------------   duration     -           cd                ---------------
         *                 3 atk here      3th atk completed or duration=0
         */


        // we can use this skill only we haven't press it and it is not in CD
        if (enabled &&
            (Input.GetKeyDown(KeyCode.Q) || launched) &&
            curCd <= 0 && m_curDuration <= 0 && manaCost <= m_property.curMana)
        {
            m_curDuration = duration;
            m_property.UseMana(manaCost);
            m_hasAttack = false;
            launched    = false;
            atkCount    = 3;
            //print("zhaoxin use q");
        }

        AnimatorStateInfo _anmStt = m_animator.GetCurrentAnimatorStateInfo(0);

        if (m_curDuration > 0)
        {
            m_curDuration -= Time.deltaTime;
            curCd          = 0;
            if (_anmStt.IsTag("a"))
            {
                if (_anmStt.normalizedTime > 0.25f && _anmStt.normalizedTime < 0.45f && !m_hasAttack)
                {
                    atkCount--;
                    m_hasAttack = true;
                    //print(atkCount);
                }

                if (_anmStt.normalizedTime > 0.5f)
                {
                    m_hasAttack = false;
                }
            }
            else if (_anmStt.IsName("Base.batk"))
            {
                if (atkCount == 1)
                {
                    m_animator.SetBool("q", true);
                    m_hasAttack = false;
                }
            }
        }
        else if (m_curDuration < 0)
        {
            curCd         = cd;
            m_curDuration = 0;
        }

        if (_anmStt.IsName("Base.q"))
        {
            if (m_animator.GetBool("q"))
            {
                m_curDuration    = 0;
                m_animator.speed = m_property.atkSpeed / m_property.baseAtkSpeed;
                m_animator.SetBool("q", false);
                curCd    = cd;
                m_target = m_heroCtrl.rightMouseClkGo;
                BaseProperty _property = m_target.GetComponent <BaseProperty>();
                if (_property != null)
                {
                    // knock up enemy for 0.5 second
                    AdnormalState _adnmStt = new AdnormalState(GameCode.AdnormalStateCode.KnockUp, 0.5f, 0.0f);
                    _property.SetAdnormalState(_adnmStt);
                    _property.Damaged((int)((float)m_property.atk * (1 + (float)level / 10)));
                    // effect of this skill
                    PoolManager.GetInstance().
                    GetPool(targetEffectPrefab.name, targetEffectPrefab).
                    GetObject(m_target.transform.position + new Vector3(0, m_target.GetComponent <Collider>().bounds.size.y / 2, 0));
                }
                //print("zhaoxin Q !!!!!!!!!!");
            }
        }

        if (curCd > 0)
        {
            curCd -= Time.deltaTime;
        }
    }