Beispiel #1
0
    /// <summary>
    /// 遍历状态
    /// </summary>
    public void UpdateLogic()
    {
        Fix64 distince = FixVector3.Distance(m_TargetObject.m_Pos, m_Pos);

        if (distince < m_AttackDistince)
        {
            m_TargetObject.FallDamage(50);
            Destroy();
        }
        else
        {
            //普通攻击子弹自动改变朝向
            FixVector3 relativePos = m_TargetObject.m_Pos - m_Pos;
            Quaternion rotation    = Quaternion.LookRotation(relativePos.ToVector3(), Vector3.up);
            m_Angle = relativePos.GetNormalized();
            m_Pos  += m_Angle * m_AttackSpeed;
            #region 显示层
            if (GameData.m_IsExecuteViewLogic)
            {
                if (m_Attack != null)
                {
                    m_Attack.transform.rotation  = rotation;
                    m_Attack.transform.position += m_Pos.ToVector3();
                }
            }
            #endregion
        }
    }
Beispiel #2
0
    //- 初始化数据
    //
    // @param src 发射源
    // @param dest 射击目标
    // @param poOri 发射的起始位置
    // @param poDst 发射的目标位置
    // @return none.
    public override void initData(LiveObject src, LiveObject dest, FixVector3 poOri, FixVector3 poDst)
    {
        base.initData(src, dest, poOri, poDst);

        Fix64 distance = FixVector3.Distance(poOri, poDst);

        m_fixMoveTime = distance / m_fixSpeed;
    }
Beispiel #3
0
    //检测子弹目标范围参数
    public bool checkIsInBulTargetSize(BaseObject Target)
    {
        Fix64 distance = FixVector3.Distance(Target.m_Pos, m_Pos);

        if (distance <= m_BulletClass.m_bul_target_size)
        {
            return(true);
        }
        return(false);
    }
Beispiel #4
0
    //- 检测敌兵是否走出攻击范围
    // Some description, can be over several lines.
    // @return value description.
    void checkSoldierOutRange()
    {
        if (null != lockedAttackUnit)
        {
            Fix64 distance = FixVector3.Distance(m_fixv3LogicPosition, lockedAttackUnit.m_fixv3LogicPosition);

            //如果走出攻击范围,则让塔恢复到待机状态
            if (distance > attackRange)
            {
                setPrevStateName("towerstand");
            }
        }
    }
    //- ���б��Ƿ��߳�������Χ
    private void checkSoldierOutRange()
    {
        if (lockedAttackUnit != null)
        {
            Fix64 distance = FixVector3.Distance(m_fixv3LogicPos, lockedAttackUnit.m_fixv3LogicPos);

            //����߳�������Χ,�������ָ�������״̬
            if (distance > attackRange)
            {
                setPrevStateName("towerstand");
            }
        }
    }
Beispiel #6
0
    /// <summary>
    /// 每帧更新AI逻辑
    /// </summary>
    public void UpdateLogic()
    {
        if (m_Monster == null || m_Monster.m_MonsterData == null)
        {
            return;
        }
        if (m_Monster.m_IsDie)
        {
            return;
        }
        if (m_Monster.m_IsAttack)
        {
            return;
        }
        if (m_Monster.m_IsSkill)
        {
            return;
        }
        if (m_Monster.m_IsHit)
        {
            return;
        }
        m_Monster.m_SkillNode = m_Monster.m_MonsterData.GetSkillNode(1);
        Fix64      attackDistance = (Fix64)m_Monster.m_SkillNode.aoe_long;
        BaseObject target         = m_Monster.FindTarget(attackDistance);

        if (target != null)
        {
            m_Monster.m_State = new AttackState();
            m_Monster.m_State.OnInit(m_Monster, "1");
            m_Monster.m_State.OnEnter();
        }
        else
        {
            m_Monster.m_State = new MoveState();
            m_Monster.m_State.OnInit(m_Monster, m_Parameter);
            m_Monster.m_State.OnEnter();
            Fix64 distince = FixVector3.Distance(m_Monster.m_MonsterData.m_NaviPos, m_Monster.m_Pos);
            if (distince <= m_distince)
            {
                m_Monster.m_State = new MoveEndState();
                m_Monster.m_State.OnInit(m_Monster);
                m_Monster.m_State.OnEnter();
            }
        }
    }
    public override void updateLogic()
    {
        for (int i = 0; i < GameData.g_listSoldier.Count; i++)
        {
            var soldier = GameData.g_listSoldier[i];

            Fix64 distance = FixVector3.Distance(m_unit.m_fixv3LogicPos, soldier.m_fixv3LogicPos);
            s_scTestContent += distance.ToString() + ",";

            if (distance <= (Fix64)m_unit.attackRange)
            {
                s_fixTestCount         += distance;
                m_unit.lockedAttackUnit = soldier;

                m_unit.addAttackingObj(soldier);
                soldier.addAttackMeObj(m_unit);

                m_unit.changeState("towerattack");
            }
        }
    }
Beispiel #8
0
    public bool IsInRange(BulletNode m_BulletNode, BaseObject attack, BaseObject Target)
    {
        if (m_BulletNode.col_size_value == null)
        {
            return(false);
        }
        float angle    = 0;
        Fix64 distance = Fix64.Zero;

        switch (m_BulletNode.col_size_type)
        {
        case 1:    //扇形/环形
            if (m_BulletNode.col_size_value != null && m_BulletNode.col_size_value.Length == 4)
            {
                angle    = Mathf.Acos(Vector3.Dot(m_BaseObject.m_Angles.ToVector3().normalized, (Target.m_Pos - attack.m_Pos).ToVector3().normalized)) * Mathf.Rad2Deg;
                distance = Target.m_Data.m_Type == ObjectType.PLAYER ? (FixVector3.Distance(Target.m_Pos, m_Pos) - Fix64.FromRaw(200)) : (FixVector3.Distance(Target.m_Pos, m_Pos) - Fix64.FromRaw(100));
                if ((angle <= m_BulletNode.col_size_value[0] || m_BulletNode.col_size_value[0] <= 0) && ((float)distance <= m_BulletNode.col_size_value[1]) && ((float)distance >= m_BulletNode.col_size_value[2]))
                {
                    return(true);
                }
            }
            break;

        case 2:    //矩形
            if (m_BulletNode.col_size_value != null && m_BulletNode.col_size_value.Length == 5)
            {
                FixVector3 p1 = new FixVector3(m_Pos.x - (Fix64)m_BulletNode.col_size_value[2], m_Pos.y, m_Pos.x + (Fix64)m_BulletNode.col_size_value[0]);
                FixVector3 p2 = new FixVector3(m_Pos.x + (Fix64)m_BulletNode.col_size_value[3], m_Pos.y, m_Pos.x + (Fix64)m_BulletNode.col_size_value[0]);
                FixVector3 p3 = new FixVector3(m_Pos.x + (Fix64)m_BulletNode.col_size_value[3], m_Pos.y, m_Pos.x - (Fix64)m_BulletNode.col_size_value[1]);
                FixVector3 p4 = new FixVector3(m_Pos.x - (Fix64)m_BulletNode.col_size_value[2], m_Pos.y, m_Pos.x - (Fix64)m_BulletNode.col_size_value[1]);
                FixVector3 p  = Target.m_Pos;
                return(GetCross(p1, p2, p) * GetCross(p3, p4, p) >= (Fix64)0 && GetCross(p2, p3, p) * GetCross(p4, p1, p) >= (Fix64)00);
            }
            break;

        default:
            break;
        }
        return(false);
    }
Beispiel #9
0
    //查找攻击目标
    public virtual BaseObject FindTarget(Fix64 attackDistince)
    {
        Fix64      preDistance = attackDistince;
        BaseObject preObject   = null;

        for (int i = 0; i < GameData.m_ObjectList.Count; i++)
        {
            if (GameData.m_ObjectList[i] == null || GameData.m_ObjectList[i].m_Data == null)
            {
                continue;
            }
            if (GameData.m_ObjectList[i].m_Data.m_CampId == m_Data.m_CampId)
            {
                continue;
            }
            Fix64 distance = Fix64.Zero;
            if (GameData.m_ObjectList[i].m_Data.m_Type == ObjectType.PLAYER)
            {
                distance = FixVector3.Distance(GameData.m_ObjectList[i].m_Pos, m_Pos) - Fix64.FromRaw(200);
            }
            else if (GameData.m_ObjectList[i].m_Data.m_Type == ObjectType.MONSTER)
            {
                distance = FixVector3.Distance(GameData.m_ObjectList[i].m_Pos, m_Pos) - Fix64.FromRaw(100);
            }
            else if (GameData.m_ObjectList[i].m_Data.m_Type == ObjectType.ARROW_TOWER)
            {
                distance = FixVector3.Distance(GameData.m_ObjectList[i].m_Pos, m_Pos) - Fix64.FromRaw(500);
            }
            else if (GameData.m_ObjectList[i].m_Data.m_Type == ObjectType.CRYSTAL_TOWER)
            {
                distance = FixVector3.Distance(GameData.m_ObjectList[i].m_Pos, m_Pos) - Fix64.FromRaw(1000);
            }
            if (distance < preDistance)
            {
                preObject   = GameData.m_ObjectList[i];
                preDistance = distance;
            }
        }
        return(preObject);
    }
Beispiel #10
0
    /// <summary>
    /// 查找离玩家最近的可攻击目标
    /// </summary>
    /// <param name="skillNode"></param>
    /// <returns></returns>
    public BaseObject FindTarget(SkillNode skillNode)
    {
        Fix64      preDistance = Fix64.Zero;
        BaseObject preObject   = null;

        for (int i = 0; i < GameData.m_ObjectList.Count; i++)
        {
            if (GameData.m_ObjectList[i] == null || GameData.m_ObjectList[i].m_Data == null)
            {
                continue;
            }
            if (GameData.m_ObjectList[i].m_Data.m_CampId == m_PlayerData.m_CampId)
            {
                continue;
            }
            Fix64 distance = Fix64.Zero;
            if (GameData.m_ObjectList[i].m_Data.m_Type == ObjectType.PLAYER)
            {
                distance = FixVector3.Distance(GameData.m_ObjectList[i].m_Pos, m_Pos) - Fix64.FromRaw(200);
            }
            else if (GameData.m_ObjectList[i].m_Data.m_Type == ObjectType.MONSTER)
            {
                distance = FixVector3.Distance(GameData.m_ObjectList[i].m_Pos, m_Pos) - Fix64.FromRaw(100);
            }
            else if (GameData.m_ObjectList[i].m_Data.m_Type == ObjectType.ARROW_TOWER)
            {
                distance = FixVector3.Distance(GameData.m_ObjectList[i].m_Pos, m_Pos) - Fix64.FromRaw(500);
            }
            else if (GameData.m_ObjectList[i].m_Data.m_Type == ObjectType.CRYSTAL_TOWER)
            {
                distance = FixVector3.Distance(GameData.m_ObjectList[i].m_Pos, m_Pos) - Fix64.FromRaw(1000);
            }
            if ((preDistance == Fix64.Zero || preDistance > distance) && (float)distance <= skillNode.aoe_long)
            {
                preObject   = GameData.m_ObjectList[i];
                preDistance = distance;
            }
        }
        return(preObject);
    }