Example #1
0
    public void SetMoveTarget(Vector3 target)           //在cameraControl中调用,实现右键移动至目标点
    {
        this.MoveTarget = target;
        Vector3 lookDir = -transform.position + target;

        lookDir.y = 0f;
        Debug.Log("出来吧,我的角度:" + Vector3.Angle(lookDir, transform.forward));
        if (Vector3.Angle(lookDir, transform.forward) >= 60f)
        {
            transform.rotation = Quaternion.LookRotation(lookDir);
            agent.enabled      = false;
            Debug.Log("出来吧,我的角度");
        }

        if (Vector3.Distance(transform.position, MoveTarget) >= 0.3f)             //大于0,3就自动寻路
        {
            if (stateAni != State_Ani.State_Run)
            {
                ani.SetTrigger("CanRun");
            }
            agent.enabled = true;
            stateAni      = State_Ani.State_Run;
            Debug.Log("自动寻路:" + target);
            agent.Resume();
            agent.speed = moveSpeed;
            agent.SetDestination(target);               //自动寻路
        }
    }
Example #2
0
 public void BaseUpdate()
 {
     rebTimeCount += Time.deltaTime;
     aniInfo       = ani.GetCurrentAnimatorStateInfo(0);
     if (Mathf.Abs(agent.remainingDistance) < 0.3f && stateAni != State_Ani.State_Idle)           //小于0.3就停下来
     {
         Debug.Log("停下来了");
         ani.SetTrigger("CanStop");
         stateAni = State_Ani.State_Idle;
     }
     if (aiOrPlayer == AiOrPlayerType.Player)
     {
         SetKillForKey();
     }
     for (int i = 0; i < enemyInfo.Length; i++)
     {
         enemyInfo [i].time_LastAtk += Time.deltaTime;
     }
     CanDeath();         //死亡判定,判定助攻,击杀,
     skill_Q.timeCount += Time.deltaTime;
     skill_W.timeCount += Time.deltaTime;
     skill_E.timeCount += Time.deltaTime;
     skill_D.timeCount += Time.deltaTime;
     skill_F.timeCount += Time.deltaTime;
 }
    public virtual IEnumerator Start()                //基类初始化
    {
        uimanager = GameObject.Find("UI").GetComponent <UIManager>();

        if (roleCamp == Role_Camp.Blue)
        {
            FriendLayer   = LayerMask.GetMask("Blue", "Buff");
            EnemyLayer    = LayerMask.GetMask("Red", "Buff");
            EnemyLayerNum = 9;
        }
        else
        {
            FriendLayer   = LayerMask.GetMask("Red", "Buff");
            EnemyLayer    = LayerMask.GetMask("Blue", "Buff");
            EnemyLayerNum = 10;
        }
        BaseStart();
        Hp          = HpMax;
        Mp          = MpMax;
        ani         = GetComponent <Animator> ();
        agent       = GetComponent <NavMeshAgent> ();
        agent.speed = moveSpeed;
        stateAni    = State_Ani.State_Idle;
        string pathTemp = "UI/Skills/RoleSkillUI/" + roleName.ToString() + "/";

        roleTex           = Resources.Load <Sprite> (pathTemp + "HeadTex_" + skinNum);
        skill_Q.tex       = Resources.Load <Sprite> (pathTemp + "Skill_Q");
        skill_W.tex       = Resources.Load <Sprite>(pathTemp + "Skill_W");
        skill_E.tex       = Resources.Load <Sprite>(pathTemp + "Skill_E");
        skill_D.tex       = FindTexDF(skill_D.skillName);
        skill_F.tex       = FindTexDF(skill_F.skillName);
        skill_Q.timeCount = skill_Q.CD;
        skill_W.timeCount = skill_W.CD;
        skill_E.timeCount = skill_E.CD;
        skill_D.timeCount = skill_D.CD;
        skill_F.timeCount = skill_F.CD;
        colRole           = GetComponent <Collider> ();
        uiManager         = GameObject.Find("UI").GetComponent <UIManager> (); //1V1 or 3V3
        IntializeSkillData();                                                  //一帮情况下的技能设定,具体的可以删此函数,自定义来设置;
        yield return(null);

        //初始化enemyInfo
        if (uiManager.mapSelect == MapSelect.oneVSone)
        {
            IntializeEnemyInfo1V1(roleCamp);
        }
        if (uiManager.mapSelect == MapSelect.threeVSthree)
        {
            IntializeEnemyInfo3V3(roleCamp);
        }
        yield return(null);
    }
Example #4
0
    void ChangeAction(State_Ani type)
    {
        if (_isDead)
        {
            return;
        }

        _aniCtrl.SetInteger("AniState", (int)type);

        if (type == State_Ani.HIT)
        {
            _isDead = true;
        }

        _currentAction = type;
    }
    public void CanDeath()                                //死亡判断
    {
        if (IsDeath && stateAni != State_Ani.State_Death) //死亡动作;
        {
            stateAni = State_Ani.State_Death;
            ani.SetTrigger("Can_Death");
            deathCount++;
            colRole.isTrigger = true;             //不被碰撞;
            colRole.enabled   = false;            //不被检测
            transform.Find("weapon/WEAPON_1").gameObject.SetActive(false);
            GetComponent <HpShow>().canShow = false;
            rebTimeCount = 0f;
            int tempChioce = 0;             //最后的击杀者
            for (int i = 0; i < enemyInfo.Length; i++)
            {
                if (enemyInfo[i].time_LastAtk <= TimeLastDeath)
                {
                    enemyInfo [i].roleMain.assistsCount++;
                    enemyInfo [i].roleMain.ReceiveExpAndGold(worthExp / 2, worthMoney / 2);
                }
                if (enemyInfo[tempChioce].time_LastAtk > enemyInfo[i].time_LastAtk)
                {
                    tempChioce = i;
                }
            }
            if (enemyInfo[tempChioce].time_LastAtk < TimeLastDeath)
            {
                Debug.Log(playerName + "被" + enemyInfo [tempChioce].roleMain.playerName + "击杀了!!!");                  //需要一个ui界面————————————————————
                enemyInfo[tempChioce].roleMain.assistsCount--;
                enemyInfo [tempChioce].roleMain.killCount++;
                enemyInfo [tempChioce].roleMain.ReceiveExpAndGold(worthExp / 2, worthMoney / 2);
            }
        }
        if (IsDeath && rebTimeCount >= 2f)
        {
            ChangMesh(false);
        }

        if (IsDeath && rebTimeCount >= rebirthTime)
        {
            IntiRoleRebirthData();
        }
    }
    public void IntiRoleRebirthData()
    {
        Debug.Log("复活啦");
        ChangMesh(true);
        transform.Find("weapon/WEAPON_1").gameObject.SetActive(true);
        transform.GetComponent <HpShow> ().canShow = true;
        colRole.enabled   = true;
        colRole.isTrigger = false;
        Vector3 rebirthPos2 = new Vector3();

        if (uimanager.mapSelect == MapSelect.oneVSone)
        {
            if (roleCamp == Role_Camp.Red)
            {
                rebirthPos2 = GameObject.Find("PathSolider/point_00").transform.position;
            }
            else
            {
                rebirthPos2 = GameObject.Find("PathSolider/point_XX").transform.position;
            }
        }
        if (uimanager.mapSelect == MapSelect.threeVSthree)
        {
            if (roleCamp == Role_Camp.Red)
            {
                rebirthPos2 = GameObject.Find("RebirthPos/RebirthPos_Red").transform.position;
            }
            else
            {
                rebirthPos2 = GameObject.Find("RebirthPos/RebirthPos_Blue").transform.position;
            }
        }
        transform.position = rebirthPos2;
        IsDeath            = false;
        ani.SetTrigger("CanReAlive");
        stateAni = State_Ani.State_Idle;
        agent.Resume();
        SetMoveTarget(rebirthPos2 + Vector3.forward * 2f);
        Hp = HpMax;
        Mp = MpMax;
    }
Example #7
0
    public void IntiRoleRebirthData()
    {
        Debug.Log("复活啦");
//		transform.Find ("MeshSelf").gameObject.SetActive (true);
        transform.Find("weapon/WEAPON_1").gameObject.SetActive(true);
        transform.GetComponent <HpShow> ().canShow = true;
        colRole.enabled   = true;
        colRole.isTrigger = false;
        if (uimanager.mapSelect == MapSelect.oneVSone)
        {
            if (roleCamp == Role_Camp.Red)
            {
                transform.position = GameObject.Find("PathSolider/point_00").transform.position;
            }
            else
            {
                transform.position = GameObject.Find("PathSolider/point_XX").transform.position;
            }
        }
        if (uimanager.mapSelect == MapSelect.threeVSthree)
        {
            if (roleCamp == Role_Camp.Red)
            {
                transform.position = GameObject.Find("RebirthPos/RebirthPos_Red").transform.position;
            }
            else
            {
                transform.position = GameObject.Find("RebirthPos/RebirthPos_Blue").transform.position;
            }
        }
        IsDeath = false;
        ani.SetTrigger("CanReAlive");
        stateAni = State_Ani.State_Idle;
        Hp       = HpMax;
        Mp       = MpMax;
    }