Exemplo n.º 1
0
    void Awake()
    {
        aiSystem = FindObjectOfType <AISystem>();
        aiSystem.AITurnFinished += OnAiTurnFinished;

        player = FindObjectOfType <PlayerController>();
    }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
 }
Exemplo n.º 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]));
     }
 }
    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);
    }
Exemplo n.º 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;
 }
Exemplo n.º 9
0
        private void init()
        {
            DontDestroyOnLoad(this);
            aiSystem      = this.GetComponent <AISystem>();
            EposGame.game = this;

            //spawnPlayer();
            DEBUG_findAlternatePlayerGO("_player_test");
            initCameraSystem();
        }
Exemplo n.º 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;
     }
 }
Exemplo n.º 11
0
 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();    //游戏数据系统
 }
Exemplo n.º 12
0
    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.");
        }
    }
Exemplo n.º 13
0
    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();
    }
Exemplo n.º 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);
    }
Exemplo n.º 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);
            }
        }
Exemplo n.º 16
0
        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();
        }
Exemplo n.º 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));
    }
        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();
        }
Exemplo n.º 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;
 }
Exemplo n.º 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();
 }
Exemplo n.º 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;
        };
    }
Exemplo n.º 22
0
 public AI_GrabZone_TraceBall(AISystem owner)
     : base(owner)
 {
     m_eType = Type.eGrabZone_TraceBall;
 }
Exemplo n.º 23
0
 public AI_PractiseGuide_TraceBall(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.ePractiseGuide_TraceBall;
 }
Exemplo n.º 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;
 }
Exemplo n.º 25
0
 public AI_PickAndRoll(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.ePickAndRoll;
     timer   = new GameUtils.Timer(new IM.Number(0, 300), OnTimer);
 }
Exemplo n.º 26
0
 public AI_PractiseLayupDunk_Block(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.ePractiseLayupDunk_Block;
 }
Exemplo n.º 27
0
        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);
        }
 public AI_BullFight_Positioning(AISystem owner)
     : base(owner)
 {
     m_eType         = AIState.Type.eBullFight_Positioning;
     m_bForceNotRush = true;
 }
 public AI_ReboundStorm_Rebound(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.eReboundStorm_Rebound;
 }
Exemplo n.º 30
0
 public AI_Positioning(AISystem owner)
     : base(owner)
 {
     m_eType  = AIState.Type.ePositioning;
     m_intent = Intent.eNone;
 }
Exemplo n.º 31
0
 public PlayerState(AISystem aiSys, CombatSystem cSys, NameSystem nSys)
 {
     combatSystem = cSys;
     aiSystem = aiSys;
     nameSystem = nSys;
 }
Exemplo n.º 32
0
 public Stun(AISystem ai, NameSystem nS, double time)
 {
     aiSystem = ai;
     nameSystem = nS;
 }
Exemplo n.º 33
0
 public AI_GrabZone_Shoot(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.eGrabZone_Shoot;
 }
 public AI_Debug_Positioning2Basket(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.eDebug_Positioning2Basket;
 }
Exemplo n.º 35
0
 public BeginState(AISystem aISystem) : base(aISystem)
 {
 }
Exemplo n.º 36
0
 public SimpleWarriorAggro(AISystem aiSys, CombatSystem cSys)
 {
     aiSystem = aiSys;
     combatSystem = cSys;
 }
Exemplo n.º 37
0
 public AI_PractiseGuide_Face2Mate(AISystem owner)
     : base(owner)
 {
     m_eType = AIState.Type.ePractiseGuide_Face2Mate;
 }
Exemplo n.º 38
0
 public SimpleWarriorDefensive(AISystem aiSys, CombatSystem cSys)
 {
     aiSystem = aiSys;
     combatSystem = cSys;
 }