Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (cd != cc.direction)
        {
            cd = cc.direction;
            Vector3 dir = CharacterAnimations.GetDirection(cd);

            //transform.eulerAngles = dir * 90;
            transform.localPosition = dir * 2 + dir * stats.range * 6 - 2 * Vector3.up;
        }
    }
Exemple #2
0
    void Attack()
    {
        Debug.Log("? attack" + name);
        if (weapon == weapon_type.wand)
        {
            return;
        }

        Transform child = null;

        foreach (Transform Attack_re in skill_rec[skill_type.attack])
        {
            if (!Attack_re.gameObject.activeSelf)
            {
                child = Attack_re;
                child.gameObject.SetActive(true);
                break;
            }
        }
        if (child == null)
        {
            child = Instantiate(physic_attack).transform;
            skill_rec[skill_type.attack].Add(child);
            child.name = skill_type.attack + "_A" + ID.ToString();
            child.SetParent(ATBS);
            child.transform.localEulerAngles = Vector3.zero;
        }

        Attack_data ss = child.GetComponent <Attack_data>();

        ss.Init_Attack(skill_type.attack, physical_dmg, 10, 1, transform, MyCollider, damage_type.physical);
        Vector3 dir = CharacterAnimations.GetDirection(direction);

        Vector3 rot = Vector3.zero;

        if (target == null)
        {
            switch (direction)
            {
            case CharacterDirection.back:
                rot.z = 90 + transform.eulerAngles.z;
                break;

            case CharacterDirection.front:
                rot.z = -90 + transform.eulerAngles.z;
                break;

            case CharacterDirection.right:
                rot.z = 0 + transform.eulerAngles.z;
                break;

            case CharacterDirection.left:
                rot.z = 180 + transform.eulerAngles.z;
                break;
            }
        }
        else
        {
            rot.z = (AngleBetweenVector2(transform.position, target.position));
        }
        ATBS.eulerAngles = rot;

        float sc = stats.range / 15;

        child.localScale    = new Vector2(sc, 0.7f);
        child.localPosition = new Vector3(2 + sc * 6f, 0, 0);
    }
Exemple #3
0
    void ArrowShoot()
    {
        Debug.Log("arrow - " + name);
        Transform child = null;

        foreach (Transform t in skill_rec[skill_type.arrow_shot])
        {
            if (!t.gameObject.activeSelf)
            {
                child = t;
                child.gameObject.SetActive(true);
                break;
            }
        }
        if (child == null)
        {
            child = Instantiate(arrow).transform;
            skill_rec[skill_type.arrow_shot].Add(child);
        }

        Attack_data ss = child.GetComponent <Attack_data>();

        ss.Init_Attack(skill_type.arrow_shot, physical_dmg, 10, stats.range, transform, MyCollider, damage_type.physical);
        Vector3 dir = CharacterAnimations.GetDirection(direction);

        child.localPosition = dir * 4 - transform.up * 2 + transform.position;

        arrow_script ars = child.GetComponent <arrow_script>();

        ars.speed = 10 * (stats.strength * 0.1f);


        Vector3 rot = child.transform.eulerAngles;
        float   r   = Random.Range(0, 15) + Random.Range(0, 15);

        if (target == null)
        {
            switch (direction)
            {
            case CharacterDirection.back:
                rot.z = -90 + (Random.Range(-r, r));
                break;

            case CharacterDirection.front:
                rot.z = 90 + (Random.Range(-r, r));
                break;

            case CharacterDirection.right:
                rot.z = 180 + (Random.Range(-r, r));
                break;

            case CharacterDirection.left:
                rot.z = (Random.Range(-r, r));
                break;
            }
            rot.z += transform.eulerAngles.z;
        }
        else
        {
            rot.z = (AngleBetweenVector2(transform.position, target.position)) - 180 + (Random.Range(-r, r));
        }
        child.transform.localEulerAngles = rot;
        child.SetParent(Skill_Dump);
    }
Exemple #4
0
    void CastSpell()
    {
        Transform child = null;

        foreach (Transform t in skill_rec[skill_type.spell])
        {
            if (!t.gameObject.activeSelf)
            {
                child = t;
                child.gameObject.SetActive(true);
                break;
            }
        }
        if (child == null)
        {
            child = Instantiate(skill1).transform;
            skill_rec[skill_type.spell].Add(child);
        }
        child.name = skill_type.spell + "_" + ID.ToString();
        Attack_data ss = child.GetComponent <Attack_data>();

        ss.Init_Attack(skill_type.spell, magic_dmg, 10, 0, transform, MyCollider, damage_type.physical);
        Vector3 dir = CharacterAnimations.GetDirection(direction);

        child.localPosition = transform.position + dir * 20 - transform.up * 5;

        Spel1_script ssc = child.GetComponent <Spel1_script>();
        Vector3      rot = child.transform.eulerAngles;
        float        r   = Random.Range(0, 15) + Random.Range(0, 15);

        if (target == null)
        {
            switch (direction)
            {
            case CharacterDirection.back:
                rot.z = -90 + (Random.Range(-r, r));
                break;

            case CharacterDirection.front:
                rot.z = 90 + (Random.Range(-r, r));
                break;

            case CharacterDirection.right:
                rot.z = 180 + (Random.Range(-r, r));
                break;

            case CharacterDirection.left:
                rot.z = (Random.Range(-r, r));
                break;
            }
            rot.z += transform.eulerAngles.z;
        }
        else
        {
            rot.z = (AngleBetweenVector2(transform.position, target.position)) - 180 + (Random.Range(-r, r));
        }
        child.transform.eulerAngles = rot;
        ssc.speed = stats.range / 15;

        ssc.ReLoadSpell();
        child.SetParent(Skill_Dump);
    }