Ejemplo n.º 1
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));
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 播放拾取特效 by吴江
 /// </summary>
 /// <param name="_effectName"></param>
 /// <param name="_time"></param>
 public void DoPickUpEffect(string _effectName, float _time, Vector3 _from, SmartActor _to)
 {
     if (!CanShow)
     {
         return;
     }
     if (_effectName == string.Empty || _time <= 0)
     {
         return;
     }
     GameCenter.spawner.SpawnEffecter(_effectName, _time + holdTime, (x) =>
     {
         if (x == null)
         {
             return;
         }
         x.gameObject.SetMaskLayer(this.gameObject.layer);
         x.transform.parent     = null;
         x.transform.rotation   = Quaternion.identity;// Quaternion.Euler(_from - transform.position);
         x.transform.parent     = null;
         x.transform.localScale = Vector3.one;
         PickUpEffect p         = x.gameObject.GetComponent <PickUpEffect>();
         if (p == null)
         {
             p = x.gameObject.AddComponent <PickUpEffect>();
         }
         p.Init(_from, _to, _time, holdTime, x);
     }, false);
 }
Ejemplo n.º 3
0
    /// <summary>
    /// 当主主角使用技能成功时
    /// </summary>
    protected void OnMainPlayerUseAbility()
    {
        SmartActor target = owner.CurTarget as SmartActor;

        if (target == null)
        {
            return;
        }
        if (PlayerAutoFightFSM.IsEnemy(target))
        {
            switch (target.typeID)
            {
            case ObjectType.Entourage:
            case ObjectType.Player:
                if (lastPvpTraceTarget != target)
                {
                    lastPvpTraceTarget = target;
                    stateMachine.Send((int)EventType.PVP_FIGHT_TRACE);
                }
                break;

            case ObjectType.MOB:
                if (lastPveTraceTarget != target)
                {
                    lastPveTraceTarget = target;
                    stateMachine.Send((int)EventType.PVE_TRACE);
                }
                break;

            default:
                break;
            }
        }
    }
Ejemplo n.º 4
0
 public void UnRegist()
 {
     thisTarget = null;
     foreach (AbilityInstance item in GameCenter.skillMng.abilityDic.Values)
     {
         item.ResetTarget(null);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 手动选中的怪物
 /// </summary>
 public void SetThisTarget(SmartActor _actor)
 {
     if (thisTarget != null && _actor != null && thisTarget.id == _actor.id)
     {
         return;
     }
     thisTarget = _actor;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 获取翻滚技能,可能为null(法师没有冲锋)
 /// </summary>
 /// <returns></returns>
 public AbilityInstance GetRoundAbility(SmartActor _target)
 {
     if (roundAbility != null)
     {
         roundAbility.ResetResult(_target);
     }
     return(roundAbility);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 使用基础符文的技能 by吴江
 /// </summary>
 /// <param name="_abilityID"></param>
 /// <param name="_level"></param>
 /// <param name="_rune"></param>
 /// <param name="_user"></param>
 /// <param name="_target"></param>
 public AbilityInstance(int _abilityID, int _level, SmartActor _user, SmartActor _target)
 {
     abilityID = _abilityID;
     level     = _level;
     runeID    = RefData == null ? -1 : RefData.baseRune;
     UserActor = _user;
     target    = _target;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 使用自定义符文的技能 by吴江
 /// </summary>
 /// <param name="_abilityID"></param>
 /// <param name="_level"></param>
 /// <param name="_rune"></param>
 /// <param name="_user"></param>
 /// <param name="_target"></param>
 public AbilityInstance(int _abilityID, int _level, int _rune, SmartActor _user, SmartActor _target)
 {
     abilityID = _abilityID;
     level     = _level;
     runeID    = _rune;
     UserActor = _user;
     target    = _target;
 }
Ejemplo n.º 9
0
 protected virtual void EnterFlowState(fsm.State _from, fsm.State _to, fsm.Event _event)
 {
     if (thisPlayer.isDead)
     {
         return;
     }
     //TryTalk(EntourageTalkType.IDLE);
     thisTarget   = null;
     curEventType = EventType.FLOW;
 }
Ejemplo n.º 10
0
 public void SetTarget(SmartActor _sm)
 {
     target = _sm;
     target.onSectorChanged += OnPositionChange;
     us = this.gameObject.GetComponent <UISprite>();
     if (us != null && target.typeID == ObjectType.MOB)
     {
         us.color = ConfigMng.Instance.GetRelationColor(GameCenter.curMainPlayer.Camp, _sm.Camp, GameCenter.curGameStage.SceneType);
     }
 }
Ejemplo n.º 11
0
    public void ChangeTarget()
    {
        float distance = 0;

        thisTarget = GameCenter.curGameStage.GetAnotherSmartActor(thisTarget == null ? -1 : thisTarget.id, thisPlayer.transform.position);       //startFightPos == Vector3.zero ? thisPlayer.transform.position : startFightPos);  //这里需要加
        if (thisTarget == null)
        {
            thisTarget = GameCenter.curGameStage.GetClosestMob(thisPlayer, ref distance);
            if (distance > autoFightDistance)
            {
                thisTarget = null;
            }
            if (thisTarget != null)//自动战斗避开BOSS  BY黄洪兴
            {
                Monster mo = thisTarget as Monster;
                if (mo != null && GameCenter.mainPlayerMng.MainPlayerInfo.CurSceneRef != null)
                {
                    if (GameCenter.systemSettingMng.IsHideBoss && mo.actorInfo.IsBoss && GameCenter.mainPlayerMng.MainPlayerInfo.CurSceneRef.sort == SceneType.SCUFFLEFIELD)
                    {
                        thisTarget = null;
                    }
                }
            }
        }
        if (thisTarget != null)
        {
            thisPlayer.CurTarget = thisTarget;
        }
        else
        {
            if (!commandMng.HasCommand())
            {
                List <DropItemInfo> dropItmes = GameCenter.sceneMng.GetDropItemInfoListByLimit(thisPlayer);
                if (dropItmes.Count > 1)
                {
                    thisPlayer.OnDropItem();
                }
                else
                {
                    Vector3 wayPoint = GameCenter.sceneMng.WayPoint;//找不到怪物则寻找路点
                    if ((thisPlayer.transform.position - wayPoint).sqrMagnitude > 2f)
                    {
                        if (wayPoint.x != 0 || wayPoint.z != 0)
                        {
                            Command_MoveTo moveto = new Command_MoveTo();
                            moveto.destPos     = wayPoint;
                            moveto.maxDistance = 0f;
                            GameCenter.curMainPlayer.commandMng.PushCommand(moveto);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 12
0
    protected virtual void EnterTargetState(fsm.State _from, fsm.State _to, fsm.Event _event)
    {
        curEventType = EventType.TARGET;
        thisTarget   = null;
        float distance = 0;

        curTarTaskInfo = GameCenter.taskMng.CurfocusTask;

        SceneRef sceneRef = GameCenter.mainPlayerMng.MainPlayerInfo.CurSceneRef;

        if (sceneRef != null && sceneRef.pk_mode != 0)       //强制玩家切换PK模式的场景里,才锁定玩家 by邓成
        {
            thisTarget = GameCenter.curGameStage.GetClosestPlayer(thisPlayer, RelationType.AUTOMATEDATTACKS, ref distance);
            if (distance > autoFightDistance)
            {
                thisTarget = null;
            }
        }
        else
        {
            thisTarget = GameCenter.curGameStage.GetClosestMob(thisPlayer, ref distance);
            if (distance > autoFightDistance)
            {
                thisTarget = null;
            }
            if (curTarTaskInfo != null && thisTarget != null)
            {
                Monster mob = thisTarget as Monster;
                if (mob == null)
                {
                    thisTarget = null;
                }
//				else if (curTarTaskInfo.TargetMosterID != mob.ConfigID)   //这里需要TargetMosterID和ConfigID
//				{
//					thisTarget = null;
//				}
            }
            if (thisTarget != null)//自动战斗避开BOSS  BY黄洪兴
            {
                Monster mo = thisTarget as Monster;
                if (mo != null && GameCenter.mainPlayerMng.MainPlayerInfo.CurSceneRef != null)
                {
                    if (GameCenter.systemSettingMng.IsHideBoss && mo.actorInfo.IsBoss && GameCenter.mainPlayerMng.MainPlayerInfo.CurSceneRef.sort == SceneType.SCUFFLEFIELD)
                    {
                        thisTarget = null;
                    }
                }
            }
        }
        if (thisTarget == null)
        {
            ChangeTarget();
        }
    }
Ejemplo n.º 13
0
    public void ChangeTarget()
    {
        float distance = 0;

        if (thisTarget != null && !thisTarget.isDead)
        {
            thisTarget = GameCenter.curGameStage.GetAnotherMob(thisTarget.id);
        }
        else
        {
            thisTarget = GameCenter.curGameStage.GetClosestMob(thisPlayer, ref distance);
        }
    }
Ejemplo n.º 14
0
 /// <summary>
 /// 尝试战斗 by吴江
 /// </summary>
 /// <param name="_curType">当前状态</param>
 /// <param name="_nextType">下一顺位的状态</param>
 protected void TryFight(EventType _curType, EventType _nextType, float _checkRange)
 {
     if (CheckNeedTeleport())
     {
         return;
     }
     if (lastNormalAbilityInstance != null && !lastNormalAbilityInstance.HasServerConfirm && !lastNormalAbilityInstance.IsTringEnd)
     {
         return;
     }
     if ((thisPlayer.transform.position - owner.transform.position).sqrMagnitude > _checkRange * _checkRange)
     {
         stateMachine.Send((int)_nextType);
         return;
     }
     if (thisTarget == null || thisTarget.isDead)
     {
         thisTarget = TryTarget(_curType);
     }
     if (thisTarget == null || thisTarget.isDead)
     {
         stateMachine.Send((int)_nextType);
     }
     else
     {
         if (IsUseLoseHitAbility)
         {
             return;
         }
         if (thisTarget != null)
         {
             TryTalk(EntourageTalkType.ATTACK);
             if (!thisPlayer.isRigidity && !thisPlayer.IsProtecting && !commandMng.HasCommand())
             {
                 if (lastNormalAbilityInstance != null && !lastNormalAbilityInstance.HasServerConfirm)
                 {
                     Debug.LogError("Catch: 捕捉到上一次普通攻击尚未获得后台确认,前台即发动下一次普通攻击!");
                 }
                 AbilityInstance instance = thisPlayer.abilityMng.GetNextEntourageAbility(thisTarget);
                 //Debug.Log("TryUseAbility:"+(instance==null?"null":instance.AbilityName)+",Time:"+Time.realtimeSinceStartup);
                 if (instance != null)
                 {
                     thisPlayer.TryUseAbility(instance, true);
                     lastNormalAbilityInstance = instance;
                     startNoTargetTime         = Time.time;
                 }
             }
         }
     }
     return;
 }
Ejemplo n.º 15
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);
    }
Ejemplo n.º 16
0
 public void Init(Vector3 _from, SmartActor _to, float _time, float _holdTime, PoolEffecter _self)
 {
     if (_to == null)
     {
         return;
     }
     from           = _from;
     to             = _to.GetReceivePoint();
     wholeTime      = _time;
     startTime      = Time.time;
     curRate        = 0;
     hasInited      = true;
     holdTime       = _holdTime;
     thisPoolEffect = _self;
 }
Ejemplo n.º 17
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);
    }
Ejemplo n.º 18
0
 public AbilityInstance(pt_scene_skill_aleret_c021 _pt, SmartActor _user)
 {
     abilityID   = (int)_pt.skill;
     runeID      = (int)_pt.skill_rune;
     level       = (int)_pt.lev;
     UserActor   = _user;
     target      = GameCenter.curGameStage.GetInterActiveObj((int)_pt.target_id) as SmartActor;
     warnningX   = _pt.aleret_x;
     warnningY   = _pt.aleret_y;
     warnningZ   = _pt.aleret_z;
     warnningDir = _pt.aleret_dir;
     UserActor.FaceToNoLerp(_pt.dir);
     target           = null;
     HasServerConfirm = false;
     needPrepare      = true;
 }
Ejemplo n.º 19
0
    /// <summary>
    /// 获取下一次普通攻击的类型
    /// </summary>
    /// <returns></returns>
    public AbilityInstance GetNextDefaultAbility(SmartActor _target)
    {
        if (LastDefaultAbility != null && LastDefaultAbility.RestCD <= 0)
        {
            ResetDefaultAbility();            //普攻CD结束,则重置到第一个普攻
        }
        int             curIndex = CountCurIndex(curDefaultAbilityIndex, defaultAbilityCount);
        AbilityInstance instance = defaultAbilityList[curIndex];

        if (instance != null)
        {
            instance.ResetResult(_target);
            return(instance);
        }
        return(null);
    }
Ejemplo n.º 20
0
    protected void S2C_OnAbilityCancelWarnning(Pt _info)
    {
        pt_scene_skill_aleret_cancel_c022 msg = _info as pt_scene_skill_aleret_cancel_c022;

        if (msg != null)
        {
            ObjectType type = (ObjectType)msg.obj_sort;
            SmartActor user = null;
            switch (type)
            {
            case ObjectType.Player:
                if ((int)msg.oid == GameCenter.mainPlayerMng.MainPlayerInfo.ServerInstanceID)
                {
                    user = GameCenter.curMainPlayer;
                }
                else
                {
                    user = GameCenter.curGameStage.GetOtherPlayer((int)msg.oid) as SmartActor;
                }
                break;

            case ObjectType.MOB:
                user = GameCenter.curGameStage.GetMOB((int)msg.oid) as SmartActor;
                break;

            case ObjectType.Entourage:
                user = GameCenter.curGameStage.GetEntourage((int)msg.oid) as EntourageBase;
                break;

            default:
                break;
            }
            if (user != null)
            {
                AbilityInstance instance = user.curTryUseAbility;
                if (instance == null)
                {
                    return;
                }
                if (instance.AbilityID == msg.skill && instance.RuneID == msg.skill_rune &&
                    instance.Level == msg.lev && instance.NeedPrepare && !instance.HasServerConfirm)
                {
                    user.CancelAbility();
                }
            }
        }
    }
Ejemplo n.º 21
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);
    }
Ejemplo n.º 22
0
 protected virtual void EnterTelePortState(fsm.State _from, fsm.State _to, fsm.Event _event)
 {
     if (thisPlayer.isDead)
     {
         return;
     }
     thisTarget = null;
     //TryTalk(EntourageTalkType.IDLE);
     curEventType = EventType.TELEPORT;
     thisPlayer.commandMng.CancelCommands();
     if (thisPlayer.IsMoving)
     {
         thisPlayer.StopMovingTo();
     }
     ;
     thisPlayer.CancelAbility();
     thisPlayer.InitPos();
     stateMachine.Send((int)EventType.FLOW);
 }
Ejemplo n.º 23
0
    /// <summary>
    /// 展示
    /// </summary>
    /// <param name="_actor"></param>
    public void Show(SmartActor _actor)
    {
        if (_actor == null || UserActor == null || _actor.isDummy)
        {
            HasFinished = true;
        }
        if (_actor.curHp <= 0)
        {
            _actor.Dead();
        }
        if (HasFinished)
        {
            return;
        }
        bool showText = (UserActor == GameCenter.curMainPlayer || TargetActor == GameCenter.curMainPlayer || UserActor == GameCenter.curMainEntourage || TargetActor == GameCenter.curMainEntourage);

        if (showText)
        {
            GameCenter.spawner.SpawnStateTexter(this);
            if (UserActor == GameCenter.curMainPlayer)
            {
                if ((AttackResultType)DefType != AttackResultType.ATT_SORT_DODGE)
                {
                    if (GameCenter.abilityMng.OnContinuCountUpdate != null)
                    {
                        GameCenter.abilityMng.OnContinuCountUpdate(Time.time);
                    }
                }
            }
            if (curShakePower > 0)
            {
                GameCenter.cameraMng.MainCameraShake(curCameraShakeV3, curShakePower);
            }
            GameCenter.soundMng.PlaySound(curDefSound, SoundMng.GetSceneSoundValue(_actor.transform, GameCenter.curMainPlayer.transform), false, true);
        }
        hasShowDamage += curDamage;
        if (instance != null && instance.needHitAnim)
        {
            _actor.BeHit(this);
        }
        index++;
    }
Ejemplo n.º 24
0
 /// <summary>
 /// 清理结果
 /// </summary>
 public void ResetResult(SmartActor _target)
 {
     target        = _target;
     ArrowFinished = false;
     targetTransforms.Clear();
     if (HasServerConfirm)
     {
         HasServerConfirm = false;
         lastTryTime      = -1;
         if (OnTringEnd != null)
         {
             OnTringEnd(serializeID);
         }
         serializeID = 0;
         if (result_list != null)
         {
             result_list.Clear();
         }
     }
 }
Ejemplo n.º 25
0
    protected void S2C_OnAbilityWarnning(Pt _info)
    {
        pt_scene_skill_aleret_c021 msg = _info as pt_scene_skill_aleret_c021;

        if (msg != null)
        {
            ObjectType type = (ObjectType)msg.obj_sort;
            SmartActor user = null;
            switch (type)
            {
            case ObjectType.Player:
                if ((int)msg.oid == GameCenter.mainPlayerMng.MainPlayerInfo.ServerInstanceID)
                {
                    user = GameCenter.curMainPlayer;
                }
                else
                {
                    user = GameCenter.curGameStage.GetOtherPlayer((int)msg.oid) as SmartActor;
                }
                break;

            case ObjectType.MOB:
                user = GameCenter.curGameStage.GetMOB((int)msg.oid) as SmartActor;
                break;

            case ObjectType.Entourage:
                user = GameCenter.curGameStage.GetEntourage((int)msg.oid) as EntourageBase;
                break;

            default:
                break;
            }
            if (user != null)
            {
                AbilityInstance instance = new AbilityInstance(msg, user);
                user.UseAbility(instance);
            }
        }
    }
Ejemplo n.º 26
0
 protected virtual void EnterAwakeState(fsm.State _from, fsm.State _to, fsm.Event _event)
 {
     curEventType = EventType.AWAKE;
     if (GameCenter.mainPlayerMng.MainPlayerInfo.CurSceneRef != null)
     {
         autoFightDistance = (float)GameCenter.mainPlayerMng.MainPlayerInfo.CurSceneRef.autofight_distance;
     }
     if (thisPlayer == null)
     {
         thisPlayer = this.gameObject.GetComponent <MainPlayer>();
     }
     if (thisPlayer == null)
     {
         Debug.LogError("找不到主玩家组件!");
     }
     else
     {
         commandMng = thisPlayer.commandMng;
         thisTarget = thisPlayer.CurTarget as SmartActor;
     }
     mainTaskStateType = CheckMainTaskStateType();
     startFightPos     = thisPlayer.transform.position;
 }
Ejemplo n.º 27
0
    /// <summary>
    /// 主角被打事件 by吴江
    /// </summary>
    /// <param name="_fromUser"></param>
    protected void OnMainPlayerBeHit(SmartActor _fromUser)
    {
        if (_fromUser == null)
        {
            return;
        }
        switch (_fromUser.typeID)
        {
        case ObjectType.Entourage:
        case ObjectType.Player:
            lastPvpDefenseTarget = _fromUser;
            stateMachine.Send((int)EventType.PVP_FIGHT_DEFENSE);
            break;

        case ObjectType.MOB:
            lastPveDefenseTarget = _fromUser;
            stateMachine.Send((int)EventType.PVE_DEFENSE);
            break;

        default:
            return;
        }
    }
Ejemplo n.º 28
0
    /// <summary>
    /// 获取前方的最近的对象 by吴江
    /// </summary>
    /// <param name="_gameStage"></param>
    /// <param name="_player"></param>
    /// <param name="_distance"></param>
    /// <returns></returns>
    public static SmartActor GetClosestSmartActorInFront(this GameStage _gameStage, PlayerBase _player, RelationType _relationType, ref float _distance)
    {
        if (_player == null)
        {
            return(null);
        }
        List <SmartActor> list        = _gameStage.GetSmartActors();
        List <SmartActor> inFrontList = new List <SmartActor>();

        if (list.Count == 0)
        {
            return(null);
        }
        for (int i = 0; i < list.Count; i++)
        {
            SmartActor sm    = list[i];
            float      angle = Mathf.Acos(Vector3.Dot((sm.transform.position - _player.transform.position).normalized, _player.transform.forward)) * Mathf.Rad2Deg;
            if (Mathf.Abs(angle) < 90)
            {
                inFrontList.Add(sm);
            }
        }
        return(GetClosestSmartActor(_player, inFrontList, _relationType, ref _distance));
    }
Ejemplo n.º 29
0
    /// <summary>
    /// 获取随从要使用的下一个技能
    /// </summary>
    /// <param name="_target"></param>
    /// <returns></returns>
    public AbilityInstance GetNextEntourageAbility(SmartActor _target)
    {
        AbilityInstance curInstance = null;

        //以普攻CD为间隔,大约三秒发动一次攻击 by邓成
        if (!(Time.time - previousAbilityTime > AttackDiffTime))
        {
            return(null);
        }
        for (int i = 0; i < entourageDefaultAbilityList.Count; i++)
        {
            if (entourageDefaultAbilityList[i].RestCD <= 0)
            {
                int curRandom = UnityEngine.Random.Range(0, 100);
                if (curRandom / 100f > entourageDefaultAbilityList[i].PetUseRate)
                {
                    curInstance = entourageDefaultAbilityList[i];
                    break;
                }
            }
        }
        if (curInstance == null && entourageNormalAbility != null && entourageNormalAbility.RestCD <= 0)
        {
            curInstance = entourageNormalAbility;
        }
        if (curInstance != null)
        {
            curInstance.ResetResult(_target);
            previousAbilityTime = Time.time;
        }
        if (curInstance != null)
        {
            curInstance.FullCD();
        }
        return(curInstance);
    }
Ejemplo n.º 30
0
    public override bool Exec(Actor _actor)
    {
        SmartActor smartActor = (_actor as SmartActor);

        if (abilityInstance.thisSkillMode == SkillMode.NORMALSKILL && smartActor.IsProtecting)
        {
            return(false);
        }
        if (smartActor == null || smartActor.isRigidity)
        {
            return(false);
        }
        if (abilityInstance == null)
        {
            return(true);
        }

        if (GameCenter.curGameStage == null || !GameCenter.sceneMng.EnterSucceed)
        {
            return(false);
        }

        if (smartActor.isDead)
        {
            return(true);                  //如果自己死了,什么也不干了
        }
        if (target == null)
        {
            if (abilityInstance.NeedTarget)
            {
                return(true);
            }
            smartActor.UseAbility(abilityInstance);//没目标或者目标死了,直接放技能,策划的要求  by吴江
            return(true);
        }


        Actor targetActor = target as Actor;

        if (targetActor != null && targetActor.isDead) //没目标或者目标死了,直接放技能,策划的要求  by吴江
        {
            smartActor.UseAbility(abilityInstance);
            return(true);
        }
        //==========修改,非普通攻击的技能可以空放!
        if (abilityInstance.thisSkillMode == SkillMode.NORMALSKILL)
        {
            if (!abilityInstance.NeedTarget || abilityInstance.CanUseFor(target))
            {
                smartActor.UseAbility(abilityInstance);
                return(true);
            }
            else
            {
                PlayerBase p = smartActor as PlayerBase;
                if (p != null)
                {
                    p.FaceTo(target.transform.position);
                    //p.UseAbility(p.LoseHitAbility);
                }
                return(true);
            }
        }
        else
        {
            smartActor.UseAbility(abilityInstance);
        }
        return(true);
    }