实习Day2

今天上午这哪里是讲课。。。分明是分派任务。。这大概就是主程和我们的区别吧。。。。

昨天实现了下三连击,以及特殊的情况处理,这里先贴个技能处理效果吧。大概思路是时间检测

using System.Collections;
using System.Collections.Generic;
using UnityEngine; 
public class PlayerControll : MonoBehaviour
{
    Animator anim;
    Rigidbody rigid;
    Transform trans;
    public float speed = 0.3f;
    private float rotationSpeed = 100.0f; 
    public bool isRun;
    public float timeNeed=0.5f;
    //技能释放ATTACK动作时间
    private float timeAttack;
    public float timeANeed = 0.3f; 


    public GameObject skillStartPosition;//技能释放点
    //敌人队列
    public List<GameObject> enemy = new List<GameObject>();

    //三连
    //状态机里面的状态;
    public int isThree;
    //状态机里是否存在了下一帧
    public int isFour;
    //三连当前还剩下的秒
    public float isThreeTime;
    //三连下一连特效
    public List<GameObject> list = new List<GameObject>();


    //人物属性 
    private PersonAttri personAttri;
    public List<int> skillList = new List<int>();

    void Start()
    {
        isThree = 0;
        isFour = 0;
        timeAttack = 0.0f; 
        isRun = false;
        trans = gameObject.GetComponent<Transform>();
        rigid = gameObject.GetComponent<Rigidbody>();
        anim = gameObject.GetComponent<Animator>();
        anim.SetBool("toIdle", true);

            属性      
        personAttri = GetComponent<PersonAttri>();

    }   
    void Update()
    {

        updateThreeA();
        playerMove();
    }   
    void updateThreeA()     
    { 
        timeAttack -= Time.deltaTime;
        isThreeTime -= Time.deltaTime;
        if (isThreeTime <=0 )
        {   
            if (isFour == isThree)
            {   
                isFour = 0;
                isThree = 0;
                isThreeTime = 0;
            }   
            else
            {   
                if (isFour == 1)
                    isThreeTime = 0.8f;
                if (isFour == 2)
                {   
                    isThreeTime = 0.867f;
                }   
                else if (isFour == 3)
                {   
                    isThreeTime = 0.5f;
                }   
                isThree = isFour;
                if(enemy.Count!=0)
                    GameManager.GM.skillManager.ShowSkillOne(list[0],enemy[0],skillStartPosition);
            }   

            anim.SetInteger("toThree",isThree);

        }
        if (timeAttack <= 0) timeAttack = 0;
        
    }    
    void playerMove( )
    {
        if (timeAttack > 0) return;     
        if (isThreeTime > 0) return;    
        float translation = Input.GetAxis("Vertical") * (-1.0f);
        float rotation = Input.GetAxis("Horizontal");
        Vector3 Rot = new Vector3(translation, 0, rotation);
        if (translation != 0 || rotation != 0)
        {   
            isRun = true;           
            Vector3 targetDirect = Rot;
            Quaternion targetRotation = Quaternion.LookRotation(targetDirect, Vector3.up);
            Quaternion newRotation = Quaternion.Lerp(rigid.rotation, targetRotation, 30.0f * Time.deltaTime);
            gameObject.GetComponent<Rigidbody>().MoveRotation(newRotation);
            transform.Translate(Vector3.forward * speed, Space.Self);
            anim.Play("Run"); 
        }
        else
        { 
            if (isRun)
            {
                isRun = false;
                anim.Play("Idle");
            }
        }   
    }

    void Rotation(Vector3 Rot,GameObject go)
    {
        Vector3 targetDirect = Rot;
        go.transform.LookAt(Rot); 
    }

    //技能逻辑部分
    public void DoSkill(GameObject currentSkill, int em = 0)
    {
        bool isOk = true;
        Debug.Log(currentSkill.GetComponent<SkillData>().kind +"   种类技能");
        //单体攻击技能
        if (currentSkill.GetComponent<SkillData>().kind == 0)
        {
            //em是否为平A
            XA(currentSkill, em);
            Debug.Log(timeAttack + " there");
        }
        //buff性技能
        else if (timeAttack == 0)
        {
            if (currentSkill.GetComponent<SkillData>().kind == 1)
            {
                bool isHave = false;
                GameObject skillType = GameObject.Instantiate(currentSkill, skillStartPosition.transform.position, Quaternion.identity);

                for (int i = 0; i < skillList.Count; i++)
                {
                    if (skillList[i] == currentSkill.GetComponent<SkillData>().buffKind)
                    {
                        isHave = true;
                        break;
                    }
                }
                if (isHave == false)
                    skillList.Add(currentSkill.GetComponent<SkillData>().buffKind);
                GameManager.GM.skillManager.ShowSkillBuff(currentSkill, this.gameObject, skillStartPosition, !isHave);
                anim.Play("Attack");
            }
            else if (currentSkill.GetComponent<SkillData>().kind == 2)//AOE不被隔断的技能
            {
                GameObject skillType = GameObject.Instantiate(currentSkill, skillStartPosition.transform.position, Quaternion.identity);

                GameManager.GM.skillManager.ShowSkillAOEStill(currentSkill, this.gameObject);

                anim.Play("Attack");
            }
            Debug.Log(isOk);
            if (isOk)
            {
                timeAttack += 0.8f;
            }
        }
    }

    /三连
    public bool XA(GameObject currentSkill,int em=0)
    {
        if (enemy.Count == 0) return false;
        isRun = false;
        GameObject targetEnemy = enemy[0];
        Rotation(targetEnemy.transform.position, this.gameObject);
        if (em == 1)
        {
            if (isThreeTime <= 0.2f)    
            {                           
                isFour = isThree + 1;   
                list.Add(currentSkill); 
            }
            else
            {
                if (isThree == 4)
                {
                    isThree = 0;
                    isFour = 0;
                }
            }   
        }
        else
        { 
            if (timeAttack > 0)
                return false;
            timeAttack += 0.8f;
            isThree = 0;
            anim.Play("Attack");
        }

        GameObject skillType = GameObject.Instantiate(currentSkill, skillStartPosition.transform.position, Quaternion.identity);
        GameManager.GM.skillManager.ShowSkillOne(currentSkill, targetEnemy, skillStartPosition);
        return true;
    }
    //加敌人
    void OnTriggerEnter(Collider col)
    {
        if (col.tag == "Enemy") enemy.Add(col.gameObject);
    }
    void OnTriggerExit(Collider col)
    {   
        if (col.tag == "Enemy") enemy.Remove(col.gameObject);
    } 

    ///buff/
    void BeBuff( )
    {

    }

}   
今天争取把怪物的生产与自动走路实现吧,似乎和塔防时候的差不多


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值