コード例 #1
0
        public void receivedMessage(ObserverMsgTypeEnum messageType, object paramsObj, PublisheOptionVo options)
        {
            switch (messageType)
            {
            case ObserverMsgTypeEnum.BEHAVIOUR_MACHINE_GLOBALBLACKBOARD_FINISHED:
            {
                if (paramsObj is IMoojiBehaviourManager)
                {
                    sendFinishedFsmEvent();
                }
                else
                {
                    throw new Exception("BEHAVIOUR_MACHINE_GLOBALBLACKBOARD_FINISHED 该消息 必须是实现了 IMoojiBehaviourManager 的实例!");
                }

                break;
            }

            case ObserverMsgTypeEnum.BEHAVIOUR_MACHINE_FSM_EVENT:
            {
                int fsmEventID = (int)paramsObj;
                sendFinishedFsmEvent(fsmEventID);
                break;
            }

            case ObserverMsgTypeEnum.BEHAVIOUR_MACHINE_SET_AS_CONCURRENT:
            {
                _justOneConcurrent = paramsObj as MoojiConCurrentMonoState;
                break;
            }
            }
        }
コード例 #2
0
        }// end fun registerMsg ...

        public void publisheMsg(ObserverMsgTypeEnum key, System.Object msgParams = null, PublisheOptionVo options = null)
        {
            if (_msgMapping.ContainsKey(key))
            {
                List <ISubscriber> targetLst = _msgMapping[key];

                foreach (ISubscriber target in targetLst)
                {
                    if (target is MonoBehaviour)
                    {
                        MonoBehaviour mb       = target as MonoBehaviour;
                        GameObject    targetGo = mb.gameObject;

                        if (targetGo.activeSelf && targetGo.activeInHierarchy && mb.enabled)
                        {
                            target.receivedMessage(key, msgParams, options);
                        }
                    }
                    else
                    {
                        target.receivedMessage(key, msgParams, options);
                    }
                }
            }
        }
コード例 #3
0
 public void receivedMessage(ObserverMsgTypeEnum messageType, object paramsObj, PublisheOptionVo options)
 {
     switch (messageType)
     {
     case ObserverMsgTypeEnum.INPUT_CLICKED_HIT_3D_GAME_OBJECT:
     {
         moveToByClickFloor(((RaycastHit)paramsObj).point);
         break;
     }
     }// end switch ...
 }
コード例 #4
0
        public void receivedMessage(ObserverMsgTypeEnum messageType, object paramsObj, PublisheOptionVo options)
        {
            switch (messageType)
            {
            case ObserverMsgTypeEnum.INPUT_CLICKED_HIT_3D_GAME_OBJECT:
            {
                _mainPlayer = GameObject.FindGameObjectWithTag("Player");



                return;


                //_raycastHit = (RaycastHit) paramsObj;

                //IAIBattleUnit battleUnit = _raycastHit.collider.gameObject.GetComponent<IAIBattleUnit>();

                ////  是一个战斗单位
                //if ( battleUnit != null )
                //{
                //    //  告诉作战单位 你将要被攻击
                //    battleUnit.doReadyToAcceptAttack( _raycastHit );


                //    //  移动到 可以攻击的位置
                //    Vector3 targetPosition = battleUnit.doGetComponent<Rigidbody>().position + _raycastHit.point.normalized * -1f;
                //    NavMeshPath navMeshPath = new NavMeshPath();
                //    GameConfigVo gameConfigVo = BehaviourManagermentCenter.getGameConfigBehaviour().gameConfigVo;
                //    int gameLayerByMovement = NavMesh.GetAreaFromName( gameConfigVo.gameLayer_unit_movement );

                //    if ( NavMesh.CalculatePath( _mainPlayer.GetComponent<Rigidbody>().position , targetPosition , gameLayerByMovement , navMeshPath ) )
                //    {
                //        _mainPlayer.GetComponent<AIPlayerMovementByCalculatePath>().doMove( navMeshPath );
                //    }
                //}

                //else
                //{
                //    NavMeshPath navMeshPath = new NavMeshPath();
                //    GameConfigVo gameConfigVo = BehaviourManagermentCenter.getGameConfigBehaviour().gameConfigVo;
                //    int gameLayerByMovement = NavMesh.GetAreaFromName( gameConfigVo.gameLayer_unit_movement );

                //    if ( NavMesh.CalculatePath( _mainPlayer.GetComponent<Rigidbody>().position , _raycastHit.point , gameLayerByMovement , navMeshPath ) )
                //    {
                //        _mainPlayer.GetComponent<AIPlayerMovementByCalculatePath>().doMove( navMeshPath );
                //    }
                //}



                break;
            }
            }// end switch ...
        }
コード例 #5
0
 public void receivedMessage(ObserverMsgTypeEnum messageType, object paramsObj, PublisheOptionVo options)
 {
     switch (messageType)
     {
     case ObserverMsgTypeEnum.INPUT_CLICKED_HIT_3D_GAME_OBJECT:
     {
         hit = (RaycastHit)paramsObj;
         nav.SetDestination(hit.point);
         break;
     }
     }
 }
コード例 #6
0
 public void receivedMessage(ObserverMsgTypeEnum messageType, object paramsObj, PublisheOptionVo options)
 {
     switch (messageType)
     {
     case ObserverMsgTypeEnum.INPUT_CLICKED_HIT_3D_GAME_OBJECT:
     {
         //  点击地板的 十字图片 移动到点击的地方
         RaycastHit raycastHit = ((RaycastHit)paramsObj);
         _maskGo.transform.position = new Vector3(raycastHit.point.x, 0f, raycastHit.point.z);
         break;
     }
     }// end switch ...
 }
コード例 #7
0
 private IEnumerator coroutinePublisheMsg()
 {
     while (true)
     {
         if (_coroutinePublisheMsgLst.Count != 0)
         {
             ObserverMsgTypeEnum key       = (ObserverMsgTypeEnum)_coroutinePublisheMsgLst[0][0];
             System.Object       msgParams = _coroutinePublisheMsgLst[0][1];
             PublisheOptionVo    options   = _coroutinePublisheMsgLst[0][2] as PublisheOptionVo;
             this.publisheMsg(key, msgParams, options);
             _coroutinePublisheMsgLst.RemoveAt(0);
         }
         yield return(null);
     }
 }
コード例 #8
0
        public void receivedMessage(ObserverMsgTypeEnum messageType, object paramsObj, PublisheOptionVo options)
        {
            this.enabled = true;

            switch (messageType)
            {
            case ObserverMsgTypeEnum.INPUT_CLICKED_HIT_3D_GAME_OBJECT:
            {
                sendFsmEvent(FSMEventsBlackBoard.FSM_CLICK_3D_GO);
                break;
            }

            case ObserverMsgTypeEnum.INPUT_CLICKED_HIT_2D_GAME_OBJECT:
            {
                sendFsmEvent(FSMEventsBlackBoard.FSM_CLICK_2D_GO);
                break;
            }
            }
        }
コード例 #9
0
    public void receivedMessage(ObserverMsgTypeEnum messageType, object paramsObj, PublisheOptionVo options)
    {
        switch (messageType)
        {
        case ObserverMsgTypeEnum.INPUT_CLICKED_HIT_3D_GAME_OBJECT:
        {
            RaycastHit hit = (RaycastHit)paramsObj;

            GetComponent <Animator>().applyRootMotion = true;
            _agent = GetComponent <NavMeshAgent>();
            _agent.updateRotation = false;

            this.transform.DOLookAt(hit.point, .2f, AxisConstraint.Y);


            _agent.SetDestination(hit.point);
            GetComponent <Animator>().SetFloat("Forward", 1);

            break;
        }
        }
    }
コード例 #10
0
        public void receivedMessage(ObserverMsgTypeEnum messageType, object paramsObj, PublisheOptionVo options)
        {
            switch (messageType)
            {
            case ObserverMsgTypeEnum.PLAYER_START_TO_MOVE_BY_CLICK_GROUND:
            {
                _animatorComponent.SetFloat("OnAttack", 0f);

                //  如果之前有选中可攻击的作战单位,把选中的 maskGo Active设置 false
                _playerInfoBlackBoard.getSelectBattleUnitLocaltionMaskGo().SetActive(false);


                //  告诉移动组建,开始移动
                RaycastHit raycastHit = (RaycastHit)paramsObj;
                this.doMoveToByPosition(raycastHit.point);

                break;
            }

            case ObserverMsgTypeEnum.PLAYER_START_ATTACK:
            {
                AIBattleUnit selectBattleUnit = this.getCurrSelectBattleUnit(paramsObj);

                if (_palyerBattleUnitComponent.gameObject != _playerInfoBlackBoard.getCurrleadGo())
                {
                    throw new Exception("PlayerUnitManager 只能添加到主角身上");
                }

                //  如果攻击的不是自己
                if (_palyerBattleUnitComponent != selectBattleUnit)
                {
                    _palyerBattleUnitComponent.attack(selectBattleUnit);
                }

                break;
            }
            }
        }
コード例 #11
0
 public void publisheMsgByCoroutine(ObserverMsgTypeEnum key, System.Object msgParams = null, PublisheOptionVo options = null)
 {
     _coroutinePublisheMsgLst.Add(new object[] { key, msgParams, options });
 }
コード例 #12
0
        public void receivedMessage(ObserverMsgTypeEnum messageType, object paramsObj, PublisheOptionVo options)
        {
            switch (messageType)
            {
            case ObserverMsgTypeEnum.INPUT_CLICKED_HIT_3D_GAME_OBJECT:
            {
                //  点击命中info
                //_raycastHit = (RaycastHit) paramsObj;

                //if ( canMove() )
                //{

                //    //  正在走或跑的时候,要求改变路径
                //    if ( _currFrowardNum != 0 && _monementTweener != null )
                //    {
                //        _monementTweener.Kill();

                //        //  从跑到走
                //        _monementTweener = DOVirtual.Float( _currFrowardNum , 0f , 1f , ( float val ) =>
                //        {
                //            _currFrowardNum = val;
                //            _ani.SetFloat( "Forward" , _currFrowardNum );

                //        } );
                //    }

                //    //  移动中函数添加到 fixedUpdate  角度<60度开跑,其他事件等待转向
                //    joinFixedUpdateCallBack( this.fixedMoving );
                //}

                //joinFixedUpdateCallBack( this.fixedRotation );

                break;
            }


            case ObserverMsgTypeEnum.PLAYER_CONTROLER_CHANGED:
            {
                object[]          objs  = paramsObj as object[];
                List <GameObject> goLst = objs[0] as List <GameObject>;
                List <PlayerConstant.PlayerControlerType> pctLst = objs[1] as List <PlayerConstant.PlayerControlerType>;

                int index = goLst.IndexOf(this.gameObject);

                if (index >= 0)
                {
                    PlayerConstant.PlayerControlerType pct = pctLst[index];

                    switch (pct)
                    {
                    case PlayerConstant.PlayerControlerType.PROTAGONIST:
                    {
                        break;
                    }

                    case PlayerConstant.PlayerControlerType.FOLLOWER:
                    {
                        break;
                    }

                    case PlayerConstant.PlayerControlerType.INCONTROLLABLE:
                    {
                        break;
                    }
                    }

                    //base.maskGo.SetActive( true );

                    //base.playerDescribeVo.playerControlerType = pct;
                }

                break;
            }


            case ObserverMsgTypeEnum.PLAYER_FOLLOW_TARGET_CHANGED:
            {
                //GameObject followTargetGo = paramsObj as GameObject;

                //if ( followTargetGo == this.gameObject )
                //{
                //    base.playerDescribeVo.floowOffsetVec3 = Vector3.zero;
                //    return;
                //}

                ////  =============== 应该从 数据库配置文件取 这个对象 应该在那个位置   ===============
                //if ( this.gameObject.name == "player1" )
                //{
                //    base.playerDescribeVo.floowOffsetVec3 = followTargetGo.transform.position - new Vector3( 1.5f , 0 , 0 );
                //}
                //else if ( this.gameObject.name == "player2" )
                //{
                //    base.playerDescribeVo.floowOffsetVec3 = followTargetGo.transform.position - new Vector3( -1.5f , 0 , 0 );
                //}
                //else if ( this.gameObject.name == "player3" )
                //{
                //    base.playerDescribeVo.floowOffsetVec3 = followTargetGo.transform.position - new Vector3( 0f , 0 , 1.5f );
                //}
                //else if ( this.gameObject.name == "player4" )
                //{
                //    base.playerDescribeVo.floowOffsetVec3 = followTargetGo.transform.position - new Vector3( 0f , 0 , -1.5f );
                //}
                ////  =============== 应该从 数据库配置文件取 这个对象 应该在那个位置   ===============

                break;
            }
            } // end switch ...
        }     // end fun ...
コード例 #13
0
 protected void publisheMsgByCoroutine(ObserverMsgTypeEnum msg, object paramsObj)
 {
     BMC.getObserverBehaviour().publisheMsgByCoroutine(msg, paramsObj);
 }
コード例 #14
0
 public void receivedMessage(ObserverMsgTypeEnum messageType, object paramsObj, PublisheOptionVo options)
 {
 }
コード例 #15
0
        //  ====================================    [IPlayerMove end ]   =====================================
        public void receivedMessage(ObserverMsgTypeEnum messageType, object paramsObj, PublisheOptionVo options)
        {
            switch (messageType)
            {
            //case ObserverMsgTypeEnum.PLAYER_TRIGGER_MOVEMENT_POSITION_DEVICE:
            //{

            //    //  是否还有下一条路径
            //    if ( hasNextPath() )
            //    {
            //        _currPathIndex += 1;
            //        _currPathVec3 = _currCanMoveNavMeshPath.corners[_currPathIndex];
            //    }
            //    else
            //    {
            //        _ani.SetFloat( aniKeyTrun , 0 );
            //        _ani.SetFloat( aniKeyForward , 0 );
            //        removeUpdateCallBack( this.moving );
            //    }

            //    break;
            //}


            case ObserverMsgTypeEnum.PLAYER_CONTROLER_CHANGED:
            {
                //object[] objs                                       = paramsObj as object[];
                //List<GameObject> goLst                              = objs[0] as List<GameObject>;
                //List < PlayerConstant.PlayerControlerType> pctLst   = objs[1] as List<PlayerConstant.PlayerControlerType>;

                //int index =  goLst.IndexOf( this.gameObject );

                //if ( index >= 0 )
                //{
                //    PlayerConstant.PlayerControlerType pct = pctLst[index];

                //    switch ( pct )
                //    {
                //        case PlayerConstant.PlayerControlerType.PROTAGONIST:
                //        {
                //            break;

                //        }
                //        case PlayerConstant.PlayerControlerType.FOLLOWER:
                //        {
                //            break;
                //        }
                //        case PlayerConstant.PlayerControlerType.INCONTROLLABLE:
                //        {
                //            break;
                //        }

                //    }

                //    //base.maskGo.SetActive( true );

                //    base.playerDescribeVo.playerControlerType = pct;
                //}

                break;
            }


            case ObserverMsgTypeEnum.PLAYER_FOLLOW_TARGET_CHANGED:
            {
                //GameObject followTargetGo = paramsObj as GameObject;

                //if ( followTargetGo == this.gameObject )
                //{
                //    base.playerDescribeVo.floowOffsetVec3 = Vector3.zero;
                //    return;
                //}

                ////  =============== 应该从 数据库配置文件取 这个对象 应该在那个位置   ===============
                //if ( this.gameObject.name == "player1" )
                //{
                //    base.playerDescribeVo.floowOffsetVec3 = followTargetGo.transform.position - new Vector3( 1.5f , 0 , 0 );
                //}
                //else if ( this.gameObject.name == "player2" )
                //{
                //    base.playerDescribeVo.floowOffsetVec3 = followTargetGo.transform.position - new Vector3( -1.5f , 0 , 0 );
                //}
                //else if ( this.gameObject.name == "player3" )
                //{
                //    base.playerDescribeVo.floowOffsetVec3 = followTargetGo.transform.position - new Vector3( 0f , 0 , 1.5f );
                //}
                //else if ( this.gameObject.name == "player4" )
                //{
                //    base.playerDescribeVo.floowOffsetVec3 = followTargetGo.transform.position - new Vector3( 0f , 0 , -1.5f );
                //}
                ////  =============== 应该从 数据库配置文件取 这个对象 应该在那个位置   ===============

                break;
            }
            }// end switch ...
        }