예제 #1
0
 protected virtual void EnterAutoDartState(fsm.State _from, fsm.State _to, fsm.Event _event)
 {
     if (CurDart != null)
     {
         Command_TraceTarget traceTarget = new Command_TraceTarget();
         traceTarget.target = CurDart;
         traceTarget.updatePathDeltaTime = 1.0f;
         commandMng.PushCommand(traceTarget);
     }
     else
     {
         if (stateMachine != null)
         {
             stateMachine.Send((int)EventType.FINDDART);
         }
     }
 }
예제 #2
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);
    }
예제 #3
0
    public bool isTransfer = false;//是否传送去他身边
    #endregion

    public void show()
    {
        UIEventListener.Get(gameObject).onClick = delegate { this.gameObject.SetActive(false); };


        if (GameCenter.friendsMng.curFriend != null)
        {
            int id = GameCenter.friendsMng.curFriend.configId;
            if (sendMegBtn != null)
            {
                UIEventListener.Get(sendMegBtn.gameObject).onClick = delegate
                {
                    this.gameObject.SetActive(false);
                    GameCenter.chatMng.OpenPrivateWnd(GameCenter.friendsMng.curFriend.name);
                }
            }
            ;
            if (teamBtn != null)
            {
                UIEventListener.Get(teamBtn.gameObject).onClick = delegate
                {
                    this.gameObject.SetActive(false);
                    if (GameCenter.friendsMng.curFriend != null)
                    {
                        GameCenter.teamMng.C2S_TeamInvite(id);
                    }
                }
            }
            ;
            if (deleteBtn != null)
            {
                UIEventListener.Get(deleteBtn.gameObject).onClick = delegate
                {
                    this.gameObject.SetActive(false);
                    if (GameCenter.friendsMng.curFriend != null)
                    {
                        GameCenter.friendsMng.C2S_DeleteFriend(id);
                    }
                    GameCenter.friendsMng.OnFriendsDicUpdata();
                }
            }
            ;
            if (sendMailBtn != null)
            {
                UIEventListener.Get(sendMailBtn.gameObject).onClick = delegate
                {
                    this.gameObject.SetActive(false);
                    GameCenter.mailBoxMng.mailWriteData = new MailWriteData(GameCenter.friendsMng.curFriend.name);
                    GameCenter.uIMng.SwitchToSubUI(SubGUIType.BMail);
                }
            }
            ;
            if (checkDataBtn != null)
            {
                UIEventListener.Get(checkDataBtn.gameObject).onClick = delegate
                {
                    this.gameObject.SetActive(false);
                    GameCenter.previewManager.C2S_AskOPCPreview(id);
                }
            }
            ;
            if (addToBlackBtn != null)
            {
                UIEventListener.Get(addToBlackBtn.gameObject).onClick = delegate
                {
                    this.gameObject.SetActive(false);
                    GameCenter.friendsMng.C2S_AddFriendToBlack(id);
                }
            }
            ;
            if (moveFromBlackBtn != null)
            {
                UIEventListener.Get(moveFromBlackBtn.gameObject).onClick = delegate
                {
                    this.gameObject.SetActive(false);
                    GameCenter.friendsMng.C2S_ReqDoSomething(FriendOperation.ADDFRIEND, id);
                }
            }
            ;
            if (gotoHerSideBtn != null)
            {
                UIEventListener.Get(gotoHerSideBtn.gameObject).onClick = delegate
                {
                    this.gameObject.SetActive(false);
                    if (GameCenter.friendsMng.curFriend.IsOnline)
                    {
                        if (!isTransfer)
                        {
                            GameCenter.curMainPlayer.commandMng.CancelCommands();
                            OtherPlayer other = GameCenter.curGameStage.GetOtherPlayer(id);
                            if (other != null)
                            {
                                Command_TraceTarget trace = new Command_TraceTarget();
                                trace.target      = other;
                                trace.minDistance = 1f;
                                GameCenter.curMainPlayer.commandMng.PushCommand(trace);
                                GameCenter.curMainPlayer.CurTarget = other;
                                GameCenter.uIMng.SwitchToUI(GUIType.NONE);
                            }
                            else
                            {
                                Debug.LogError("GetOtherPlayer:" + id + " is null!");
                            }
                        }
                        else
                        {
                            MessageST mst = new MessageST();
                            mst.messID = 398;
                            mst.delYes = delegate
                            {
                                GameCenter.friendsMng.C2S_ReqDoSomething(FriendOperation.DELETEFRIEND, id);
                                GameCenter.uIMng.SwitchToUI(GUIType.NONE);
                            };
                            GameCenter.messageMng.AddClientMsg(mst);
                        }
                    }
                    else
                    {
                        GameCenter.messageMng.AddClientMsg(68);
                    }
                }
            }
            ;
            if (addToFriendBtn != null)
            {
                UIEventListener.Get(addToFriendBtn.gameObject).onClick = delegate
                {
                    this.gameObject.SetActive(false);
                    if (isTransfer && GameCenter.friendsMng.findFriend != null)
                    {
                        id = GameCenter.friendsMng.findFriend.configId;
                        GameCenter.friendsMng.C2S_AddFriend(id);
                    }
                    else
                    {
                        GameCenter.friendsMng.C2S_AddFriend(id);
                    }
                }
            }
            ;
        }
    }
}