コード例 #1
0
    void Awake()
    {
        aiSystem = FindObjectOfType <AISystem>();
        aiSystem.AITurnFinished += OnAiTurnFinished;

        player = FindObjectOfType <PlayerController>();
    }
コード例 #2
0
        /// <summary>
        /// 表示线程池线程要执行的回调方法。
        /// </summary>
        /// <param name="state"></param>
        private void SliceWorld(object state)
        {
            if (OneServer.Closing == true)
            {
                Interlocked.Decrement(ref m_SignalCount);
                return;
            }

            // 运行库为每个可执行文件创建一个异常信息表。在异常信息表中,可执行文件的每个方法都有一个关联的异常处理信息数组(可以为空)。
            // 数组中的每一项描述一个受保护的代码块、任何与该代码关联的异常筛选器和任何异常处理程序(Catch 语句)。此异常表非常有效,
            // 在没有发生异常时,在处理器时间或内存使用上没有性能损失。仅在异常发生时使用资源。
            try
            {
                EventHandler <BaseWorldEventArgs> tempEventArgs = m_EventStartSlice;
                if (tempEventArgs != null)
                {
                    tempEventArgs(this, m_BaseWorldEventArgs);
                }

                // 更新ISupportSlice的处理
                m_SliceUpdate.Slice();

                // AI处理
                AISystem.Slice();

                // 时间片
                TimeSlice.Slice();

                // 测试下来在数组方面for内只使用一个索引数值的时候比foreach速度快,当超过使用两个索引数值时就比foreach慢了。
                // 其他方面foreach比较快
                MessagePump[] tempArray = m_MessagePump;
                for (int iIndex = 0; iIndex < tempArray.Length; iIndex++)
                {
                    tempArray[iIndex].Slice();
                }

                // 发送缓存的数据
                this.FlushAll();

                // 处理已经断开的连接
                this.ProcessDisposed();

                tempEventArgs = m_EventEndSlice;
                if (tempEventArgs != null)
                {
                    tempEventArgs(this, m_BaseWorldEventArgs);
                }

                // 最后需要等待的单处理执行
                m_WaitExecute.Slice();
            }
            catch (Exception exception)
            {
                OneServer.UnhandledException(this, new UnhandledExceptionEventArgs(exception, true));
            }
            finally
            {
                Interlocked.Decrement(ref m_SignalCount);
            }
        }
コード例 #3
0
 public AI_PractiseRebound_Positioning(AISystem owner)
     : base(owner)
 {
     m_eType    = AIState.Type.ePractiseRebound_Positioning;
     timer      = new GameUtils.Timer(new IM.Number(0, 100), OnTimer);
     timer.stop = true;
 }
コード例 #4
0
 public AI_TraceBall(AISystem owner)
     : base(owner)
 {
     m_eType           = AIState.Type.eTraceBall;
     timerRebound      = new GameUtils.Timer(IM.Number.one, OnTimerRebound, 1);
     timerRebound.stop = true;
 }
コード例 #5
0
 private void OnEnable()
 {
     theTarget = new SerializedObject(target);
     aiSystem  = target as AISystem;
     settings  = theTarget.FindProperty("settingsData");
     data      = theTarget.FindProperty("temperamentData");
     EventManager <SettingType> .AddHandler(EVENT.show, ChangeOpenSetting);
 }
コード例 #6
0
 void Update()
 {
     if (calculatePath)
     {
         calculatePath = false;
         Vector2[] path = AISystem.GetPath(GridSystem.System.PosToCoord(walkOnSide, transform.position), GridSystem.System.PosToCoord(walkOnSide, targetPosition), walkOnSide);
         transform.position = GridSystem.System.ToGridPosition(GridSystem.System.CoordToPos(walkOnSide, path[0]));
     }
 }
コード例 #7
0
    protected override void _OnLoadingCompleteImp()
    {
        base._OnLoadingCompleteImp();
        mCurScene.CreateBall();
        mCurScene.mBall.onShootGoal += OnGoal;
        mCurScene.mBall.onGrab      += OnGrab;
        mCurScene.mBall.onDunk      += OnDunk;
        mCurScene.mBall.onHitGround += OnHitGround;

        if (m_config == null)
        {
            Debug.LogError("Match config file loading failed.");
            return;
        }

        //TODO 针对PVP修改
        //main role
        PlayerManager pm = GameSystem.Instance.mClient.mPlayerManager;

        mainRole = pm.GetPlayerById(uint.Parse(m_config.MainRole.id));
        //mainRole.m_inputDispatcher = new InputDispatcher(this, mainRole);
        mainRole.m_catchHelper = new CatchHelper(mainRole);
        mainRole.m_catchHelper.ExtractBallLocomotion();
        mainRole.m_StateMachine.SetState(PlayerState.State.eStand, true);
        mainRole.m_InfoVisualizer.ShowStaminaBar(true);
        mainRole.m_team.m_role = GameMatch.MatchRole.eOffense;
        mainRoleNormalAISystem = new AISystem_Basic(this, mainRole);
        //mainRole.m_aiMgr = mainRoleNormalAISystem;
        mainRole.m_aiMgr.m_enable   = false;
        mainRolePositioningAISystem = new AISystem_BullFight(this, mainRole);
        mainRoleAIState             = mainRolePositioningAISystem.GetState(AIState.Type.eBullFight_Positioning) as AI_BullFight_Positioning;
        mainRoleAIState.onArrive   += OnArrive;

        //npc
        Team oppoTeam = mainRole.m_team.m_side == Team.Side.eAway ? m_homeTeam : m_awayTeam;

        npc = oppoTeam.GetMember(0);
        if (npc.model != null)
        {
            npc.model.EnableGrey();
        }

        npcNormalAISystem = new AISystem_Basic(this, npc, AIState.Type.eInit, m_config.NPCs[0].AIID);
        npcNormalAISystem.ReplaceState(new AI_Positioning_Shoot_on_Hold(npcNormalAISystem));
        npcPositioningAISystem = new AISystem_BullFight(this, npc);
        npcAIState             = npcPositioningAISystem.GetState(AIState.Type.eBullFight_Positioning) as AI_BullFight_Positioning;
        npcAIState.onArrive   += OnArrive;
        //npc.m_aiMgr = npcNormalAISystem;
        npc.m_aiMgr.m_enable = false;
        npc.m_team.m_role    = GameMatch.MatchRole.eDefense;

        AssumeDefenseTarget();
        _UpdateCamera(mainRole);
        //_CreateGUI();

        m_stateMachine.m_matchStateListeners.Add(this);
    }
コード例 #8
0
 public NewCharacterState(CombatSystem cSys, EntityMaintenanceSystem eSys, EntityManager eMan, StateMachine sMach, PlayerSystem pSys, AISystem aiSys)
 {
     combatSystem = cSys;
     entMaintenanceSystem = eSys;
     playerSystem = pSys;
     entityManager = eMan;
     stateSystem = sMach;
     aiSystem = aiSys;
 }
コード例 #9
0
ファイル: EposGame.cs プロジェクト: The5-1/Epos
        private void init()
        {
            DontDestroyOnLoad(this);
            aiSystem      = this.GetComponent <AISystem>();
            EposGame.game = this;

            //spawnPlayer();
            DEBUG_findAlternatePlayerGO("_player_test");
            initCameraSystem();
        }
コード例 #10
0
 public AI_GrabPoint_TracePoint(AISystem owner)
     : base(owner)
 {
     m_eType = Type.eGrabPoint_TracePoint;
     match   = m_match as GameMatch_GrabPoint;
     if (match != null)
     {
         timerTracePoint      = new GameUtils.Timer(match.TRACE_POINT_DELAY, TracePoint);
         timerTracePoint.stop = true;
     }
 }
コード例 #11
0
ファイル: MainSystem.cs プロジェクト: WH961230/UnityDemo
 private void CreateSystem()
 {
     environmentSystem = new EnvironmentSystem(); //环境
     roleSystem        = new RoleSystem();        //角色系统
     aISystem          = new AISystem();          //AI
     eventSystem       = new EventSystem();       //事件系统
     functionSystem    = new FunctionSystem();    //功能系统
     uISystem          = new UISystem();          //UI系统
     inputSystem       = new InputSystem();       //输入系统
     gameDataSystem    = new GameDataSystem();    //游戏数据系统
 }
コード例 #12
0
ファイル: AIState.cs プロジェクト: Avatarchik/LockStepDemo
    public AIState(AISystem owner)
    {
        m_system    = owner;
        m_player    = owner.m_player;
        m_match     = owner.m_curMatch;
        m_basket    = m_match.mCurScene.mBasket;
        m_timerTick = new GameUtils.Timer(m_system.AI.delay, OnTick);

        if (m_player == null)
        {
            Debug.LogError("AIState: player can not be null.");
        }
    }
コード例 #13
0
ファイル: Monster.cs プロジェクト: jinseop88/KHTeam
    public override void Initialize()
    {
        base.Initialize();

        onDamage = OnDamage;

        AISystem                 = thisObject.AddComponent <MonsterAI>();
        AISystem.m_Owner         = this;
        AISystem.m_Sight         = 5f;
        AISystem.m_LimitDistance = 3f;
        AISystem.m_AtkDelay      = 2f;

        AISystem.AIOn();
    }
コード例 #14
0
    private void Awake()
    {
        entities        = new List <Entity>();
        newEntities     = new Queue <Entity>();
        expiredEntities = new Queue <Entity>();

        entitySystem     = new EntitySystem(this);
        inputSystem      = new InputSystem(this);
        moveSystem       = new MoveSystem(this);
        controllerSystem = new ControllerSystem(this);
        gunSystem        = new GunSystem(this);
        bulletSystem     = new BulletSystem(this);
        buffSystem       = new BuffSystem(this);
        aiSystem         = new AISystem(this);
        levelSystem      = new LevelSystem(this);
    }
コード例 #15
0
        /// <summary>
        /// Make all entities with an AI perform an action if possible
        /// </summary>
        private void UpdateAI()
        {
            // Create a Dijkstra Map with the player as the sole source
            EntityManager.GetComponent(Player, EntityManager.ComponentIndex.Location, out Component component);
            Location location = (Location)component;

            int[,] PlayerDMap = Dijkstra.CreateSingleSourceMap(location.X, location.Y, dungeon);

            // Send all entities with an AI component to the AI system
            List <int> AIEntities = EntityManager.GetAllEntitiesWithComponent(EntityManager.ComponentIndex.AI);

            foreach (int Entity in AIEntities)
            {
                AISystem.PerformAction(Entity, EntityManager, dungeon, PlayerDMap);
            }
        }
コード例 #16
0
ファイル: CombatSystem.cs プロジェクト: InferiorOlive/AIQuest
        public CombatSystem(Lua Lua, ActionSystem actSys, ActionInventorySystem actInvSys, AISystem aiSys, DropSystem dSys, EffectSystem eSys, EntityMaintenanceSystem eMainSys, ExperienceSystem xSys, ItemInventorySystem iSys, NameSystem nSys, PlayerSystem pSys, StatsSystem sSys)
        {
            actionSystem = actSys;
            aInventorySystem = actInvSys;
            aiSystem = aiSys;
            dropSystem = dSys;
            effectSystem = eSys;
            entityMaintenanceSystem = eMainSys;
            experienceSystem = xSys;
            inventorySystem = iSys;
            nameSystem = nSys;
            playerSystem = pSys;
            statsSystem = sSys;

            lua = Lua;
            RegisterLuaFunctions();
        }
コード例 #17
0
    private IEnumerator testenum()
    {
        yield return(new WaitForSeconds(1));

        //print("Own position: " + GridSystem.System.CanMoveTo(walkOnSide, GridSystem.System.GetGridCoords(transform.position, true)));

        //print("time1: " + Time.time.ToString());
        //MonoBehaviour.print("start: "+GridSystem.System.PosToCoord(walkOnSide, transform.position));
        //MonoBehaviour.print("end :"+ GridSystem.System.PosToCoord(walkOnSide, targetPosition));
        Vector2[] path = AISystem.GetPath(GridSystem.System.PosToCoord(walkOnSide, transform.position), GridSystem.System.PosToCoord(walkOnSide, targetPosition), walkOnSide);
        //print("time2: " + Time.time.ToString());

        //transform.position = GridSystem.System.ToGridPosition(GridSystem.System.CoordToPos(walkOnSide, path[0]));

        //print("Path lenght: " + path.Length);
        StartCoroutine(walkTo(path));
    }
コード例 #18
0
        protected override void Initialize()
        {
            this.IsMouseVisible = true;
            //Get Systems
            RenderSystem           = SystemManager.Instance.GetSystem <RenderSystem>();
            LoadContentSystem      = SystemManager.Instance.GetSystem <LoadContentSystem>();
            InputHandlerSystem     = SystemManager.Instance.GetSystem <InputHandler>();
            TankMovementSystem     = SystemManager.Instance.GetSystem <TankMovementSystem>();
            TitlesafeRenderSystem  = SystemManager.Instance.GetSystem <TitlesafeRenderSystem>();
            CollisionSystem        = SystemManager.Instance.GetSystem <CollisionSystem>();
            CameraFollowSystem     = SystemManager.Instance.GetSystem <CameraSceneSystem>();
            LightSystems           = SystemManager.Instance.GetSystem <FlashlightSystem>();
            MoveSystem             = SystemManager.Instance.GetSystem <MoveSystem>();
            CollisionResolveSystem = SystemManager.Instance.GetSystem <CollisionResolveSystem>();
            WallCollisionSystem    = SystemManager.Instance.GetSystem <WallCollisionSystem>();
            AISystem              = SystemManager.Instance.GetSystem <AISystem>();
            EnemyCollisionSystem  = SystemManager.Instance.GetSystem <EnemyCollisionSystem>();
            AnimationSystem       = SystemManager.Instance.GetSystem <AnimationSystem>();
            SoundSystem           = SystemManager.Instance.GetSystem <SoundSystem>();
            WeaponSystem          = SystemManager.Instance.GetSystem <WeaponSystem>();
            BulletCollisionSystem = SystemManager.Instance.GetSystem <BulletCollisionSystem>();
            HealthSystem          = SystemManager.Instance.GetSystem <HealthSystem>();

            TempGameEnder = new TempGameEnder();

            //Init systems that require initialization
            TankMovementSystem.Start();
            WallCollisionSystem.Start();
            SoundSystem.Start();
            WeaponSystem.Start();
            EnemyCollisionSystem.Start();
            BulletCollisionSystem.Start();

            _gameDependencies.GameContent = this.Content;
            _gameDependencies.SpriteBatch = new SpriteBatch(GraphicsDevice);
            // just quickly done for FPS testing
            spriteBatch            = _gameDependencies.SpriteBatch;
            _gameDependencies.Game = this;

            CreateTestEntities();

            base.Initialize();
        }
コード例 #19
0
 public EntityManager(StateMachine sMach, DropSystem dSys, PlayerSystem pS, StatsSystem sS, ItemSystem iS, StatModifierSystem mS, EffectSystem efS, EquipmentSystem eqS, AISystem aiS, GearSystem gS, ExperienceSystem xS, ItemInventorySystem invS, NameSystem nS, ProfessionSystem profS, ActionSystem actS, ActionInventorySystem aInvS, CombatSystem cSys, EntityMaintenanceSystem eMS)
 {
     stateSystem = sMach;
     dropSystem = dSys;
     entMaintenanceSystem = eMS;
     aInventorySystem = aInvS;
     combatSystem = cSys;
     playerSystem = pS;
     statsSystem = sS;
     itemSystem = iS;
     modifierSystem = mS;
     effectSystem = efS;
     equipmentSystem = eqS;
     aiSystem = aiS;
     gearSystem = gS;
     experienceSystem = xS;
     inventorySystem = invS;
     nameSystem = nS;
     professionSystem = profS;
     actionSystem = actS;
 }
コード例 #20
0
 void Construct(
     PlanetViewController.Factory planetFactory,
     SettingsSO.GameSettings gameSettings,
     List <SettingsSO.RocketSettings> rocketSettings,
     RocketAmmoPanel ammoPanel,
     LocalSaveController localSaveController,
     RocketViewController.Factory rocketFactory,
     AISystem aiSystem,
     MainMenuView mainMenuView
     )
 {
     _planetFactory              = planetFactory;
     _rocketFactory              = rocketFactory;
     _gameSettings               = gameSettings;
     _rocketSettings             = rocketSettings;
     _ammoPanel                  = ammoPanel;
     _aiSystem                   = aiSystem;
     _localSaveController        = localSaveController;
     _mainMenuView               = mainMenuView;
     Application.targetFrameRate = 60;
     ConfigureInput();
     SubscribeToUpdateAiSystem();
 }
コード例 #21
0
    void Awake()
    {
        gameGUI       = gameObject.AddComponent <GameGUI>() as GameGUI;
        actionManager = gameObject.AddComponent <ActionManager>() as ActionManager;
        preists       = new Character[3];
        devils        = new Character[3];
        SSDirector.getInstance().currentScenceController = this;
        LoadResources();

        judger                 = gameObject.AddComponent <Judger>() as Judger;
        judger.preists         = preists;
        judger.devils          = devils;
        judger.boat            = boat;
        judger.sceneController = this;

        ai = new AISystem(3);
        gameGUI.onPressTipButton += delegate {
            int cnt1 = 0, cnt2 = 0;
            for (int i = 0; i < preists.Length; i++)
            {
                if (!preists[i].onLeft)
                {
                    cnt1++;
                }
            }
            for (int i = 0; i < devils.Length; i++)
            {
                if (!devils[i].onLeft)
                {
                    cnt2++;
                }
            }
            Tuple <int, int> tip = ai.GetNextStep(cnt1, cnt2, boat.onLeft);
            gameGUI.boatOnLeft = boat.onLeft;
            gameGUI.tip        = tip;
        };
    }
コード例 #22
0
 public AI_GrabZone_TraceBall(AISystem owner)
     : base(owner)
 {
     m_eType = Type.eGrabZone_TraceBall;
 }
コード例 #23
0
 public AI_PractiseGuide_TraceBall(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.ePractiseGuide_TraceBall;
 }
コード例 #24
0
 public AI_PractiseGuide_Base(AISystem owner)
     : base(owner)
 {
     behaviour = (m_match as GameMatch_Practise).practise_behaviour as PractiseBehaviourGuide;
     system    = owner as AISystem_PractiseGuide;
 }
コード例 #25
0
 public AI_PickAndRoll(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.ePickAndRoll;
     timer   = new GameUtils.Timer(new IM.Number(0, 300), OnTimer);
 }
コード例 #26
0
 public AI_PractiseLayupDunk_Block(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.ePractiseLayupDunk_Block;
 }
コード例 #27
0
ファイル: AIQuest.cs プロジェクト: InferiorOlive/AIQuest
        private void InitializeSystems()
        {
            Console.WriteLine("Initializing Game Systems");

            professionSystem = new ProfessionSystem();
            effectSystem=new EffectSystem(lua);
            equipmentSystem = new EquipmentSystem();
            experienceSystem = new ExperienceSystem();         
            itemSystem = new ItemSystem();
            inventorySystem = new ItemInventorySystem();
            modifierSystem = new StatModifierSystem();
            nameSystem = new NameSystem(lua);
            playerSystem = new PlayerSystem(nameSystem, stateSystem);
            gearSystem = new GearSystem();
            statsSystem = new StatsSystem();
            aInventorySystem = new ActionInventorySystem(lua, statsSystem);
            actionSystem = new ActionSystem(lua);
            aiSystem = new AISystem();
            dropSystem = new DropSystem(dropMap);
        }
コード例 #28
0
 public AI_BullFight_Positioning(AISystem owner)
     : base(owner)
 {
     m_eType         = AIState.Type.eBullFight_Positioning;
     m_bForceNotRush = true;
 }
コード例 #29
0
 public AI_ReboundStorm_Rebound(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.eReboundStorm_Rebound;
 }
コード例 #30
0
 public AI_Positioning(AISystem owner)
     : base(owner)
 {
     m_eType  = AIState.Type.ePositioning;
     m_intent = Intent.eNone;
 }
コード例 #31
0
ファイル: PlayerState.cs プロジェクト: InferiorOlive/AIQuest
 public PlayerState(AISystem aiSys, CombatSystem cSys, NameSystem nSys)
 {
     combatSystem = cSys;
     aiSystem = aiSys;
     nameSystem = nSys;
 }
コード例 #32
0
ファイル: Stun.cs プロジェクト: InferiorOlive/AIQuest
 public Stun(AISystem ai, NameSystem nS, double time)
 {
     aiSystem = ai;
     nameSystem = nS;
 }
コード例 #33
0
 public AI_GrabZone_Shoot(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.eGrabZone_Shoot;
 }
コード例 #34
0
 public AI_Debug_Positioning2Basket(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.eDebug_Positioning2Basket;
 }
コード例 #35
0
 public BeginState(AISystem aISystem) : base(aISystem)
 {
 }
コード例 #36
0
 public SimpleWarriorAggro(AISystem aiSys, CombatSystem cSys)
 {
     aiSystem = aiSys;
     combatSystem = cSys;
 }
コード例 #37
0
 public AI_PractiseGuide_Face2Mate(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.ePractiseGuide_Face2Mate;
 }
コード例 #38
0
 public SimpleWarriorDefensive(AISystem aiSys, CombatSystem cSys)
 {
     aiSystem = aiSys;
     combatSystem = cSys;
 }