示例#1
0
    protected DropItemInfo GetClosestDropItem(List <DropItemInfo> _targetList)
    {
        Vector3      curPos    = GameCenter.curMainPlayer.transform.position;
        Vector3      targetPos = Vector3.zero;
        float        distance  = 0;
        DropItemInfo dropInfo  = null;

        for (int i = 0, length = _targetList.Count; i < length; i++)
        {
            targetPos = ActorMoveFSM.LineCast(new Vector2(targetList[i].ServerPos.x, targetList[i].ServerPos.y), true);
            Vector3[] path = GameStageUtility.StartPath(targetPos, curPos);
            if (path != null)
            {
                float tempDistance = path.Length == 2 ? Vector3.Distance(targetPos, curPos) : path.CountPathDistance();
                if (distance == 0)
                {
                    distance = tempDistance;
                    dropInfo = _targetList[i];
                }
                else
                {
                    if (tempDistance < distance)
                    {
                        distance = tempDistance;
                        dropInfo = _targetList[i];
                    }
                }
            }
        }
        if (dropInfo != null)
        {
            return(dropInfo);
        }
        return(_targetList.Count > 0 ? _targetList[0] : null);
    }
示例#2
0
文件: Utils.cs 项目: atom-chen/tianyu
    /// <summary>
    /// 获取目标点(NPC)周围的随机一个可站立点
    /// </summary>
    public static Vector3 GetRandomPos(Vector3 _tarVector3)
    {
        if (_tarVector3.Equals(Vector3.zero))
        {
            return(Vector3.zero);
        }
        List <Vector3> posList = new List <Vector3>();
        Vector3        pos     = _tarVector3;

        posList.Add(new Vector3(pos.x + 1, 0, pos.z));
        posList.Add(new Vector3(pos.x + 1, 0, pos.z + 1));
        posList.Add(new Vector3(pos.x + 1, 0, pos.z - 1));
        posList.Add(new Vector3(pos.x - 1, 0, pos.z));
        posList.Add(new Vector3(pos.x - 1, 0, pos.z + 1));
        posList.Add(new Vector3(pos.x - 1, 0, pos.z - 1));
        posList.Add(new Vector3(pos.x, 0, pos.z));
        posList.Add(new Vector3(pos.x, 0, pos.z + 1));
        posList.Add(new Vector3(pos.x, 0, pos.z - 1));
        Vector3 initPos = Vector3.zero;

        for (int i = 0; i < posList.Count; i++)
        {
            if (GameStageUtility.CheckPosition(pos, posList[i]))
            {
                initPos = posList[i];
                break;
            }
        }
        if (initPos == Vector3.zero)
        {
            initPos = pos;
        }
        return(initPos);
    }
示例#3
0
        static int _m_GetClosestSmartActor_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    PlayerBase _player = (PlayerBase)translator.GetObject(L, 1, typeof(PlayerBase));
                    System.Collections.Generic.List <SmartActor> smartActors = (System.Collections.Generic.List <SmartActor>)translator.GetObject(L, 2, typeof(System.Collections.Generic.List <SmartActor>));
                    RelationType _relationType; translator.Get(L, 3, out _relationType);
                    float        _instance = (float)LuaAPI.lua_tonumber(L, 4);

                    SmartActor __cl_gen_ret = GameStageUtility.GetClosestSmartActor(_player, smartActors, _relationType, ref _instance);
                    translator.Push(L, __cl_gen_ret);
                    LuaAPI.lua_pushnumber(L, _instance);



                    return(2);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
示例#4
0
    /// <summary>
    /// 获取路径最近的怪物
    /// </summary>
    /// <param name="_gameStage"></param>
    /// <param name="_player"></param>
    /// <param name="_needAlive"></param>
    /// <returns></returns>
    public static Monster GetClosestMob(this GameStage _gameStage, SmartActor _player, ref float _distance)
    {
        List <Monster> mobs         = _gameStage.GetMobs();
        FDictionary    distanceDic  = new FDictionary();
        FDictionary    mobDic       = new FDictionary();
        int            selfCamp     = _player.Camp;
        SceneType      sceneType    = GameCenter.curGameStage.SceneType;
        Vector3        selfPosition = _player.transform.position;


        for (int i = 0; i < mobs.Count; i++)
        {
            Monster mob = mobs[i];
            if (mob.isDummy || !mob.IsShowing || mob.isDead)
            {
                continue;
            }
            if (mob.gameObject != null && !mob.isDead && !mob.IsActor &&
                ConfigMng.Instance.GetRelationType(selfCamp, mob.Camp, sceneType) == RelationType.AUTOMATEDATTACKS)
            {
                Vector3[] path = GameStageUtility.StartPath(selfPosition, mob.transform.position);
                if (path != null)
                {
                    if (path.Length != 2)
                    {
                        distanceDic.Add(mob.id, path.CountPathDistance());//距离计算方法改变
                    }
                    else
                    {
                        distanceDic.Add(mob.id, Vector3.Distance(selfPosition, mob.transform.position));
                    }
                    mobDic.Add(mob.id, mob);
                }
            }
        }
        int   closestOne = -1;
        float distance   = -1;

        foreach (int id in distanceDic.Keys)
        {
            if (distance < 0 || distance >= (float)distanceDic[id])
            {
                closestOne = id;
                distance   = (float)distanceDic[id];
                _distance  = distance;
            }
        }
        return(mobDic.ContainsKey(closestOne) ? mobDic[closestOne] as Monster : null);
    }
示例#5
0
    /// <summary>
    /// 获取路径最近指定关系随从 by吴江
    /// </summary>
    /// <param name="_gameStage"></param>
    /// <param name="_player"></param>
    /// <param name="_needAlive"></param>
    /// <returns></returns>
    public static OtherEntourage GetClosestEntourage(this GameStage _gameStage, SmartActor _player, RelationType _relationType, ref float _distance)
    {
        List <OtherEntourage> opcs        = _gameStage.GetOtherEntourages();
        FDictionary           distanceDic = new FDictionary();
        FDictionary           opcDic      = new FDictionary();
        int       selfCamp     = _player.Camp;
        SceneType sceneType    = GameCenter.curGameStage.SceneType;
        Vector3   selfPosition = _player.transform.position;

        for (int i = 0; i < opcs.Count; i++)
        {
            OtherEntourage opc = opcs[i];
            if (opc.isDummy || !opc.IsShowing)
            {
                continue;
            }
            if (opc.gameObject != null && !opc.isDead && !opc.IsActor &&
                ConfigMng.Instance.GetRelationType(selfCamp, opc.Camp, sceneType) == _relationType)
            {
                Vector3[] path = GameStageUtility.StartPath(selfPosition, opc.transform.position);
                if (path != null)
                {
                    if (path.Length != 2)
                    {
                        distanceDic.Add(opc.id, path.CountPathDistance());//距离计算方法改变
                    }
                    else
                    {
                        distanceDic.Add(opc.id, Vector3.Distance(selfPosition, opc.transform.position));
                    }
                    opcDic.Add(opc.id, opc);
                }
            }
        }
        int   closestOne = -1;
        float distance   = -1;

        foreach (int id in distanceDic.Keys)
        {
            if (distance < 0 || distance >= (float)distanceDic[id])
            {
                closestOne = id;
                distance   = (float)distanceDic[id];
                _distance  = distance;
            }
        }
        return(opcDic.ContainsKey(closestOne) ? opcDic[closestOne] as OtherEntourage : null);
    }
示例#6
0
文件: NPC.cs 项目: atom-chen/tianyu
    /// <summary>
    /// 获取一个逃跑点
    /// </summary>
    /// <param name="_avoidTarPos"></param>
    protected Vector3 GetAvoidPos(Vector3 _avoidTarPos)
    {
        int     dirY    = UnityEngine.Random.Range(0, 360);
        Vector3 dir     = new Vector3(Mathf.Sin(dirY * Mathf.Deg2Rad), 0.0f, Mathf.Cos(dirY * Mathf.Deg2Rad));
        Vector3 tarPost = _avoidTarPos + dir * 2 * startAvoidRange;

        Vector3[] path = GameStageUtility.StartPath(transform.position, tarPost);
        if (path != null)
        {
            return(tarPost);
        }
        else
        {
            return(GetAvoidPos(_avoidTarPos));
        }
    }
示例#7
0
    /// <summary>
    /// 获取路径最近的怪物
    /// </summary>
    /// <param name="_gameStage"></param>
    /// <param name="_player"></param>
    /// <param name="_needAlive"></param>
    /// <returns></returns>
    public static SmartActor GetClosestSmartActor(PlayerBase _player, List <SmartActor> smartActors, RelationType _relationType, ref float _instance)
    {
        List <SmartActor> smActors    = smartActors;
        FDictionary       distanceDic = new FDictionary();
        FDictionary       mobDic      = new FDictionary();


        int       selfCamp     = _player.Camp;
        SceneType sceneType    = GameCenter.curGameStage.SceneType;
        Vector3   selfPosition = _player.transform.position;

        for (int i = 0; i < smActors.Count; i++)
        {
            SmartActor smActor = smActors[i];
            if (smActor.gameObject != null && !smActor.isDead && !smActor.IsActor &&
                ConfigMng.Instance.GetRelationType(selfCamp, smActor.Camp, sceneType) == _relationType)
            {
                Vector3[] path = GameStageUtility.StartPath(selfPosition, smActor.transform.position);
                if (path != null)
                {
                    if (path.Length != 2)
                    {
                        distanceDic.Add(smActor.id, path.CountPathDistance());//距离计算方法改变
                    }
                    else
                    {
                        distanceDic.Add(smActor.id, Vector3.Distance(selfPosition, smActor.transform.position));
                    }
                    mobDic.Add(smActor.id, smActor);
                }
            }
        }
        int   closestOne = -1;
        float distance   = -1;

        foreach (int id in distanceDic.Keys)
        {
            if (distance < 0 || distance >= (float)distanceDic[id])
            {
                closestOne = id;
                distance   = (float)distanceDic[id];
            }
        }
        _instance = distance;
        return(mobDic.ContainsKey(closestOne) ? mobDic[closestOne] as SmartActor : null);
    }
示例#8
0
    /// <summary>
    /// 获取路径最近的场景物品
    /// </summary>
    /// <param name="_gameStage"></param>
    /// <param name="_player"></param>
    /// <param name="_needAlive"></param>
    /// <returns></returns>
    public static SceneItem GetClosestSceneItem(this GameStage _gameStage, PlayerBase _player)
    {
        List <SceneItem> sceneItems  = _gameStage.GetSceneItems();
        FDictionary      distanceDic = new FDictionary();
        FDictionary      sceneDic    = new FDictionary();
        //int selfCamp = _player.Camp;
        //SceneType sceneType = GameCenter.curGameStage.SceneType;
        Vector3 selfPosition = _player.transform.position;

        Debug.Log(sceneItems.Count);
        for (int i = 0; i < sceneItems.Count; i++)
        {
            SceneItem sceneItem = sceneItems[i];
            Debug.Log(sceneItem.isDummy + ":" + sceneItem.IsShowing);
            //    if (sceneItem.isDummy || !sceneItem.IsShowing) continue;
            if (sceneItem.gameObject != null)
            {
                Vector3[] path = GameStageUtility.StartPath(selfPosition, sceneItem.transform.position);
                if (path != null)
                {
                    if (path.Length != 2)
                    {
                        distanceDic.Add(sceneItem.id, path.CountPathDistance());//距离计算方法改变
                    }
                    else
                    {
                        distanceDic.Add(sceneItem.id, Vector3.Distance(selfPosition, sceneItem.transform.position));
                    }
                    sceneDic.Add(sceneItem.id, sceneItem);
                }
            }
        }
        int   closestOne = -1;
        float distance   = -1;

        foreach (int id in distanceDic.Keys)
        {
            if (distance < 0 || distance >= (float)distanceDic[id])
            {
                closestOne = id;
                Debug.Log(closestOne);
                distance = (float)distanceDic[id];
            }
        }
        return(sceneDic.ContainsKey(closestOne) ? sceneDic[closestOne] as SceneItem : null);
    }
示例#9
0
 /// <summary>
 /// 是否停止追踪
 /// </summary>
 /// <param name="_target"></param>
 /// <returns></returns>
 public bool CanPushAbilityCommand(InteractiveObject _target)
 {
     if (_target != null)
     {
         if (UserActor != null)
         {
             Vector3[] path = GameStageUtility.StartPath(UserActor.transform.position, _target.transform.position);
             if (path != null && path.Length > 0)
             {
                 float distance = path.CountPathDistance();
                 return(distance <= 0.5f * AttackDistance);//计算方式修改,解决穿墙放冲锋技能bug by邓成
             }
             else
             {
                 return((UserActor.transform.position - _target.transform.position).sqrMagnitude <= 0.5f * AttackDistance * AttackDistance);
             }
         }
     }
     return(PerformanceRef.castType == CastType.NOTARGET);
 }
示例#10
0
    public void OnSpawned(AlertAreaType _type, Color _color, float _rotY, float _wid, float _length, float _duration)
    {
        base.OnSpawned();
        this.gameObject.transform.eulerAngles = new Vector3(90, _rotY, 0);
        Projector pro = this.gameObject.GetComponent <Projector>();

        pro.aspectRatio      = _wid / _length;
        pro.orthographicSize = Mathf.Max(_length, _wid);
        mat = pro.material;
        if (mat != null)
        {
            mat.mainTexture = GameStageUtility.GetTextureByType(_type);
            fromColor       = new Color(_color.r, _color.g, _color.b, 0);
            mat.color       = fromColor;
            aimColor        = _color;
            startTime       = Time.time;
            shakeScale      = Mathf.Abs(startShake);
        }
        Invoke("StartReturn", _duration);
    }
示例#11
0
文件: Utils.cs 项目: atom-chen/tianyu
    /// <summary>
    /// 获取主角身边的随机一个可站立点
    /// </summary>
    public static Vector3 GetRandomPos(Transform _tar)
    {
        if (_tar == null)
        {
            return(Vector3.zero);
        }
        List <Vector3> posList = new List <Vector3>();
        Vector3        pos     = _tar.position;

        posList.Add(new Vector3(pos.x + 1, 0, pos.z));
        posList.Add(new Vector3(pos.x + 1, 0, pos.z + 1));
        posList.Add(new Vector3(pos.x + 1, 0, pos.z - 1));
        posList.Add(new Vector3(pos.x - 1, 0, pos.z));
        posList.Add(new Vector3(pos.x - 1, 0, pos.z + 1));
        posList.Add(new Vector3(pos.x - 1, 0, pos.z - 1));
        posList.Add(new Vector3(pos.x, 0, pos.z));
        posList.Add(new Vector3(pos.x, 0, pos.z + 1));
        posList.Add(new Vector3(pos.x, 0, pos.z - 1));
        Vector3 initPos = Vector3.zero;

        System.Random random = new System.Random();
        while (posList.Count > 0)       //用随机,否则都是一个点
        {
            int count = posList.Count;
            int index = random.Next(0, count - 1);
            if (GameStageUtility.CheckPosition(pos, posList[index]))
            {
                initPos = posList[index];
                break;
            }
            else
            {
                posList.RemoveAt(index);
            }
        }
        if (initPos == Vector3.zero)
        {
            initPos = pos;
        }
        return(ActorMoveFSM.LineCast(initPos, true));
    }
示例#12
0
        static int _m_CheckPath_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    UnityEngine.Vector3[] _originPath = (UnityEngine.Vector3[])translator.GetObject(L, 1, typeof(UnityEngine.Vector3[]));

                    UnityEngine.Vector3[] __cl_gen_ret = GameStageUtility.CheckPath(_originPath);
                    translator.Push(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
示例#13
0
        static int _m_GetTextureByType_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    AlertAreaType _type; translator.Get(L, 1, out _type);

                    UnityEngine.Texture __cl_gen_ret = GameStageUtility.GetTextureByType(_type);
                    translator.Push(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
示例#14
0
        static int _m_StartPath_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            int __gen_param_count = LuaAPI.lua_gettop(L);

            try {
                if (__gen_param_count == 3 && translator.Assignable <UnityEngine.Vector3>(L, 1) && translator.Assignable <UnityEngine.Vector3>(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3))
                {
                    UnityEngine.Vector3 _startPos; translator.Get(L, 1, out _startPos);
                    UnityEngine.Vector3 _destinationPos; translator.Get(L, 2, out _destinationPos);
                    float _maxDistance = (float)LuaAPI.lua_tonumber(L, 3);

                    UnityEngine.Vector3[] __cl_gen_ret = GameStageUtility.StartPath(_startPos, _destinationPos, _maxDistance);
                    translator.Push(L, __cl_gen_ret);



                    return(1);
                }
                if (__gen_param_count == 2 && translator.Assignable <UnityEngine.Vector3>(L, 1) && translator.Assignable <UnityEngine.Vector3>(L, 2))
                {
                    UnityEngine.Vector3 _startPos; translator.Get(L, 1, out _startPos);
                    UnityEngine.Vector3 _destinationPos; translator.Get(L, 2, out _destinationPos);

                    UnityEngine.Vector3[] __cl_gen_ret = GameStageUtility.StartPath(_startPos, _destinationPos);
                    translator.Push(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to GameStageUtility.StartPath!"));
        }
示例#15
0
        static int _m_CheckPosition_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    UnityEngine.Vector3 _from; translator.Get(L, 1, out _from);
                    UnityEngine.Vector3 _to; translator.Get(L, 2, out _to);

                    bool __cl_gen_ret = GameStageUtility.CheckPosition(_from, _to);
                    LuaAPI.lua_pushboolean(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
示例#16
0
文件: NPC.cs 项目: atom-chen/tianyu
    /// <summary>
    /// 移动到指定终点  by吴江
    /// </summary>
    /// <param name="_pos"></param>
    /// <param name="_maxDistance"></param>
    /// <param name="_noStop"></param>
    public override void MoveTo(Vector3 _pos, float _maxDistance = 10.0f, bool _noStop = false)
    {
        if (moveFSM != null)
        {
            Vector3[] path = GameStageUtility.StartPath(transform.position, _pos);

            if (path == null)
            {
                return;
            }
            moveFSM.path = path;

            if (moveFSM.path == null)
            {
                GameSys.Log("NPC's path not found! Target: " + _pos);
                moveFSM.destPos = moveFSM.transform.position;
                moveFSM.StopMovingTo();
                return;
            }
            MoveTo(moveFSM.path);
        }
    }
示例#17
0
        static int _m_GetClosestTypeNPCDistance_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    GameStage  _gameStage = (GameStage)translator.GetObject(L, 1, typeof(GameStage));
                    PlayerBase _player    = (PlayerBase)translator.GetObject(L, 2, typeof(PlayerBase));
                    NPCType    _type; translator.Get(L, 3, out _type);

                    float __cl_gen_ret = GameStageUtility.GetClosestTypeNPCDistance(_gameStage, _player, _type);
                    LuaAPI.lua_pushnumber(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
示例#18
0
        static int _m_GetCloseNPCByIndex_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    GameStage  _gameStage = (GameStage)translator.GetObject(L, 1, typeof(GameStage));
                    PlayerBase _player    = (PlayerBase)translator.GetObject(L, 2, typeof(PlayerBase));
                    int        _index     = LuaAPI.xlua_tointeger(L, 3);

                    NPC __cl_gen_ret = GameStageUtility.GetCloseNPCByIndex(_gameStage, _player, _index);
                    translator.Push(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
示例#19
0
    /// <summary>
    /// 使用技能(供外部使用) by吴江
    /// </summary>
    ///  <param name="_trace">是否追踪</param>
    /// <returns></returns>
    public bool TryUseAbility(AbilityInstance _instance, bool _trace, bool noTarget = false)
    {
        if (isRigidity || isDead || _instance == null)
        {
            return(false);
        }
        if (_instance.thisSkillMode != SkillMode.NORMALSKILL && isSilent)
        {
            return(false);
        }
        if (abilityMng != null && abilityMng.HasLockState)
        {
            return(false);
        }
        if (moveFSM != null && moveFSM.isMoving)
        {
            StopMovingTo();
        }
        CancelAbility();

        commandMng.CancelCommands();
        curTryUseAbility = _instance;
        if (_trace)
        {
            if (_instance.TargetActor == null)
            {
                if (_instance.NeedTarget)
                {
                    return(false);
                }
                Command_CastAbilityOn cmdCastAbilityOn = new Command_CastAbilityOn();
                cmdCastAbilityOn.abilityInstance = _instance;
                cmdCastAbilityOn.target          = noTarget ? null : _instance.TargetActor;;
                commandMng.PushCommand(cmdCastAbilityOn);
            }
            else
            {
                Vector3[] path = GameStageUtility.StartPath(transform.position, _instance.TargetActor.transform.position);
                if (path == null || path.Length == 0)
                {
                    if (_instance.TargetActor != null && (_instance.TargetActor.transform.position - this.transform.position).sqrMagnitude <= 2.0f * 2.0f)//有怪物(玩家和怪物重叠)直接打怪
                    {
                        Command_CastAbilityOn cmdCastAbilityOn = new Command_CastAbilityOn();
                        cmdCastAbilityOn.abilityInstance = _instance;
                        cmdCastAbilityOn.target          = noTarget ? null : _instance.TargetActor;
                        commandMng.PushCommand(cmdCastAbilityOn);
                    }
                }
                else
                {
                    //
                    Command_TraceTarget cmdTraceTarget = new Command_TraceTarget();
                    cmdTraceTarget.abilityInstance     = _instance;
                    cmdTraceTarget.target              = _instance.TargetActor;
                    cmdTraceTarget.updatePathDeltaTime = 1.0f;
                    commandMng.PushCommand(cmdTraceTarget);

                    //
                    Command_CastAbilityOn cmdCastAbilityOn = new Command_CastAbilityOn();
                    cmdCastAbilityOn.abilityInstance = _instance;
                    cmdCastAbilityOn.target          = noTarget ? null : _instance.TargetActor;;
                    commandMng.PushCommand(cmdCastAbilityOn);
                }
            }
        }
        else
        {
            if (_instance.TargetActor != null && !noTarget)
            {
                FaceToNoLerp(_instance.TargetActor.gameObject.transform.position - transform.position);
            }
            //这里一定不能直接使用技能,而必须是压入命令.  压入命令的话,执行命令是下一帧(因为必须先等本帧的状态机切换结束)  by 吴江
            Command_CastAbilityOn cmdCastAbilityOn = new Command_CastAbilityOn();
            cmdCastAbilityOn.abilityInstance = _instance;
            cmdCastAbilityOn.target          = noTarget ? null : _instance.TargetActor;;
            commandMng.PushCommand(cmdCastAbilityOn);
        }
        return(true);
    }
示例#20
0
    void FlyToPint(GameObject _obj)
    {
        if (GameCenter.taskMng.CurTargetSceneID == 0 || GameCenter.taskMng.CurTargetSceneID == GameCenter.mainPlayerMng.MainPlayerInfo.SceneID)
        {
            Vector3   targetPos = ActorMoveFSM.LineCast(GameCenter.taskMng.CurTargetPoint, true);
            Vector3   curPos    = GameCenter.curMainPlayer.transform.position;
            Vector3[] path      = GameStageUtility.StartPath(targetPos, curPos);
            float     distance  = 0;
            if (path != null)
            {
                distance = path.Length == 2 ? Vector3.Distance(targetPos, curPos) : path.CountPathDistance();
                //Debug.Log("distance:" + distance);
                if (distance < 10)
                {
                    GameCenter.messageMng.AddClientMsg(509);
                    return;//距离太近的时候不传送
                }
            }
        }
        GameCenter.curMainPlayer.StopForFly();

        Refresh();

        if (GameCenter.mainPlayerMng.MainPlayerInfo.CurLevel >= 10 && GameCenter.mainPlayerMng.MainPlayerInfo.CurLevel < 21)
        {
            FlyYes();
        }
        //else if(GameCenter.taskMng.CurfocusTask.TaskType == TaskType.Ring&&GameCenter.mainPlayerMng.MainPlayerInfo.CurLevel >= 10)
        //{
        //    FlyYes();
        //    return;
        //}
        else if (GameCenter.vipMng.VipData != null && GameCenter.vipMng.VipData.vLev <= 0 && GameCenter.mainPlayerMng.MainPlayerInfo.CurLevel < 10)
        {
            GameCenter.messageMng.AddClientMsg(435);
        }
        else if (GameCenter.vipMng.VipData != null && GameCenter.vipMng.VipData.vLev > 0)
        {
            FlyYes();
        }
        else
        {
            if (GameCenter.mainPlayerMng.MainPlayerInfo.RealYuanCount < 10)
            {
                GameCenter.curMainPlayer.StopMovingTo();
                GameCenter.curMainPlayer.CancelCommands();
                GameCenter.curMainPlayer.GoNormal();
                GameCenter.uIMng.GenGUI(GUIType.FLYREMIND, true);
                //GameCenter.practiceMng.ReminderWnd(12, "真元");
            }
            else
            {
                if (GameCenter.systemSettingMng.ShowFlyTips)
                {
                    FlyYes();
                }
                else
                {
                    GameCenter.curMainPlayer.StopMovingTo();
                    GameCenter.curMainPlayer.CancelCommands();
                    GameCenter.curMainPlayer.GoNormal();
                    GameCenter.uIMng.GenGUI(GUIType.FLYREMIND, true);
                }
            }
        }
    }
示例#21
0
    public override bool Exec(Actor _actor)
    {
        if (target == null)
        {
            return(true);
        }
        if (target.isDummy)
        { // 当目标为null时,这里不能返回true,必须等目标创建
            id               = target.id;
            typeID           = target.typeID;
            dummyWaitForLoad = true;
        }
        if (GameCenter.curGameStage == null || !GameCenter.sceneMng.EnterSucceed)
        {
            return(false);
        }
        if (dummyWaitForLoad)
        {
            if (target == null)
            {
                target           = GameCenter.curGameStage.GetObject(typeID, id);
                dummyWaitForLoad = false;
            }
        }

        Actor targetActor = target as Actor;

        if (targetActor != null && targetActor.isDead)
        {
            return(true);
        }


        SmartActor smartActor = (_actor as SmartActor);

        if (smartActor != null)
        {
            if (smartActor.isRigidity)
            {
                return(false);
            }
            if (smartActor.isDead)
            {
                return(true);
            }
        }

        Vector3 targetPos  = target.transform.position;
        Vector3 diff       = targetPos - _actor.transform.position;
        bool    keepMoving = false;

        if (abilityInstance != null)
        {
            keepMoving = !abilityInstance.CanPushAbilityCommand(target);//如果到了可以施放技能的距离,则停止移动,开始施放技能
            if (!keepMoving)
            {
                _actor.StopMovingTo();
                _actor.FaceToNoLerp(diff);

                MainPlayer player = _actor as MainPlayer;//释放技能前也需要下马
                if (player != null && player.actorInfo != null && player.actorInfo.CurMountInfo != null && player.actorInfo.CurMountInfo.IsRiding)
                {
                    if (haveReqDownRide == false)
                    {
                        GameCenter.newMountMng.C2S_ReqRideMount(ChangeMount.DOWNRIDE, player.actorInfo.CurMountInfo.ConfigID, MountReqRideType.AUTO);
                        haveReqDownRide = true;
                    }
                    return(false);
                }
                return(true);
            }
        }
        if (diff.sqrMagnitude <= minDistance * minDistance)
        {
            _actor.StopMovingTo();
            _actor.FaceToNoLerp(diff);
            return(true);
        }

        DestPos = targetPos; // -Vector3.Normalize(diff) * 2.0f;
        if (firstTime)
        {                    // 这里确保在移动中,防止自动挂机卡住
            firstTime = false;
            Vector3[] path = GameStageUtility.StartPath(_actor.transform.position, DestPos);
            _actor.MoveTo(path);
            return(false);
        }
        else
        {
            if (!_actor.IsMoving)
            {
                Vector3[] path = GameStageUtility.StartPath(_actor.transform.position, DestPos);
                if (path == null)
                {
                    _actor.ChangeTarget();
                    return(true);
                }
                else
                {
                    _actor.MoveTo(path);
                }
                return(false);
            }

            if (Time.time >= updatePathTime && updatePathDeltaTime > 0.0f)
            {
                Vector3[] path = GameStageUtility.StartPath(_actor.transform.position, DestPos);
                _actor.MoveTo(path); // 定位新的目标的位置
                updatePathTime = Time.time + updatePathDeltaTime;
            }
        }

        return(false);
    }
示例#22
0
    public override bool Exec(Actor _actor)
    {
        targetList = FilterDropItems;
        if (targetList.Count < 1)
        {
            return(true);//所有物品都拾取完毕,结束命令
        }
        if (GameCenter.inventoryMng != null && GameCenter.inventoryMng.IsBagFull)
        {
            return(true);//背包已满结束拾取
        }
        DropItemInfo targetOne = GetClosestDropItem(targetList);

        path = GameStageUtility.StartPath(_actor.transform.position, ActorMoveFSM.LineCast(new Vector3(targetOne.ServerPos.x, 0, targetOne.ServerPos.y), true));
        if (path == null)
        {
            //掩码里的物品,加入黑名单
            if (!cannotList.Contains(targetOne))
            {
                cannotList.Add(targetOne);
            }
            if (player != null && !player.blackDropItemList.Contains(targetOne))
            {
                player.blackDropItemList.Add(targetOne);
            }
        }
        else
        {
            destPos = path[path.Length - 1];
        }
        if (!_actor.IsMoving)
        {
            if (player.isRigidity)
            {
                return(false);
            }
            Vector3 delta = destPos - _actor.transform.position;
            if (delta.sqrMagnitude <= (0.3 * 0.3))
            {
                DropItem dropItem = GameCenter.curGameStage.GetDropItem(targetOne.ServerInstanceID);
                if (dropItem != null && dropItem.HasShowName)
                {
                    //尝试拾取的物品,不管拾取是否成功,加入黑名单
                    if (!cannotList.Contains(targetOne))
                    {
                        cannotList.Add(targetOne);
                    }
                    if (player != null && !player.blackDropItemList.Contains(targetOne))
                    {
                        player.blackDropItemList.Add(targetOne);
                    }
                }
                return(false);
            }
            if (GameCenter.sceneMng.GetDropItemInfo(targetOne.ServerInstanceID) == null)
            {
                return(true);
            }
            _actor.MoveTo(path, 0.3f, false);
        }
        return(false);
    }
示例#23
0
    public override bool Exec(Actor _actor)
    {
        if (GameCenter.curGameStage == null || !GameCenter.sceneMng.EnterSucceed)
        {
            return(false);
        }
        //如果目标在使用技能,返回false ,等他用完 by吴江
        SmartActor sa = _actor as SmartActor;

        if (sa.isRigidity) //如果在僵直
        {
            return(false);
        }
        if (sa != null && (sa.isCasting || sa.isCastingAttackEffect)) //如果在使用技能
        {
            sa.CancelAbility();
        }

        if (path == null)
        {
            path = GameStageUtility.StartPath(_actor.transform.position, destPos);

            if (path == null)
            {
                GameSys.Log("寻路失败!");
                _actor.StopMovingTo();
                MainPlayer player = _actor as MainPlayer;
                if (player != null)
                {
                    if (player.CannotMoveTo != null)
                    {
                        player.CannotMoveTo();
                    }
                }
                return(true);
            }
            else
            {
                destPos = path[path.Length - 1];
            }
        }

        //检查是否超出最远距离 by吴江
        if (maxDistance > 0.0f)
        {
            Vector3 delta = destPos - _actor.transform.position;
            if (ignoreY)
            {
                delta.y = 0.0f;
            }
            if (delta.sqrMagnitude <= (maxDistance * maxDistance))
            {
                _actor.StopMovingTo();
                return(true);
            }
        }


        if (firstTime)
        {
            if (_actor.isMoveLocked == false)
            {
                // firstTimeTick = Time.realtimeSinceStartup;
                firstTime = false;
                _actor.MoveTo(path, maxDistance, false);
            }

            return(false);
        }

        if (maxDistance <= 0.0f)
        {
            Vector3 delta = destPos - _actor.transform.position;
            if (ignoreY)
            {
                delta.y = 0.0f;
            }
            if (delta.sqrMagnitude < (0.1 * _actor.CurRealSpeed * 0.1 * _actor.CurRealSpeed))
            {
                var player = _actor as SmartActor;
                if (player != null)
                {
                    _actor.StopMovingTo();
                }
                return(true);
            }
        }

        if (_actor.IsMoving)
        {
            return(false);
        }
        else
        {
            path = GameStageUtility.StartPath(_actor.transform.position, destPos);
            _actor.MoveTo(path, maxDistance, false);

            if (path == null || path.Length == 0)
            {
                return(true);
            }
        }
        return(false);
    }