Пример #1
0
    void ReceiveCommand2v(int cmd, Vector3 vParam1, Vector3 vParam2, int networkID, int commandIndex, Vector3 commandPos, PhotonMessageInfo msgInfo)
    {
        Debug.Log("[RPC] [receive] command:" + (FCCommand.CMD)cmd + " obj:" + networkID + " from player:" + msgInfo.sender
                  + " delayMS : " + ((int)((PhotonNetwork.time - msgInfo.timestamp) * 1000)).ToString());

        //put the command into input command list
        OBJECT_ID object_ID = ObjectManager.Instance.GetObjectByNetworkID(networkID);

        if (object_ID == null)
        {
            Debug.Log("command target object is not exist: " + networkID);
        }
        else
        {
            FCCommand ewd = new FCCommand();
            ewd.Set((FCCommand.CMD)cmd,
                    object_ID,
                    vParam1, FC_PARAM_TYPE.VECTOR3,
                    vParam2, FC_PARAM_TYPE.VECTOR3,
                    null, FC_PARAM_TYPE.NONE,
                    FCCommand.STATE.RIGHTNOW,
                    false);

            WriteCommandToCache(object_ID.NetworkId, commandPos, false, commandIndex, ewd);
        }
    }
Пример #2
0
    public bool Send(FCCommand.CMD cmd, OBJECT_ID objectID, FCCommand.STATE state, bool isHost)
    {
        bool ret = false;

        if (state != FCCommand.STATE.RIGHTNOW)
        {
            FCCommand ewd = null;
            if (_deActiveCommandList.Count != 0)
            {
                ewd = _deActiveCommandList[0];
                _deActiveCommandList.Remove(ewd);
            }
            else
            {
                ewd = new FCCommand();
            }
            ewd.Set(cmd, objectID, state, isHost);
            AddCmdToArray(ewd);
        }
        else
        {
            _fastCommand.Set(cmd, objectID, state, isHost);
            if (objectID.HandleCommand(ref _fastCommand))
            {
                _fastCommand._objID = null;
                ret = true;
            }
            else
            {
                //AddCmdToArray(ewd);
                // may need to add it to command list
            }
        }
        return(ret);
    }
Пример #3
0
    public override bool HandleCommand(ref FCCommand ewd)
    {
        int  rootcmd = ((int)ewd._cmd / 100) * 100;
        int  subcmd  = ((int)ewd._cmd);
        bool canrun  = true;
        bool ret     = false;

        if (canrun)
        {
            if (rootcmd < 0 ||
                (rootcmd == (int)FCCommand.CMD.MOVE && HasActionSwitchFlag(FC_ACTION_SWITCH_FLAG.CANT_MOVE))
                )
            {
                canrun = false;
            }
        }

        if (canrun)
        {
            switch ((FCCommand.CMD)rootcmd)
            {
            case FCCommand.CMD.MOVE:
                if (_state != null && _state.CurrentStateID == AIAgent.STATE.IDLE)
                {
                    ret = SetNextState(AIAgent.STATE.RUN);
                }
                break;
            }
            if (subcmd >= 0)
            {
                ret = HandleInnerCmd((FCCommand.CMD)subcmd, null, ewd._param1, ewd._param2, ewd._param3);
            }
        }
        return(ret);
    }
Пример #4
0
    public override bool HandleCommand(ref FCCommand ewd)
    {
        switch (ewd._cmd)
        {
        case FCCommand.CMD.ATTACK_HIT_TARGET:
        {
            ActionController ac = ewd._param1 as ActionController;
            Assertion.Check(ac != null);
            EnemyInRange info = new EnemyInRange();
            info._ac    = ac;
            info._timer = 0.0f;
            _enemys.Add(info);
        }
        break;

        case FCCommand.CMD.ATTACK_OUT_OF_RANGE:
        {
            ActionController ac = ewd._param1 as ActionController;
            Assertion.Check(ac != null);
            for (int i = _enemys.Count - 1; i >= 0; --i)
            {
                if (_enemys[i]._ac == ac)
                {
                    _enemys.RemoveAt(i);
                    break;
                }
            }
        }
        break;

        default:
            break;
        }
        return(true);
    }
Пример #5
0
    public void Init(FCObject owner)
    {
        _owner              = owner;
        _isInMoveS          = false;
        _isInMoveD          = false;
        _isInNavPathFinding = false;
        _currentSpeed       = 0;
        _moveDirection      = Vector3.zero;
        _fastCommand        = new FCCommand();
        _thisRigidBody      = _owner.rigidbody;
        if (_thisRigidBody != null)
        {
            _thisRigidBody.drag        = 100;
            _thisRigidBody.isKinematic = true;
        }
        _currentMoveLengthCount = 0;
        _currentMoveLength      = 0;

        _characterController = _owner.GetComponent <CharacterController>();

        _fastCommand.Set(FCCommand.CMD.STOP, owner.ObjectID, FCCommand.STATE.RIGHTNOW, true);
        if (_navAgent != null)
        {
            _navAgent.radius  = 0;
            _navAgent.enabled = false;
            _defaultRaduis    = _navAgent.radius;
        }
        _rotateDirection = _owner.ThisTransform.forward;
        if (_fallHeight <= 0)
        {
            _fallHeight = 1;
        }
        //_gReadAccel.y =  FC_CONST.REAL_G;
    }
Пример #6
0
    public FCCommand ReadCommandFromCache2(int objID)
    {
        FC_COMMAND_NETSTREAM ecns = null;
        FCCommand            ewc  = null;
        FCCommand            ret  = null;

        if (_commandCmdStreamCache.ContainsKey(objID))
        {
            List <FC_COMMAND_NETSTREAM> list = _commandCmdStreamCache[objID];
            if (list.Count > 0)
            {
                ecns = list[0];
            }
            else
            {
                ecns = null;
            }
        }
        else
        {
            ecns = null;
        }

        if (_commandRpcCache.ContainsKey(objID))
        {
            List <FCCommand> list = _commandRpcCache[objID];
            if (list.Count > 0)
            {
                ewc = _commandRpcCache[objID][0];
                if (ecns != null && ecns._commandIndex < ewc._cmdIndex)
                {
                    ret = new FCCommand(ecns);
                    _commandCmdStreamCache[objID].RemoveAt(0);
                }
                else
                {
                    ret = ewc;
                    //		Debug.Log(string.Format("[rpc command] ReadCommandFromCache2 -- remove  _commandIndex:{0} , _currentPosition:{1} , CMD = {2}" ,
                    //		ewc._cmdIndex , ewc._commandPosition , ewc._cmd ));
                    _commandRpcCache[objID].RemoveAt(0);
                }
            }
            else
            {
                ewc = null;
            }
        }
        else
        {
            ewc = null;
        }
        if (ecns != null && ret == null)
        {
            ret = new FCCommand(ecns);
            _commandCmdStreamCache[objID].RemoveAt(0);
        }

        return(ret);
    }
Пример #7
0
    //update and distribute input command list
    private void UpdateInputCommanList()
    {
        //check input command list and distribute
        int inputCommandListCount = _inputCommandList.Count;

        if (inputCommandListCount > 0)
        {
            Debug.Log("[receive] command count: " + inputCommandListCount);

            for (int i = 0; i < inputCommandListCount; i++)
            {
                //handle commands
                FCCommand command = _inputCommandList[i];
                Debug.Log("[receive] command : " + command._cmd);


                switch (command._cmd)
                {
                case FCCommand.CMD.CLIENT_MOVE_TO_POINT:
                case FCCommand.CMD.CLIENT_HURT:
                case FCCommand.CMD.CLIENT_HURT_HP:
                case FCCommand.CMD.CLIENT_THREAT:
                case FCCommand.CMD.CLIENT_LEVELUP:
                case FCCommand.CMD.CLIENT_CURRSTATE:
                case FCCommand.CMD.CLIENT_POTION_HP:
                case FCCommand.CMD.CLIENT_POTION_ENERGY:
                case FCCommand.CMD.CLIENT_REVIVE:
                {
                    //handle this right now, network agent will do it
                    _inputCommandList[i]._objID.HandleCommand(ref command);
                }
                break;

                case FCCommand.CMD.DIE_NORMAL:
                case FCCommand.CMD.ATTACK_WITH_SPEC_CONTS:
                case FCCommand.CMD.ACTION_CANCEL:
                {
                    //convert to self fast inner command
                    command._isHost = true;
                    CommandManager.Instance.SendFastToSelf(ref command);
                }
                break;


                default:
                {
                    Debug.LogError("receive command but cannot handle :" + command._cmd);
                }
                break;
                }
            }

            //clear command list
            _inputCommandList.Clear();
        }
    }
Пример #8
0
 void Awake()
 {
     _fastCommand = new FCCommand();
     _fastCommand.Set(FCCommand.CMD.STOP, null, FCCommand.STATE.RIGHTNOW, true);
     _threatTable             = new ThreatTable();
     _threatTable._length     = 4;
     _threatTable._threatList = new int[_threatTable._length];
     _threatTable._targetList = new ActionController[_threatTable._length];
     _threatTable._count      = 0;
 }
Пример #9
0
 public bool HandleCommand(ref FCCommand ewd)
 {
     if (!_fcObj.IsDestroyed)
     {
         return(_fcObj.HandleCommand(ref ewd));
     }
     else
     {
         return(true);
     }
 }
Пример #10
0
    protected override void Awake()
    {
        base.Awake();
        _isRangerBullet = true;         // make me be enable to override function 'FireRange()'
        _enemys         = new System.Collections.Generic.List <EnemyInRange>();
        _mask           = (1 << LayerMask.NameToLayer("WALL"));
        _mask          |= (1 << LayerMask.NameToLayer("WALL_AIR"));
        _mask          |= (1 << LayerMask.NameToLayer("GROUND"));

        _fastCommand         = new FCCommand();
        _fastCommand._param1 = this;
        _fastCommand._cmd    = FCCommand.CMD.HURT;
    }
Пример #11
0
 public FCCommand(FCCommand ewc)
 {
     _cmdIndex   = ewc._cmdIndex;
     _cmd        = ewc._cmd;
     _param1     = ewc._param1;
     _param2     = ewc._param2;
     _param3     = ewc._param3;
     _param1Type = ewc._param1Type;
     _param2Type = ewc._param2Type;
     _param3Type = ewc._param3Type;
     _objID      = ewc._objID;
     _state      = ewc._state;
     _isHost     = ewc._isHost;
 }
Пример #12
0
    public void AddCmdToArray(FCCommand ewd)
    {
        List <FCCommand> ewdl = null;

        if (_commandArray.ContainsKey((int)ewd._objID))
        {
            ewdl = _commandArray[(int)ewd._objID];
        }
        else
        {
            ewdl = new List <FCCommand>();
            _commandArray[(int)ewd._objID] = ewdl;
        }
        ewdl.Add(ewd);
        Send(FCCommand.CMD.NET_HAS_EVENT, ewdl[0], FC_PARAM_TYPE.OTHERS, ewdl[0]._objID, FCCommand.STATE.RIGHTNOW, true);
    }
Пример #13
0
    public bool SendFast(ref FCCommand ewd, FCObject eb)
    {
        if (ewd._cmd == FCCommand.CMD.INVALID)
        {
            return(false);
        }

        if (ewd._cmd == FCCommand.CMD.ATTACK_HIT_TARGET)
        {
            ActionController ac = ewd._param1 as ActionController;
            if (ac.IsPlayerSelf)
            {
                //ac.
            }
        }
        return(eb.ObjectID.HandleCommand(ref ewd));
    }
Пример #14
0
    public override bool HandleCommand(ref FCCommand ewd)
    {
        switch (ewd._cmd)
        {
        case FCCommand.CMD.ATTACK_HIT_TARGET:
        {
            ActionController target = ewd._param1 as ActionController;
            HandleHitTarget.HandleHit(_owner, this, _damageType, target);

            if (GetAttackInfo()._hitType == AttackHitType.ForceBack)
            {
                AIAgent aiAgent = _owner.gameObject.GetComponentInChildren <AIAgent>();
                if (aiAgent != null)
                {
                    aiAgent.AddHitBackList(target);
                }
            }
            if (_hitSound != "")
            {
                SoundManager.Instance.PlaySoundEffect(_hitSound);
            }
        }
        break;

        case FCCommand.CMD.ATTACK_OUT_OF_RANGE:
        {
            ActionController target = ewd._param1 as ActionController;

            if (GetAttackInfo()._hitType == AttackHitType.ForceBack)
            {
                AIAgent aiAgent = _owner.gameObject.GetComponentInChildren <AIAgent>();
                if (aiAgent != null)
                {
                    if (!GameManager.Instance.IsPVPMode)
                    {
                        aiAgent.RemoveHitBackList(target);
                    }
                }
            }
        }
        break;
        }
        return(true);
    }
Пример #15
0
    public override bool HandleCommand(ref FCCommand ewd)
    {
        switch (ewd._cmd)
        {
        case FCCommand.CMD.ATTACK_HIT_TARGET:
        {
            _targetList.Add((ewd._param1 as ActionController));
            break;
        }

        case FCCommand.CMD.ATTACK_OUT_OF_RANGE:
        {
            _targetList.Remove((ewd._param1 as ActionController));
            (ewd._param1 as ActionController).ACEffectByGravity(0, null, 0, true, false);
            break;
        }
        }
        return(true);
    }
Пример #16
0
 protected virtual void FirstInit()
 {
     _fastCommand = new FCCommand();
     _fastCommand.Set(FCCommand.CMD.STOP, null, FCCommand.STATE.RIGHTNOW, true);
     _thisObject   = gameObject;
     _selfCollider = _thisObject.collider;
     if (_selfCollider.GetType().ToString().Contains("Sphere"))
     {
         _colliderType = COLLIDER_TYPE.Sphere;
     }
     else if (_selfCollider.GetType().ToString().Contains("Capsule"))
     {
         _colliderType = COLLIDER_TYPE.Capsule;
     }
     if (_parent != null && _parent.ObjectID.ObjectType == FC_OBJECT_TYPE.OBJ_BULLET)
     {
         ((FCBullet)_parent)._damageReceiver = this;
         DeActiveLogic();
     }
 }
Пример #17
0
    public override bool HandleCommand(ref FCCommand ewd)
    {
        base.HandleCommand(ref ewd);
        switch (ewd._cmd)
        {
        case FCCommand.CMD.ATTACK_HIT_TARGET:
        {
            if (_attackInfo._hitType == AttackHitType.BlackHole)
            {
                _targetList.Add((ewd._param1 as ActionController));
            }
            else if (_attackInfo._hitType == AttackHitType.Lock)
            {
                _targetList.Add((ewd._param1 as ActionController));
            }

            break;
        }
        }
        return(true);
    }
Пример #18
0
 public override bool HandleCommand(ref FCCommand ewd)
 {
     switch (ewd._cmd)
     {
     case FCCommand.CMD.ATTACK_HIT_TARGET:
     {
         if (_attackInfo._hitType == AttackHitType.BlackHole)
         {
             _targetList.Add((ewd._param1 as ActionController));
         }
         else if (_attackInfo._hitType == AttackHitType.Lock)
         {
             _targetList.Add((ewd._param1 as ActionController));
         }
         ActionController target = ewd._param1 as ActionController;
         IsHitSomeone(_owner, this, _damageType, target);
         break;
     }
     }
     return(true);
 }
Пример #19
0
    public override bool HandleCommand(ref FCCommand ewd)
    {
        switch (ewd._cmd)
        {
        case FCCommand.CMD.ATTACK_HIT_WALL:
            if (!_deadByLifeOver)
            {
                _curBombPosition = BOMB_POSITION.AT_HIT_WALL;
                Dead();
            }

            break;

        case FCCommand.CMD.ATTACK_HIT_GROUND:
            if (_shakePos == SHAKE_POS.AT_HIT_GROUND)
            {
                CameraController.Instance.StartCameraEffect(EnumCameraEffect.none, _shakeLevel, false);
            }
            if (_moveAgent != null)
            {
                _moveAgent.IsOnGround = true;
            }
            if (!_deadByLifeOver && _moveAgent.IsOnGround)
            {
                _curBombPosition = BOMB_POSITION.AT_HIT_GROUND;

                Dead();
            }

            break;

        case FCCommand.CMD.ATTACK_HIT_TARGET:
        {
            ActionController target = ewd._param1 as ActionController;
            IsHitSomeone(_owner, this, _damageType, target);
        }
        break;
        }
        return(true);
    }
Пример #20
0
    public void ReadCommandFromCache(int objID, out FCCommand ewc, out FC_COMMAND_NETSTREAM ecns)
    {
        if (_commandCmdStreamCache.ContainsKey(objID))
        {
            List <FC_COMMAND_NETSTREAM> list = _commandCmdStreamCache[objID];
            if (list.Count > 0)
            {
                ecns = list[0];
                _commandCmdStreamCache[objID].RemoveAt(0);
            }
            else
            {
                ecns = null;
            }
        }
        else
        {
            ecns = null;
        }

        if (_commandRpcCache.ContainsKey(objID))
        {
            List <FCCommand> list = _commandRpcCache[objID];
            if (list.Count > 0)
            {
                ewc = _commandRpcCache[objID][0];
                _commandRpcCache[objID].RemoveAt(0);
            }
            else
            {
                ewc = null;
            }
        }
        else
        {
            ewc = null;
        }
    }
Пример #21
0
    void ReceiveCommand2q(int cmd, Quaternion qParam1, Quaternion qParam2, int networkID, int commandIndex, Vector3 commandPos, PhotonMessageInfo msgInfo)
    {
        //put the command into input command list
        OBJECT_ID object_ID = ObjectManager.Instance.GetObjectByNetworkID(networkID);

        if (object_ID == null)
        {
            Debug.Log("command target object is not exist: " + networkID);
        }
        else
        {
            FCCommand ewd = new FCCommand();
            ewd.Set((FCCommand.CMD)cmd,
                    object_ID,
                    qParam1, FC_PARAM_TYPE.QUATERNION,
                    qParam2, FC_PARAM_TYPE.QUATERNION,
                    null, FC_PARAM_TYPE.NONE,
                    FCCommand.STATE.RIGHTNOW,
                    false);

            WriteCommandToCache(object_ID.NetworkId, commandPos, false, commandIndex, ewd);
        }
    }
Пример #22
0
    public override bool HandleCommand(ref FCCommand ewd)
    {
        base.HandleCommand(ref ewd);
        switch (ewd._cmd)
        {
        case FCCommand.CMD.ATTACK_HIT_TARGET:
            if (!_deadByLifeOver)
            {
                if (_currentPerHitCount > 0)
                {
                    _currentPerHitCount--;
                    if (_currentPerHitCount <= 0 && !_hitInfo[_step]._canPenetrate)
                    {
                        _inState = false;
                        _moveAgent.Stop();
                    }
                }
            }

            break;
        }
        return(true);
    }
Пример #23
0
    public override bool HandleCommand(ref FCCommand ewd)
    {
        switch (ewd._cmd)
        {
        case FCCommand.CMD.ATTACK_HIT_TARGET:
        {
            ActionController ac = ewd._param1 as ActionController;
            Assertion.Check(ac != null);
            AddNewEnemy(ac);
        }
        break;

        case FCCommand.CMD.ATTACK_OUT_OF_RANGE:
        {
            ActionController ac = ewd._param1 as ActionController;
            Assertion.Check(ac != null);
            // remove from waiting list.
            _savedTarget.Remove(ac);
            // remove from lightning chain.
            foreach (BulletLightningBallChain blbc in _lightningChains)
            {
                if (blbc._target == ac)
                {
                    blbc.End();
                    // seek new target.
                    AssignChainToNewTarget(blbc);
                    break;
                }
            }
        }
        break;

        default:
            break;
        }
        return(true);
    }
Пример #24
0
    //send msg to all clients except me

    public void SendCommandToOthers(FCCommand.CMD cmd,
                                    OBJECT_ID objID,
                                    Vector3 commandPosition,
                                    object param1,
                                    FC_PARAM_TYPE p1Type,
                                    object param2,
                                    FC_PARAM_TYPE p2Type,
                                    object param3,
                                    FC_PARAM_TYPE p3Type
                                    )
    {
        //single player will not send comment to others
        if (PhotonNetwork.room == null)
        {
            return;
        }

        Debug.Log("[send] command:" + cmd + " , obj_network_id:" + objID.NetworkId);

        //build command instance and add into output list
        FCCommand ewd = new FCCommand(GetNextCommandStreamID(objID.NetworkId));

        ewd.Set((FCCommand.CMD)cmd, objID, param1, p1Type, param2, p2Type, param3, p3Type,
                FCCommand.STATE.RIGHTNOW, false);
        ewd._commandPosition = commandPosition;
        if (CheatManager.netDelay > 0)
        {
            StartCoroutine(AddCommand(ewd));
        }
        else
        {
            _outputCommandList.Add(ewd);
        }
        //
        //_outputCommandList.Add(ewd);
    }
Пример #25
0
    void Awake()
    {
        _instance     = this;
        _fastCommand  = new FCCommand();
        _syncTypeFlag = new int[(int)FC_AI_TYPE.MAX];
        for (int i = 0; i < _syncTypeFlag.Length; i++)
        {
            _syncTypeFlag[i] = 0;
            Utils.SetFlag((int)FC_NET_SYNC_TYPE.HIT_PONIT, ref _syncTypeFlag[i]);
        }
        foreach (CommandFilters cfs in _cmdFiltersList)
        {
            foreach (FC_NET_SYNC_TYPE nst in cfs._typeList)
            {
                Utils.SetFlag((int)nst, ref _syncTypeFlag[(int)cfs._aiType]);
            }
        }

        _commandStreamIdDic.Clear();

        if (_useSyncMode && (_syncCommandScript == null))
        {
            if ((_syncCommandObjectPrefeb != null) && (PhotonNetwork.room != null))
            {
                //network instantiate sync obj
                GameObject syncCommandObject = PhotonNetwork.Instantiate(_syncCommandObjectPrefeb.name,
                                                                         transform.position, transform.rotation, 0) as GameObject;

                _syncCommandScript = syncCommandObject.GetComponent <SyncCommand>();
                if (_syncCommandScript == null)
                {
                    Debug.LogError("error, sync command object do not have a sync script");
                }
            }
        }
    }
Пример #26
0
    public void WriteCommandToCache(int netIndex, Vector3 commandPos, bool streamCommand, params object[] args)
    {
        OBJECT_ID objectID = ObjectManager.Instance.GetObjectByNetworkID(netIndex);

        if (objectID == null)
        {
            Debug.LogError(string.Format("Object ID is not exist !  netIndex = {0} , isStreamCommand = {1} ", netIndex, streamCommand));
            return;
        }

        int objID = (int)objectID;

        ActionController ac = ObjectManager.Instance.GetObjectByNetworkID(netIndex).fcObj as ActionController;

        //Debug.Log("ac object id = " + ac.ObjectID + ", object ID = " + objID);
        //if(ac != null && ac.IsPlayer && GameManager.Instance.IsPVPMode)
        if (GameManager.Instance.IsPVPMode)
        {
            int cidx = (int)args[0];             //command stream idx
            if (streamCommand)
            {
                if (ac.AIUse.AIStateAgent.CurrentStateID == AIAgent.STATE.DEAD || ac.AIUse.AIStateAgent.CurrentStateID == AIAgent.STATE.REVIVE)
                {
                    return;
                }

                if (!_commandCmdStreamCache.ContainsKey(objID))
                {
                    _commandCmdStreamCache[objID] = new List <FC_COMMAND_NETSTREAM>();
                }

                List <FC_COMMAND_NETSTREAM> cpc = _commandCmdStreamCache[objID];
                if ((cpc.Count > 0 && cpc[cpc.Count - 1]._commandIndex < cidx) ||
                    cpc.Count == 0)
                {
                    FC_COMMAND_NETSTREAM ecns = new FC_COMMAND_NETSTREAM((FC_COMMAND_NETSTREAM)args[1]);

                    ecns._commandIndex = cidx;
                    if (ecns._state == AIAgent.STATE.HURT)
                    {
                        ac.AIUse.UpdateNetCommand(AIAgent.COMMAND_DONE_FLAG.IN_HURT_STATE);
                    }
                    //Debug.Log(string.Format("[stream command] _commandIndex:{0} , _currentPosition:{1} , _currentRotation{2} , _state{3}" ,
                    //	ecns._commandIndex , ecns._currentPosition , ecns._currentRotation ,ecns._state));
                    cpc.Add(ecns);
                    //Debug.Log("add stream cmd  to list : _myRotation = " + ecns._currentRotation + ", cmd idx = " + ecns._commandIndex);
                }
            }
            else
            {
                if (!_commandRpcCache.ContainsKey(objID))
                {
                    _commandRpcCache[objID] = new List <FCCommand>();
                }

                FCCommand ewc = new FCCommand((FCCommand)args[1]);
                ewc._cmdIndex        = cidx;
                ewc._commandPosition = commandPos;
                ewc._isRun           = false;
                ewc._needRunPerFrame = false;
                ewc._canDrop         = false;
                //Debug.Log(string.Format("[rpc command] _commandIndex:{0} , _currentPosition:{1} , CMD = {2}" ,
                //		ewc._cmdIndex , ewc._commandPosition , ewc._cmd ));

                _commandRpcCache[objID].Add(ewc);
                if (ewc._cmd == FCCommand.CMD.CLIENT_HURT ||
                    ewc._cmd == FCCommand.CMD.ACTION_EOT ||
                    ewc._cmd == FCCommand.CMD.ATTACK_WITH_SPEC_CONTS)
                {
                    //Debug.Log(Time.realtimeSinceStartup);
                    ac.AIUse.UpdateNetCommand();
                }
                //if find rpc command idx < player next command index or current
                //replace command
                //pre command may should return to array
                // all rpc command should have position param
            }
        }
        else
        {
            if (!streamCommand)
            {
                FCCommand ewc = (FCCommand)args[1];
                ewc._cmdIndex = 0;
                _inputCommandList.Add(ewc);
            }
        }
    }
Пример #27
0
    //update and distribute output command list
    private void UpdateOutputCommanList()
    {
        //check output command list and distribute
        int outputCommandListCount = _outputCommandList.Count;

        if (outputCommandListCount > 0)
        {
            for (int i = 0; i < outputCommandListCount; i++)
            {
                //handle commands
                FCCommand command = _outputCommandList[i];

                // 0 param
                if (command._param1Type == FC_PARAM_TYPE.NONE)
                {
                    photonView.RPC("ReceiveCommand0",
                                   PhotonTargets.OthersBuffered,
                                   (int)command._cmd,
                                   command._objID.NetworkId,
                                   GetNextCommandStreamID(command._objID.NetworkId),
                                   command._commandPosition);
                    continue;
                }


                // 1 param, vector
                if ((command._param1Type == FC_PARAM_TYPE.VECTOR3) &&
                    (command._param2Type == FC_PARAM_TYPE.NONE))
                {
                    photonView.RPC("ReceiveCommand1v",
                                   PhotonTargets.Others,
                                   (int)command._cmd,
                                   (Vector3)command._param1,
                                   command._objID.NetworkId,
                                   GetNextCommandStreamID(command._objID.NetworkId),
                                   command._commandPosition);
                    continue;
                }

                // 1 param, float
                if ((command._param1Type == FC_PARAM_TYPE.FLOAT) &&
                    (command._param2Type == FC_PARAM_TYPE.NONE))
                {
                    photonView.RPC("ReceiveCommand1f",
                                   PhotonTargets.Others,
                                   (int)command._cmd,
                                   (float)command._param1,
                                   command._objID.NetworkId,
                                   GetNextCommandStreamID(command._objID.NetworkId),
                                   command._commandPosition);
                    continue;
                }

                // 1 param, int
                if ((command._param1Type == FC_PARAM_TYPE.INT) &&
                    (command._param2Type == FC_PARAM_TYPE.NONE))
                {
                    photonView.RPC("ReceiveCommand1i",
                                   PhotonTargets.Others,
                                   (int)command._cmd,
                                   (int)command._param1,
                                   command._objID.NetworkId,
                                   GetNextCommandStreamID(command._objID.NetworkId),
                                   command._commandPosition);
                    continue;
                }

                // 2 param, int, int
                if ((command._param1Type == FC_PARAM_TYPE.INT) &&
                    (command._param2Type == FC_PARAM_TYPE.INT) &&
                    (command._param3Type == FC_PARAM_TYPE.NONE))
                {
                    photonView.RPC("ReceiveCommand1i2i",
                                   PhotonTargets.Others,
                                   (int)command._cmd,
                                   (int)command._param1,
                                   (int)command._param2,
                                   command._objID.NetworkId,
                                   GetNextCommandStreamID(command._objID.NetworkId),
                                   command._commandPosition);
                    continue;
                }

                // 3 param, int, int, int
                if ((command._param1Type == FC_PARAM_TYPE.INT) &&
                    (command._param2Type == FC_PARAM_TYPE.INT) &&
                    (command._param3Type == FC_PARAM_TYPE.INT))
                {
                    photonView.RPC("ReceiveCommand1i2i3i",
                                   PhotonTargets.Others,
                                   (int)command._cmd,
                                   (int)command._param1,
                                   (int)command._param2,
                                   (int)command._param3,
                                   command._objID.NetworkId,
                                   GetNextCommandStreamID(command._objID.NetworkId),
                                   command._commandPosition);
                    continue;
                }

                // 3 param, int, int, float
                if ((command._param1Type == FC_PARAM_TYPE.INT) &&
                    (command._param2Type == FC_PARAM_TYPE.INT) &&
                    (command._param3Type == FC_PARAM_TYPE.FLOAT))
                {
                    photonView.RPC("ReceiveCommand1i2i3f",
                                   PhotonTargets.Others,
                                   (int)command._cmd,
                                   (int)command._param1,
                                   (int)command._param2,
                                   (float)command._param3,
                                   command._objID.NetworkId,
                                   GetNextCommandStreamID(command._objID.NetworkId),
                                   command._commandPosition);
                    continue;
                }

                // 2 param, float, float
                if ((command._param1Type == FC_PARAM_TYPE.FLOAT) &&
                    (command._param2Type == FC_PARAM_TYPE.FLOAT))
                {
                    photonView.RPC("ReceiveCommand1f2f",
                                   PhotonTargets.Others,
                                   (int)command._cmd,
                                   (float)command._param1,
                                   (float)command._param2,
                                   command._objID.NetworkId,
                                   GetNextCommandStreamID(command._objID.NetworkId),
                                   command._commandPosition);
                    continue;
                }

                // 2 param, vector3 , vector3
                if ((command._param1Type == FC_PARAM_TYPE.VECTOR3) &&
                    (command._param2Type == FC_PARAM_TYPE.VECTOR3))
                {
                    photonView.RPC("ReceiveCommand2v",
                                   PhotonTargets.Others,
                                   (int)command._cmd,
                                   (Vector3)command._param1,
                                   (Vector3)command._param2,
                                   command._objID.NetworkId,
                                   GetNextCommandStreamID(command._objID.NetworkId),
                                   command._commandPosition);
                    continue;
                }

                // 2 param, Quaternion , vector3
                if ((command._param1Type == FC_PARAM_TYPE.QUATERNION) &&
                    (command._param2Type == FC_PARAM_TYPE.QUATERNION))
                {
                    photonView.RPC("ReceiveCommand2q",
                                   PhotonTargets.Others,
                                   (int)command._cmd,
                                   (Quaternion)command._param1,
                                   (Quaternion)command._param2,
                                   command._objID.NetworkId,
                                   GetNextCommandStreamID(command._objID.NetworkId),
                                   command._commandPosition);
                    continue;
                }
            }


            //clear output command list
            _outputCommandList.Clear();
        }
    }
Пример #28
0
    private IEnumerator AddCommand(FCCommand ewd)
    {
        yield return(new WaitForSeconds(CheatManager.netDelay));

        _outputCommandList.Add(ewd);
    }
Пример #29
0
 public virtual bool HandleCommand(ref FCCommand ewd)
 {
     return(true);
 }
Пример #30
0
 public bool SendFastToSelf(ref FCCommand ewd)
 {
     return(ewd._objID.HandleCommand(ref ewd));
 }