Ejemplo n.º 1
0
 //攻击
 public void FightCommand(SMsgBattleCommand smsgBattleCommand)
 {
     m_MonsterAttackState.Attack(smsgBattleCommand);
     if (m_FSMSystem.CurrentStateID == StateID.MonsterAttack)
     {
         BulletManager.Instance.TryDestroyBreakBullets(this.RoleDataModel.SMsg_Header.uidEntity);
     }
     m_FSMSystem.PerformTransition(Transition.MonsterToAttack);
 }
Ejemplo n.º 2
0
    private void SendNormalSkillCommand(int skillId)
    {
        Int64 targetEntityId = 0;

        //if (m_skillBase.SkillData.IsLockTarget)  //20141008 技能细节修改。动作的followType=1 为跟随目标的动作不再有用,而技能的AutoDirecting判断
        if (m_skillBase.SkillData.AutoDirecting)
        {
            //计算锁定目标,保存在PlayerBehaviour一个变量,并把目标发给服务器端
            //2014-10-09 普通攻击的锁定目标计算规则有修改
            //var targetEntityModel = LockAttackMonster(this.m_attackDistance, this.m_attackAngle);
            var targetEntityModel = MonsterManager.Instance.LockedMonster;
            if (targetEntityModel != null)
            {
                m_PlayerBehaviour.ActionLockTarget = targetEntityModel;
                targetEntityId = targetEntityModel.EntityDataStruct.SMsg_Header.uidEntity;

                m_PlayerBehaviour.ThisTransform.LookAt(new Vector3(targetEntityModel.GO.transform.position.x, m_PlayerBehaviour.ThisTransform.position.y, targetEntityModel.GO.transform.position.z));
            }
        }

        float xValue, yValue;

        this.m_PlayerBehaviour.ThisTransform.position.SetToServer(out xValue, out yValue);

        if (GameManager.Instance.CurrentGameMode == GameMode.MULTI_PLAYER)
        {
            SMsgBattleCommand sMsgBattleCommand = new SMsgBattleCommand();
            sMsgBattleCommand.uidFighter = this.m_PlayerBehaviour.RoleDataModel.SMsg_Header.uidEntity;
            sMsgBattleCommand.uidTarget  = targetEntityId;
            sMsgBattleCommand.nFightCode = skillId;

            sMsgBattleCommand.xPlayer = xValue;
            sMsgBattleCommand.yPlayer = yValue;
            sMsgBattleCommand.xMouse  = xValue;
            sMsgBattleCommand.yMouse  = yValue;
            //var dire = this.m_PlayerBehaviour.ThisTransform.TransformDirection(this.m_PlayerBehaviour.ThisTransform.forward);
            var euler = this.m_PlayerBehaviour.ThisTransform.rotation.eulerAngles;
            var d     = Quaternion.Euler(euler) * Vector3.forward;

            sMsgBattleCommand.xDirect = d.x;
            sMsgBattleCommand.yDirect = d.z * -1;
            //add by lee
            sMsgBattleCommand.bulletIndex = (UInt32)BulletManager.Instance.ReadIndex(this.m_PlayerBehaviour.RoleDataModel.SMsg_Header.uidEntity);
            NetServiceManager.Instance.BattleService.SendBattleCommand(sMsgBattleCommand);
        }
        else if (GameManager.Instance.CurrentGameMode == GameMode.SINGLE_PLAYER)
        {
            SMsgFightCommand_CS sMsgFightCommand_CS = new SMsgFightCommand_CS();
            sMsgFightCommand_CS.uidFighter  = this.m_PlayerBehaviour.RoleDataModel.SMsg_Header.uidEntity;
            sMsgFightCommand_CS.nFightCode  = skillId;
            sMsgFightCommand_CS.byType      = 1;
            sMsgFightCommand_CS.fighterPosX = xValue;
            sMsgFightCommand_CS.fighterPosY = yValue;

            NetServiceManager.Instance.BattleService.SendFightCommandCS(sMsgFightCommand_CS);
        }
    }
Ejemplo n.º 3
0
    private void SendNormalSkillCommand(int skillId)
    {
        float xValue, yValue;

        this.m_PlayerBehaviour.ThisTransform.position.SetToServer(out xValue, out yValue);
        if (GameManager.Instance.CurrentGameMode == GameMode.MULTI_PLAYER)
        {
            SMsgBattleCommand sMsgBattleCommand = new SMsgBattleCommand();
            sMsgBattleCommand.uidFighter = this.m_PlayerBehaviour.RoleDataModel.SMsg_Header.uidEntity;
            sMsgBattleCommand.nFightCode = skillId;


            sMsgBattleCommand.xPlayer = xValue;
            sMsgBattleCommand.yPlayer = yValue;
            sMsgBattleCommand.xMouse  = xValue;
            sMsgBattleCommand.yMouse  = yValue;

            //var dire = this.m_PlayerBehaviour.ThisTransform.TransformDirection(this.m_PlayerBehaviour.ThisTransform.forward);

            var euler = this.m_PlayerBehaviour.ThisTransform.rotation.eulerAngles;

            var d = Quaternion.Euler(euler) * Vector3.forward;

            sMsgBattleCommand.xDirect = d.x;
            sMsgBattleCommand.yDirect = d.z * -1;

            //add by lee
            sMsgBattleCommand.bulletIndex = (UInt32)BulletManager.Instance.ReadIndex(this.m_PlayerBehaviour.RoleDataModel.SMsg_Header.uidEntity);

            NetServiceManager.Instance.BattleService.SendBattleCommand(sMsgBattleCommand);
        }

        else if (GameManager.Instance.CurrentGameMode == GameMode.SINGLE_PLAYER)
        {
            SMsgFightCommand_CS sMsgFightCommand_CS = new SMsgFightCommand_CS();
            sMsgFightCommand_CS.uidFighter  = this.m_PlayerBehaviour.RoleDataModel.SMsg_Header.uidEntity;
            sMsgFightCommand_CS.nFightCode  = skillId;
            sMsgFightCommand_CS.byType      = 1;
            sMsgFightCommand_CS.fighterPosX = xValue;
            sMsgFightCommand_CS.fighterPosY = yValue;

            NetServiceManager.Instance.BattleService.SendFightCommandCS(sMsgFightCommand_CS);
        }
    }
Ejemplo n.º 4
0
    public void Attack(SMsgBattleCommand smsgBattleCommand)
    {
        if (GameManager.Instance.CurrentGameMode == GameMode.SINGLE_PLAYER)
        {
            TraceUtil.Log(SystemModel.Common, TraceLevel.Error, "!!!!!!!!!!!!!Wrong Monster battle Command!");
        }


        //TraceUtil.Log("==>攻击技能id = "+smsgBattleCommand.nFightCode);

        //var skillConfig = SkillDataManager.Instance.GetSkillConfigData(smsgBattleCommand.nFightCode);   //获取技能配置信息
        m_currentSkillID = smsgBattleCommand.nFightCode;
        m_FightTargetID  = smsgBattleCommand.uidTarget;

        m_shouldPos    = Vector3.zero.GetFromServer(smsgBattleCommand.xPlayer, smsgBattleCommand.yPlayer);
        m_shouldPos.y  = 0;
        m_targetPos    = Vector3.zero.GetFromServer(smsgBattleCommand.xMouse, smsgBattleCommand.yMouse);
        m_rangeTypePos = m_targetPos;

        float rad = Mathf.Atan2(-1 * smsgBattleCommand.yDirect, smsgBattleCommand.xDirect);

        m_currentAngle = 90 - (rad * Mathf.Rad2Deg);

        Vector3 diretPos = new Vector3(smsgBattleCommand.xDirect, m_high, -1 * smsgBattleCommand.yDirect);

        m_attackLookAtPos = m_shouldPos + diretPos;


        //m_diretPos.Normalize();
        //TraceUtil.Log("monster pos = " + m_shouldPos + " targetPos = " + m_targetPos + " diretPos = " + m_diretPos);
        //rad = m_currentAngle * Mathf.Deg2Rad;
        //m_attackDirt = new Vector3(Mathf.Cos(rad), 0, Mathf.Sin(rad));

        //m_attackDirt = new Vector3(smsgBattleCommand.xDirect, 0, -1 * smsgBattleCommand.yDirect);
        //m_attackDirt.Normalize();
        #region 攻击
        if (Log.IsPrint)
        {
            //Log.Instance.StartLog();
            //Log.Instance.AddLog("99999", "解下发攻击包", smsgBattleCommand.xPlayer.ToString(), smsgBattleCommand.yPlayer.ToString(), smsgBattleCommand.xDirect.ToString(), smsgBattleCommand.yDirect.ToString());
            //Log.Instance.AppendLine();
        }
        #endregion
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 收到战斗指令
    /// </summary>
    /// <param name="dataBuffer"></param>
    /// <param name="socketID"></param>
    CommandCallbackType ReceiveBattleCommand(byte[] dataBuffer, int socketID)
    {
        //场景加载完成前不处理战斗结果消息(组队)

        var sMsgBattleCommand = SMsgBattleCommand.ParseCommandPackage(dataBuffer);

        if (!GameManager.Instance.CreateEntityIM)
        {
            PlayerFactory.Instance.RegisterPlayerAfterSceneLoadedFun("ReceiveBattleCommand", () =>
            {
                RaiseEvent(EventTypeEnum.FightCommand.ToString(), sMsgBattleCommand);
            });
        }
        else
        {
            RaiseEvent(EventTypeEnum.FightCommand.ToString(), sMsgBattleCommand);
        }
        return(CommandCallbackType.Continue);
    }
Ejemplo n.º 6
0
 public void SendBattleCommand(SMsgBattleCommand sMsgBattleCommand)
 {
     //TraceUtil.Log("发送技能攻击:" + sMsgBattleCommand.nFightCode);
     this.Request(sMsgBattleCommand.GeneratePackage(MasterMsgType.NET_ROOT_FIGHT, FightDefineManager.MSG_FIGHT_BATTLE_COMMAND));
 }
Ejemplo n.º 7
0
        void ReceiveFightCommand(INotifyArgs inotifyArgs)
        {
            SMsgBattleCommand serData = (SMsgBattleCommand)inotifyArgs;

            SkillFight(serData.nFightCode);
        }
Ejemplo n.º 8
0
    private void SendNormalSkillCommand(int skillId)
    {
        Int64 targetEntityId = 0;

        if (m_skillBase.SkillData.IsLockTarget)
        {
            //计算锁定目标,保存在PlayerBehaviour一个变量,并把目标发给服务器端
            var targetEntityModel = LockAttackMonster(this.m_attackDistance, this.m_attackAngle);
            if (targetEntityModel != null)
            {
                m_PlayerBehaviour.ActionLockTarget = targetEntityModel;
                targetEntityId = targetEntityModel.EntityDataStruct.SMsg_Header.uidEntity;
            }
        }

        float xValue, yValue;

        this.m_PlayerBehaviour.ThisTransform.position.SetToServer(out xValue, out yValue);
        if (GameManager.Instance.CurrentGameMode == GameMode.MULTI_PLAYER)
        {
            SMsgBattleCommand sMsgBattleCommand = new SMsgBattleCommand();
            sMsgBattleCommand.uidFighter = this.m_PlayerBehaviour.RoleDataModel.SMsg_Header.uidEntity;
            sMsgBattleCommand.uidTarget  = targetEntityId;
            sMsgBattleCommand.nFightCode = skillId;


            float xFireValue, yFireValue;

            if (2 == m_skillBase.SkillData.m_directionParam)
            {
                this.m_PlayerBehaviour.SkillFirePos.SetToServer(out xFireValue, out yFireValue);
            }
            else
            {
                this.m_PlayerBehaviour.ThisTransform.position.SetToServer(out xFireValue, out yFireValue);
            }

            sMsgBattleCommand.xPlayer = xValue;
            sMsgBattleCommand.yPlayer = yValue;
            sMsgBattleCommand.xMouse  = xFireValue;
            sMsgBattleCommand.yMouse  = yFireValue;

            var euler = this.m_PlayerBehaviour.ThisTransform.rotation.eulerAngles;

            var d = Quaternion.Euler(euler) * Vector3.forward;

            sMsgBattleCommand.xDirect = d.x;
            sMsgBattleCommand.yDirect = d.z * -1;

            //add by lee
            sMsgBattleCommand.bulletIndex = (UInt32)BulletManager.Instance.ReadIndex(this.m_PlayerBehaviour.RoleDataModel.SMsg_Header.uidEntity);

            NetServiceManager.Instance.BattleService.SendBattleCommand(sMsgBattleCommand);
        }

        else if (GameManager.Instance.CurrentGameMode == GameMode.SINGLE_PLAYER)
        {
            SMsgFightCommand_CS sMsgFightCommand_CS = new SMsgFightCommand_CS();
            sMsgFightCommand_CS.uidFighter  = this.m_PlayerBehaviour.RoleDataModel.SMsg_Header.uidEntity;
            sMsgFightCommand_CS.nFightCode  = skillId;
            sMsgFightCommand_CS.byType      = 1;
            sMsgFightCommand_CS.fighterPosX = xValue;
            sMsgFightCommand_CS.fighterPosY = yValue;

            NetServiceManager.Instance.BattleService.SendFightCommandCS(sMsgFightCommand_CS);
        }



        //\edit by lee
        //SMsgActionClientOptMove_CS sMsgActionClientOptMove = new SMsgActionClientOptMove_CS();
        //sMsgActionClientOptMove.dwMapID = GameManager.Instance.GetCurSceneMapID;
        //sMsgActionClientOptMove.dwPathLen = 1;
        //NetServiceManager.Instance.BattleService.SendClientOptMoveCommand(sMsgActionClientOptMove);
    }