Esempio n. 1
0
    /// <summary>
    /// 开始状态
    /// </summary>
    public override void OnEnter()
    {
        base.OnEnter();
        if (m_BaseObject == null)
        {
            return;
        }
        if (m_SkillNode == null)
        {
            return;
        }
        Fix64      attackDistince = (Fix64)m_SkillNode.dist;
        BaseObject targetObject   = m_BaseObject.FindTarget(attackDistince);

        if (m_SkillNode.is_turnround && m_TargetPos != FixVector3.Zero)
        {
            FixVector3 relativePos = m_TargetPos - m_BaseObject.m_Pos;
            relativePos = new FixVector3(relativePos.x, Fix64.Zero, relativePos.z);
            Quaternion rotation = Quaternion.LookRotation(relativePos.ToVector3(), Vector3.up);
            m_BaseObject.m_Rotation = new FixVector3((Fix64)rotation.eulerAngles.x, (Fix64)rotation.eulerAngles.y, (Fix64)rotation.eulerAngles.z);
            m_BaseObject.m_Angles   = relativePos.GetNormalized();
            #region 显示层
            if (GameData.m_IsExecuteViewLogic)
            {
                m_BaseObject.m_VGo.transform.rotation = rotation;
            }
            #endregion
        }
        m_BaseObject.m_IsSkill = true;
        #region 显示层
        if (GameData.m_IsExecuteViewLogic)
        {
            m_Animator.SetInteger(m_StateParameter, m_SkillIndex);
            if (m_BaseObject is Player && (m_BaseObject as Player).m_PlayerData.m_RoleId == GameData.m_CurrentRoleId)
            {
                GameData.m_GameManager.m_UIManager.m_UpdateBattleSkillCDUICallback((int)m_SkillNode.cooling, m_SkillIndex);
            }
            #region  加载施法特效
            if (m_SkillNode.effect != null && m_SkillNode.effect.Length > 0)
            {
                for (int i = 0; i < m_SkillNode.effect.Length; i++)//加载施法特效
                {
                    if (i >= m_SkillNode.effect_start.Length || i >= m_SkillNode.effect_end.Length)
                    {
                        //Debug.LogError("     施法特效开始时间,结束时间数组长度不对       ");
                        return;
                    }
                    int   count_temp = 0;
                    Delay delay      = new Delay();
                    delay.DelayDo((Fix64)m_SkillNode.effect_start[i], () =>
                    {
                        string eff = m_SkillNode.effect[count_temp];
                        if (m_BaseObject.m_Data.m_Type == ObjectType.PLAYER && !string.IsNullOrEmpty(eff))
                        {
                            GameObject effectGo = Resources.Load <GameObject>(string.Format("{0}/{1}/{2}/{3}", GameData.m_EffectPath, "Heros", (m_BaseObject as Player).m_PlayerData.m_HeroResourceName, eff));
                            if (effectGo != null)
                            {
                                m_AniEffect = GameObject.Instantiate(effectGo);
                            }
                        }
                        if (m_BaseObject.m_Data.m_Type == ObjectType.MONSTER && !string.IsNullOrEmpty(eff))
                        {
                            GameObject effectGo = Resources.Load <GameObject>(string.Format("{0}/{1}/{2}/{3}", GameData.m_EffectPath, "Monster", (m_BaseObject as Monster).m_MonsterData.m_MonsterResourceName, eff));
                            if (effectGo != null)
                            {
                                m_AniEffect = GameObject.Instantiate(effectGo);
                            }
                        }
                        if (m_AniEffect == null)
                        {
                            return;
                        }
                        if (/*count_temp >= m_SkillNode.effect_position.Length ||*/ count_temp >= m_SkillNode.effect_positionxyz.Count)
                        {
                            //Debug.LogError("     施法特效挂点数组,位置偏移数组长度不对       ");
                            return;
                        }
                        #region 后修改为挂点
                        m_AniEffect.transform.parent = m_BaseObject.m_VGo.transform;
                        #endregion
                        m_AniEffect.transform.localPosition = Vector3.zero + m_SkillNode.effect_positionxyz[count_temp];
                        m_AniEffect.transform.localRotation = Quaternion.Euler(Vector3.zero);
                        m_AniEffect.transform.localScale    = Vector3.one;
                        Delay end_delay = new Delay();
                        end_delay.InitDestory(m_AniEffect, (Fix64)m_SkillNode.effect_end[count_temp]);
                        GameData.m_GameManager.m_DelayManager.m_DelayList.Add(end_delay);
                        count_temp++;
                    });
                    GameData.m_GameManager.m_DelayManager.m_DelayList.Add(delay);
                }
            }
            #endregion
        }
        #endregion
        #region 创建子弹
        if (m_SkillNode.bullet_id != null && m_SkillNode.bullet_id.Length > 0)
        {
            count_temp = 0;
            for (int i = 0; i < m_SkillNode.bullet_id.Length; i++)
            {
                if (i >= m_SkillNode.bullet_time.Length)
                {
                    //Debug.LogError("     子弹触发时间点数组长度不对       ");
                    return;
                }
                Delay delay = new Delay();
                delay.DelayDo((Fix64)m_SkillNode.bullet_time[i], () =>
                {
                    BaseBullet m_SkillState  = new BaseBullet();
                    Bullet_ValueClass bullet = new Bullet_ValueClass();
                    bullet.m_BulletIndex     = (Fix64)count_temp;
                    if (m_SkillNode.bullet_id != null)
                    {
                        bullet.m_BulletId = (Fix64)m_SkillNode.bullet_id[count_temp];
                    }
                    else
                    {
                        //Debug.LogError("bullet_id");
                    }
                    if (m_SkillNode.bul_target_type != null)
                    {
                        bullet.m_bul_target_type = (Fix64)m_SkillNode.bul_target_type[count_temp];
                    }
                    else
                    {
                        //Debug.LogError("bul_target_type");
                    }
                    if (m_SkillNode.bul_target_value != null)
                    {
                        //bullet.m_bul_target_value = new Fix64[m_SkillNode.bul_target_value[count_temp].Length];
                        //for (int j = 0; j < m_SkillNode.bul_target_value[count_temp].Length; j++)
                        //{
                        //    bullet.m_bul_target_value[j] = (Fix64)m_SkillNode.bul_target_value[count_temp][j];
                        //}
                        bullet.m_bul_target_value = (Fix64)m_SkillNode.bul_target_value[count_temp][0];
                    }
                    else
                    {
                        //Debug.LogError("bul_target_value");
                    }
                    if (m_SkillNode.bul_target_size != null)
                    {
                        bullet.m_bul_target_size = (Fix64)m_SkillNode.bul_target_size[count_temp];
                    }
                    else
                    {
                        //Debug.LogError("bul_target_size");
                    }
                    if (m_SkillNode.bul_start != null)
                    {
                        bullet.m_bul_start = (Fix64)m_SkillNode.bul_start[count_temp];
                    }
                    else
                    {
                        //Debug.LogError("bul_start");
                    }
                    if (m_SkillNode.firing_xyz != null)
                    {
                        bullet.m_firing_xyz = (FixVector3)m_SkillNode.firing_xyz[count_temp];
                    }
                    else
                    {
                        //Debug.LogError("firing_xyz");
                    }
                    bullet.m_bul_end = (Fix64)m_SkillNode.bul_end;
                    if (m_SkillNode.bul_end_xyz != null)
                    {
                        bullet.m_bul_end_xyz = (FixVector3)m_SkillNode.bul_end_xyz[count_temp];
                    }
                    else
                    {
                        //Debug.LogError("bul_end_xyz");
                    }
                    if (m_SkillNode.bul_end_angle != null)
                    {
                        bullet.m_bul_end_angle = (Fix64)m_SkillNode.bul_end_angle[count_temp];
                    }
                    else
                    {
                        //Debug.LogError("bul_end_angle");
                    }
                    if (m_SkillNode.bul_son_max != null)
                    {
                        bullet.m_bul_son_max = (Fix64)m_SkillNode.bul_son_max[count_temp];
                    }
                    else
                    {
                        //Debug.LogError("bul_son_max");
                    }
                    if (m_SkillNode.max_bul != null)
                    {
                        bullet.m_max_bul = (Fix64)m_SkillNode.max_bul[count_temp];
                    }
                    else
                    {
                        //Debug.LogError("m_max_bul");
                    }
                    switch (m_SkillNode.skill_usetype)
                    {
                    case SkillUseType.None:
                        break;

                    case SkillUseType.Direction:    //方向型
                        bullet.v_pos = m_BaseObject.m_Pos + (FixVector3)(m_BaseObject.m_Angles.ToVector3().normalized * 10);

                        break;

                    case SkillUseType.Point:    //坐标点型
                        bullet.v_pos = (FixVector3)m_TargetObject.m_Pos;

                        break;

                    case SkillUseType.Forward:    //直接释放型
                        bullet.v_pos = m_BaseObject.m_Pos + (FixVector3)(m_BaseObject.m_Angles.ToVector3().normalized * 10);
                        break;

                    case SkillUseType.Target:    //目标型
                        bullet.v_taregt.Add(m_TargetObject);
                        bullet.m_taregt = m_TargetObject;
                        break;

                    default:
                        break;
                    }
                    for (int j = 0; j < (int)bullet.m_max_bul; j++)
                    {
                        m_SkillState.CreateBullet(m_BaseObject, m_SkillNode, bullet, m_Parameter);
                        m_SkillState.OnEnter();
                        GameData.m_GameManager.m_BulletManager.m_AttackList.Add(m_SkillState);
                    }
                    count_temp++;
                });
                GameData.m_GameManager.m_DelayManager.m_DelayList.Add(delay);
            }
        }
        #endregion
    }
Esempio n. 2
0
    /// <summary>
    /// 创建子子弹
    /// </summary>
    /// <param name="createType"></param>
    /// 1,销毁触发,碰撞触发
    public void CreateSonBullet(int createType, SkillNode skillNode, Vector3 targetpos = new Vector3())
    {
        if (m_BulletClass.son_now > m_BulletClass.m_bul_son_max - (Fix64)1)//最大轮数限制
        {
            return;
        }
        if (m_BulletNode.newbul != null && m_BulletNode.newbul.Count > 0)
        {
            int count_temp = 0;
            for (int i = 0; i < m_BulletNode.newbul.Count; i++)
            {
                if (createType != m_BulletNode.newbul[i][0])//符合触发类型时创建
                {
                    return;
                }
                if (i >= m_BulletNode.newbul.Count)
                {
                    //Debug.LogError("     子弹触发时间点数组长度不对       ");
                    return;
                }
                //Debug.LogError(createType + "    创建子子弹" + m_AttackTime);
                if (i == 0)
                {
                    m_BulletClass.son_now = m_BulletClass.son_now + (Fix64)1;
                }
                double time = 0;
                if (m_BulletNode.newbul_dalay.Count > i && m_BulletNode.newbul_dalay[i] != null)
                {
                    time = m_BulletNode.newbul_dalay[i][0];
                }
                Delay delay = new Delay();
                delay.DelayDo((Fix64)time, () =>
                {
                    ////Debug.LogError("触发轮数:" + m_BulletClass.son_now);
                    BaseBullet m_SkillState  = new BaseBullet();
                    Bullet_ValueClass bullet = m_BulletClass;
                    bullet.m_BulletIndex     = (Fix64)count_temp;
                    if (m_BulletNode.newbul.Count > 0 && m_BulletNode.newbul[count_temp] != null)
                    {
                        bullet.m_BulletId = (Fix64)m_BulletNode.newbul[count_temp][1];
                    }
                    else
                    {
                        //Debug.LogError("newbul");
                    }
                    //------------
                    if (m_BulletNode.newbul_target_type[count_temp] != null && m_BulletNode.newbul_target_type[count_temp].Length > 0)
                    {
                        bullet.m_bul_target_type = (Fix64)m_BulletNode.newbul_target_type[count_temp][0];
                    }
                    else
                    {
                        //Debug.LogError("newbul_target_type");
                    }
                    //------------
                    if (m_BulletNode.newbul_target_value.Count > 0 && m_BulletNode.newbul_target_value[count_temp] != null && m_BulletNode.newbul_target_value[count_temp].Length > 0)
                    {
                        //bullet.m_bul_target_value = new Fix64[m_BulletNode.newbul_target_value[count_temp].Length];
                        //for (int j = 0; j < m_BulletNode.newbul_target_value[count_temp].Length; j++)
                        //{
                        //    bullet.m_bul_target_value[j] = (Fix64)m_BulletNode.newbul_target_value[count_temp][j];
                        //}
                        bullet.m_bul_target_value = (Fix64)m_BulletNode.newbul_target_value[count_temp][0];
                    }
                    else
                    {
                        //Debug.LogError("newbul_target_value");
                    }
                    //------------
                    if (m_BulletNode.newbul_target_size.Count > 0 && m_BulletNode.newbul_target_size[count_temp] != null && m_BulletNode.newbul_target_size[count_temp].Length > 0)
                    {
                        bullet.m_bul_target_size = (Fix64)m_BulletNode.newbul_target_size[count_temp][0];
                    }
                    else
                    {
                        //Debug.LogError("newbul_target_size");
                    }
                    //------------
                    if (m_BulletNode.newbul_firing.Count > 0 && m_BulletNode.newbul_firing[count_temp] != null && m_BulletNode.newbul_firing[count_temp].Length > 0)
                    {
                        bullet.m_bul_start = (Fix64)m_BulletNode.newbul_firing[count_temp][0];
                    }
                    else
                    {
                        //Debug.LogError("newbul_firing");
                    }
                    //------------
                    if (m_BulletNode.newbul_firing_xyz.Count > 0 && m_BulletNode.newbul_firing_xyz[count_temp] != null)
                    {
                        bullet.m_firing_xyz = (FixVector3)m_BulletNode.newbul_firing_xyz[count_temp];
                    }
                    else
                    {
                        //Debug.LogError("newbul_firing_xyz");
                    }
                    //------------
                    if (m_BulletNode.newbul_end.Count > 0 && m_BulletNode.newbul_end[count_temp] != null && m_BulletNode.newbul_end[count_temp].Length > 0)
                    {
                        bullet.m_bul_end = (Fix64)m_BulletNode.newbul_end[count_temp][0];
                    }
                    else
                    {
                        //Debug.LogError("newbul_end");
                    }
                    //------------
                    if (m_BulletNode.newbul_end_xyz.Count > 0 && m_BulletNode.newbul_end_xyz[count_temp] != null)
                    {
                        bullet.m_bul_end_xyz = (FixVector3)m_BulletNode.newbul_end_xyz[count_temp];
                    }
                    else
                    {
                        //Debug.LogError("newbul_end_xyz");
                    }
                    //------------
                    if (m_BulletNode.newbul_angle.Count > 0 && m_BulletNode.newbul_angle[count_temp] != null && m_BulletNode.newbul_angle[count_temp].Length > 0)
                    {
                        bullet.m_bul_end_angle = (Fix64)m_BulletNode.newbul_angle[count_temp][0];
                    }
                    else
                    {
                        //Debug.LogError("newbul_angle");
                    }
                    //------------
                    if (m_BulletNode.newbul_origin.Count > 0 && m_BulletNode.newbul_origin[count_temp] != null && m_BulletNode.newbul_origin[count_temp].Length > 0)
                    {
                        bullet.newbul_origin = (Fix64)m_BulletNode.newbul_origin[count_temp][0];
                        if (bullet.newbul_origin == (Fix64)1)
                        {
                            bullet.old_pos = (FixVector3)targetpos;
                        }
                        else if (bullet.newbul_origin == (Fix64)3)
                        {
                            bullet.old_pos = m_Pos;
                        }
                    }
                    else
                    {
                        //Debug.LogError("newbul_origin");
                    }
                    //------------
                    if (m_BulletNode.newbul_target_extra.Count > 0 && m_BulletNode.newbul_target_extra[count_temp] != null && m_BulletNode.newbul_target_extra[count_temp].Length > 0)
                    {
                        bullet.newbul_target_extra = (Fix64)m_BulletNode.newbul_target_extra[count_temp][0];
                    }
                    else
                    {
                        //Debug.LogError("newbul_target_extra");
                    }
                    //------------
                    if (m_BulletNode.newbul_max.Count > 0 && m_BulletNode.newbul_max[count_temp] != null && m_BulletNode.newbul_max[count_temp].Length > 0)
                    {
                        bullet.m_max_bul = (Fix64)m_BulletNode.newbul_max[count_temp][0];
                    }
                    else
                    {
                        //Debug.LogError("newbul_target_extra");
                    }
                    //------------
                    if (m_BulletNode.newbul_num_single.Count > 0 && m_BulletNode.newbul_num_single[count_temp] != null && m_BulletNode.newbul_num_single[count_temp].Length > 0)
                    {
                        bullet.newbul_num_single = new Fix64[m_BulletNode.newbul_num_single[count_temp].Length];
                        for (int j = 0; j < m_BulletNode.newbul_num_single[count_temp].Length; j++)
                        {
                            bullet.newbul_num_single[j] = (Fix64)m_BulletNode.newbul_num_single[count_temp][j];
                        }
                    }
                    else
                    {
                        //Debug.LogError("newbul_num_single");
                    }
                    //switch (m_Player.m_SkillNode.skill_usetype)
                    //{
                    //    case SkillUseType.None:
                    //        break;
                    //    case SkillUseType.Direction://方向型
                    //        bullet.v_pos = (FixVector3)(m_Player.m_Angles.ToVector3().normalized * 10);

                    //        break;
                    //    case SkillUseType.Point://坐标点型
                    //        bullet.v_pos = (FixVector3)m_Player.m_TargetPlayer.m_Pos;

                    //        break;
                    //    case SkillUseType.Forward://直接释放型
                    //        bullet.v_pos = (FixVector3)(m_Player.m_Angles.ToVector3().normalized * 10);
                    //        break;
                    //    case SkillUseType.Target://目标型
                    //        bullet.v_taregt.Add(m_Player.m_TargetPlayer);
                    //        bullet.m_taregt = m_Player.m_TargetPlayer;
                    //        break;
                    //    default:
                    //        break;
                    //}
                    for (int j = 0; j < (int)bullet.m_max_bul; j++)
                    {
                        m_SkillState.CreateBullet(m_BaseObject, skillNode, bullet, m_Parameter);
                        m_SkillState.OnEnter();
                        GameData.m_GameManager.m_BulletManager.m_AttackList.Add(m_SkillState);
                    }
                    count_temp++;
                });
                GameData.m_GameManager.m_DelayManager.m_DelayList.Add(delay);
            }
        }
    }