示例#1
0
        public NetworkRunner(CvarcClient client)
        {
            this.client = client;

            factory = new SoloNetworkControllerFactory(client);

            var configProposal = client.Read<ConfigurationProposal>();
            var loadingData = configProposal.LoadingData;
            var competitions = Dispatcher.Loader.GetCompetitions(loadingData);
            var settings = competitions.Logic.CreateDefaultSettings();
            if (configProposal.SettingsProposal != null)
                configProposal.SettingsProposal.Push(settings, true);
            configuration = new Configuration
            {
                LoadingData = loadingData,
                Settings = settings
            };

            //configuration.Settings.EnableLog = true;
            //configuration.Settings.LogFile = UnityConstants.LogFolderRoot + "cvarclog1";

            var worldSettingsType = competitions.Logic.WorldStateType;
            worldState = (IWorldState)client.Read(worldSettingsType);

            Name = loadingData.AssemblyName + loadingData.Level;
            CanInterrupt = true;
            CanStart = true;
        }
示例#2
0
    public override List <Action> GenerateSatisfyingActions(IWorldState worldState, int maxActions)
    {
        List <Action> actions = new List <Action>();

        IEntity entity = worldState.GetEntity(entityId);


        float powerDiff = minPower - entity.GetPower();

        if (powerDiff <= 0)
        {
            return(actions);
        }

        ItemFilter filter = new ItemFilter();

        filter.requireEquippable = true;
        for (int i = 0; i < Item.numItemSlots; i++)
        {
            if (entity.TryGetEquippedItem((ItemSlot)i, out Item item))
            {
                filter.minPower[i] = powerDiff + item.power;
            }
            else
            {
                filter.minPower[i] = powerDiff;
            }
        }
        EquipAction equipAction = new EquipAction(worldState, entityId, filter);

        actions.Add(equipAction);
        return(actions);
    }
示例#3
0
    protected override void GenerateConditions(IWorldState worldState)
    {
        conditions = new List <Condition>();
        PossessCondition possessCond = new PossessCondition(entityId, itemFilter);

        conditions.Add(possessCond);
    }
示例#4
0
        private IEnumerator RefreshProfilingData()
        {
            while (true)
            {
                var currentPos = Utils.WorldToGridPosition(DCLCharacterController.i.characterPosition.worldPosition);

                IWorldState worldState = Environment.i.world.state;

                ParcelScene activeScene = worldState.loadedScenes.Values.FirstOrDefault(
                    x => x.sceneData.parcels != null &&
                    x.sceneData.parcels.Any(y => y == currentPos)) as ParcelScene;

                if (activeScene != null && activeScene.metricsController != null)
                {
                    var metrics = activeScene.metricsController.GetModel();
                    var limits  = activeScene.metricsController.GetLimits();
                    statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.CURRENT_SCENE, $"{activeScene.sceneData.id}");
                    statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.POLYGONS_VS_LIMIT, $"{metrics.triangles} of {limits.triangles}");
                    statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.TEXTURES_VS_LIMIT, $"{metrics.textures} of {limits.textures}");
                    statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.MATERIALS_VS_LIMIT, $"{metrics.materials} of {limits.materials}");
                    statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.ENTITIES_VS_LIMIT, $"{metrics.entities} of {limits.entities}");
                    statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.MESHES_VS_LIMIT, $"{metrics.meshes} of {limits.meshes}");
                    statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.BODIES_VS_LIMIT, $"{metrics.bodies} of {limits.bodies}");
                    statsPanel.SetCellText((int)Columns.VALUE, (int)Rows.COMPONENT_OBJECTS_COUNT, activeScene.disposableComponents.Count + activeScene.entities.Select(x => x.Value.components.Count).Sum().ToString());
                }

                yield return(WaitForSecondsCache.Get(0.2f));
            }
        }
示例#5
0
        public void LoadParcelScenesExecute(string scenePayload)
        {
            LoadParcelScenesMessage.UnityParcelScene scene;

            ProfilingEvents.OnMessageDecodeStart?.Invoke(MessagingTypes.SCENE_LOAD);
            scene = Utils.SafeFromJson <LoadParcelScenesMessage.UnityParcelScene>(scenePayload);
            ProfilingEvents.OnMessageDecodeEnds?.Invoke(MessagingTypes.SCENE_LOAD);

            if (scene == null || scene.id == null)
            {
                return;
            }

            var sceneToLoad = scene;


            DebugConfig debugConfig = DataStore.i.debugConfig;

#if UNITY_EDITOR
            if (debugConfig.soloScene && sceneToLoad.basePosition.ToString() != debugConfig.soloSceneCoords.ToString())
            {
                SendSceneReady(sceneToLoad.id);
                return;
            }
#endif

            ProfilingEvents.OnMessageProcessStart?.Invoke(MessagingTypes.SCENE_LOAD);

            IWorldState worldState = Environment.i.world.state;

            if (!worldState.loadedScenes.ContainsKey(sceneToLoad.id))
            {
                var newGameObject = new GameObject("New Scene");

                var newScene = newGameObject.AddComponent <ParcelScene>();
                newScene.SetData(sceneToLoad);

                if (debugConfig.isDebugMode)
                {
                    newScene.InitializeDebugPlane();
                }

                newScene.ownerController = this;
                worldState.loadedScenes.Add(sceneToLoad.id, newScene);
                worldState.scenesSortedByDistance.Add(newScene);

                sceneSortDirty = true;

                OnNewSceneAdded?.Invoke(newScene);

                Environment.i.messaging.manager.AddControllerIfNotExists(this, newScene.sceneData.id);

                if (VERBOSE)
                {
                    Debug.Log($"{Time.frameCount} : Load parcel scene {newScene.sceneData.basePosition}");
                }
            }

            ProfilingEvents.OnMessageProcessEnds?.Invoke(MessagingTypes.SCENE_LOAD);
        }
示例#6
0
        public void UnloadParcelSceneExecute(string sceneId)
        {
            ProfilingEvents.OnMessageProcessStart?.Invoke(MessagingTypes.SCENE_DESTROY);

            IWorldState worldState = Environment.i.world.state;

            if (!worldState.loadedScenes.ContainsKey(sceneId) || worldState.loadedScenes[sceneId].isPersistent)
            {
                return;
            }

            var scene = worldState.loadedScenes[sceneId];

            worldState.loadedScenes.Remove(sceneId);

            // Remove the scene id from the msg. priorities list
            worldState.scenesSortedByDistance.Remove(scene);

            // Remove messaging controller for unloaded scene
            Environment.i.messaging.manager.RemoveController(scene.sceneData.id);

            if (scene)
            {
                scene.Cleanup(!CommonScriptableObjects.rendererState.Get());

                if (VERBOSE)
                {
                    Debug.Log($"{Time.frameCount} : Destroying scene {scene.sceneData.basePosition}");
                }
            }

            ProfilingEvents.OnMessageProcessEnds?.Invoke(MessagingTypes.SCENE_DESTROY);
        }
示例#7
0
    public override float EstimateCost(IWorldState worldState)
    {
        Merchant merchant  = worldState.GetMerchant(merchantId);
        float    salePrice = merchant.saleEntries[saleEntryIndex].price;

        return(salePrice);
    }
示例#8
0
        public void UnloadScene(string sceneKey)
        {
            var queuedMessage = new QueuedSceneMessage()
            {
                type = QueuedSceneMessage.Type.UNLOAD_PARCEL, message = sceneKey
            };

            ProfilingEvents.OnMessageWillQueue?.Invoke(MessagingTypes.SCENE_DESTROY);

            Environment.i.messaging.manager.ForceEnqueueToGlobal(MessagingBusType.INIT, queuedMessage);

            Environment.i.messaging.manager.RemoveController(sceneKey);

            IWorldState worldState = Environment.i.world.state;

            if (worldState.loadedScenes.ContainsKey(sceneKey))
            {
                ParcelScene sceneToUnload = worldState.GetScene(sceneKey) as ParcelScene;
                sceneToUnload.isPersistent = false;

                if (sceneToUnload is GlobalScene globalScene && globalScene.isPortableExperience)
                {
                    OnNewPortableExperienceSceneRemoved?.Invoke(sceneKey);
                }
            }
        }
示例#9
0
    public override float EstimateCost(IWorldState worldState)
    {
        IEntity entity = worldState.GetEntity(entityID);
        float   dist   = PathFinder.EstimateDistance(entity.Position, targetPos);

        return(dist);
    }
示例#10
0
 public BuyAction(IWorldState worldState, int buyerId, int saleEntryIndex, int merchantId)
 {
     this.buyerId        = buyerId;
     this.saleEntryIndex = saleEntryIndex;
     this.merchantId     = merchantId;
     GenerateConditions(worldState);
 }
示例#11
0
 public TournamentPlayer(IMessagingClient client, ConfigurationProposal configProposal,
     IWorldState preferredWorldState)
 {
     this.client = client;
     this.configProposal = configProposal;
     this.preferredWorldState = preferredWorldState;
 }
示例#12
0
 public PlannerState(IWorldState workingWS, List <TaskBase> finalPlanList, List <TaskBase> taskListToProcess, int nextMethodNumber)
 {
     this.WorkingWS         = workingWS;
     this.FinalPlanList     = finalPlanList;
     this.TaskListToProcess = taskListToProcess;
     this.NextMethodNumber  = nextMethodNumber;
 }
示例#13
0
        public TournamentRunner(IWorldState worldState, Configuration configuration)
        {
            this.worldState = worldState;
            this.configuration = configuration;
            players = new List<TournamentPlayer>();

            //log section
            logFileName = Guid.NewGuid() + ".log";
            configuration.Settings.EnableLog = true;
            configuration.Settings.LogFile = UnityConstants.LogFolderRoot + logFileName;
            //log section end

            var competitions = Dispatcher.Loader.GetCompetitions(configuration.LoadingData);
            controllerIds = competitions.Logic.Actors.Keys.ToArray();

            foreach (var controller in controllerIds
                .Select(x => new ControllerSettings
                {
                    ControllerId = x,
                    Type = ControllerType.Client,
                    Name = configuration.Settings.Name
                }))
                configuration.Settings.Controllers.Add(controller);

            requiredCountOfPlayers = controllerIds.Length;

            Debugger.Log(DebuggerMessageType.Unity, "t.runner created. count: " + requiredCountOfPlayers);
            if (requiredCountOfPlayers == 0)
                throw new Exception("requiered count of players cant be 0");

            Name = configuration.LoadingData.AssemblyName + configuration.LoadingData.Level;//"Tournament";
            CanInterrupt = false;
            CanStart = false;
        }
示例#14
0
    public override List <Action> GenerateSatisfyingActions(IWorldState worldState, int maxActions)
    {
        List <Action> actions    = new List <Action>();
        MoveAction    moveAction = new MoveAction(worldState, entityID, position);

        actions.Add(moveAction);
        return(actions);
    }
 public PlayerEntityManagerFactory(IWorldState worldState,
                                   IStateManager stateManager,
                                   BattleManagerFactory battleManagerFactory)
 {
     _worldState           = worldState;
     _stateManager         = stateManager;
     _battleManagerFactory = battleManagerFactory;
 }
示例#16
0
		/// <summary>
		/// Creates a world. 
		/// </summary>
		/// <param name="configuration">Contains the cometition/level name and the settings</param>
		/// <param name="controllerFactory">Is used to create controllers, i.e. entities that control the robots</param>
		/// <param name="state">The initial state of the world</param>
		/// <returns></returns>
		public IWorld CreateWorld(Configuration configuration, ControllerFactory controllerFactory, IWorldState state)
		{
			var competitions = GetCompetitions(configuration.LoadingData);
			var world = competitions.Logic.CreateWorld();
			world.Initialize(competitions, configuration, controllerFactory, state);
			world.Exit += ()=>
				controllerFactory.Exit();
			return world;
		}
示例#17
0
    public static ConditionNode GeneratePlan(Condition condition, IWorldState worldState, int depth, int width)
    {
        LinkedList <Condition> stack = new LinkedList <Condition>();

        stack.AddFirst(condition);
        ConditionNode topNode = FillTree(stack, worldState, depth, width);

        return(topNode);
    }
示例#18
0
 public static void AddForceGame(IWorldState worldState, Configuration config)
 {
     if (forceRunner != null)
         while (!forceRunner.Disposed)
             Thread.Sleep(100);
     haveForceGame = true;
     lock (pool)
         pool.Clear();
     forceRunner = new TournamentRunner(worldState, config);
     Dispatcher.AddRunner(forceRunner);
 }
示例#19
0
 void Awake()
 {
     worldStates = new Dictionary <StateName, IWorldState>();
     // fill dictionary
     worldStates.Add(StateName.Idle, new Idle(this));
     worldStates.Add(StateName.RollCall, new RollCall(this));
     worldStates.Add(StateName.Selection, new Selection(this));
     worldStates.Add(StateName.Temp, new Temp(this));
     worldStates.Add(StateName.Final, new Final(this));
     current = worldStates[StateName.Idle];
 }
示例#20
0
 public PlayerEntityManager(IWorldState worldState,
                            IStateManager stateManager,
                            IPlayerEntityManagerStore playerEntityManagerStore)
 {
     _worldState               = worldState;
     _stateManager             = stateManager;
     _playerEntityManagerStore = playerEntityManagerStore;
     LastAccessed              = DateTime.Now;
     _movementQueue            = new Queue <Coordinate>();
     AlliedEntities            = new List <WorldEntity>();
 }
示例#21
0
 public WorldEntityManager(IWorldEntityFactory worldEntityFactory,
                           PlayerEntityManagerFactory playerEntityManagerFactory,
                           IWorldState worldState)
 {
     _worldEntityFactory         = worldEntityFactory;
     _playerEntityManagerFactory = playerEntityManagerFactory;
     _worldState           = worldState;
     _worldEntities        = new ConcurrentDictionary <Guid, WorldEntity>();
     _playerEntityManagers = new ConcurrentDictionary <Guid, PlayerEntityManager>();
     _combatEntities       = new List <CombatEntity>();
 }
示例#22
0
 public bool CheckPreCondition(IWorldState state)
 {
     foreach (var preCondition in PreConditions)
     {
         if (!preCondition.CheckPreCondition(state))
         {
             return(false);
         }
     }
     return(true);
 }
示例#23
0
    protected override void GenerateConditions(IWorldState worldState)
    {
        Merchant merchant = worldState.GetMerchant(merchantId);

        conditions = new List <Condition>();
        MoneyCondition moneyCond = new MoneyCondition(buyerId, merchant.saleEntries[saleEntryIndex].price);

        conditions.Add(moneyCond);
        LocationCondition locationCond = new LocationCondition(buyerId, merchant.position);

        conditions.Add(locationCond);
    }
示例#24
0
    /// <summary>
    /// 登録されているOperatorの実行、監視を行う
    /// </summary>
    private CurrentOperatorStatus UpdateCurrentOperator(IWorldState worldState)
    {
        if (operatorList.Count == 0)
        {
            return(CurrentOperatorStatus.Success);
        }

        // Operatorの実行処理(まだ作れてない)
        // return CurrentOperatorStatus.Continue;
        operatorList[0].Execute(worldState);
        return(CurrentOperatorStatus.Success);
    }
示例#25
0
 private MevBlockProductionTransactionsExecutor(
     ITransactionProcessor transactionProcessor,
     IStateProvider stateProvider,
     IStorageProvider storageProvider,
     ISpecProvider specProvider,
     ILogManager logManager)
     : base(transactionProcessor, stateProvider, storageProvider, specProvider, logManager)
 {
     _stateProvider   = stateProvider;
     _storageProvider = storageProvider;
     _worldState      = new WorldState(stateProvider, storageProvider);
 }
示例#26
0
        public void SortScenesByDistance()
        {
            if (DCLCharacterController.i == null)
            {
                return;
            }

            IWorldState worldState = Environment.i.world.state;

            worldState.currentSceneId = null;
            worldState.scenesSortedByDistance.Sort(SortScenesByDistanceMethod);

            using (var iterator = Environment.i.world.state.scenesSortedByDistance.GetEnumerator())
            {
                IParcelScene scene;
                bool         characterIsInsideScene;

                while (iterator.MoveNext())
                {
                    scene = iterator.Current;

                    if (scene == null)
                    {
                        continue;
                    }

                    characterIsInsideScene = WorldStateUtils.IsCharacterInsideScene(scene);

                    if (!worldState.globalSceneIds.Contains(scene.sceneData.id) && characterIsInsideScene)
                    {
                        worldState.currentSceneId = scene.sceneData.id;
                        break;
                    }
                }
            }

            if (!DataStore.i.debugConfig.isDebugMode && string.IsNullOrEmpty(worldState.currentSceneId))
            {
                // When we don't know the current scene yet, we must lock the rendering from enabling until it is set
                CommonScriptableObjects.rendererState.AddLock(this);
            }
            else
            {
                // 1. Set current scene id
                CommonScriptableObjects.sceneID.Set(worldState.currentSceneId);

                // 2. Attempt to remove SceneController's lock on rendering
                CommonScriptableObjects.rendererState.RemoveLock(this);
            }

            OnSortScenes?.Invoke();
        }
示例#27
0
        public LogRunner(string fileName)
        {
            var log = Log.Load(UnityConstants.LogFolderRoot + fileName);
            factory = new LogPlayerControllerFactory(log);
            configuration = log.Configuration;
            configuration.Settings.EnableLog = false; // чтоб файл логов не переписывать

            worldState = log.WorldState;

            Name = "log run: " + fileName;
            CanInterrupt = true;
            CanStart = true;
        }
示例#28
0
    public override void ExecuteImmediate(IWorldState worldState)
    {
        IEntity entity = worldState.GetEntity(entityId);

        foreach (Item item in entity.GetInventory())
        {
            if (itemFilter.Satisfied(item) && item.equippable)
            {
                entity.EquipItem(item, item.slot);
                return;
            }
        }
    }
 public BattleListenerContainer(IHubContext <BattleHub> battleHubContext,
                                IWorldState worldState)
 {
     _battleHubContext = battleHubContext;
     _worldState       = worldState;
     //foreach (var manager in _worldState.MapBattleManagers.Values)
     //{
     //    manager.OnCreatedBattle += (sender, args) =>
     //    {
     //        CreateListener(args.BattleManager);
     //    };
     //}
 }
示例#30
0
    public override void ExecuteImmediate(IWorldState worldState)
    {
        IEntity  buyer     = worldState.GetEntity(buyerId);
        Merchant merchant  = worldState.GetMerchant(merchantId);
        float    salePrice = merchant.saleEntries[saleEntryIndex].price;

        if (buyer.Money > salePrice)
        {
            Item item = merchant.saleEntries[saleEntryIndex].itemTemplate.Generate();
            buyer.AddInventoryItem(item);
            buyer.Money -= salePrice;
        }
    }
示例#31
0
    override public bool Satisfied(IWorldState worldState)
    {
        IEntity owner = worldState.GetEntity(ownerId);

        foreach (Item i in owner.GetInventory())
        {
            if (itemFilter.Satisfied(i))
            {
                return(true);
            }
        }
        return(false);
    }
 public WorldRuntimeContext(IWorldState state,
                            ISceneController sceneController,
                            IPointerEventsController pointerEventsController,
                            ISceneBoundsChecker sceneBoundsChecker,
                            IWorldBlockersController blockersController,
                            IRuntimeComponentFactory componentFactory)
 {
     this.state                   = state;
     this.sceneController         = sceneController;
     this.pointerEventsController = pointerEventsController;
     this.sceneBoundsChecker      = sceneBoundsChecker;
     this.blockersController      = blockersController;
     this.componentFactory        = componentFactory;
 }
示例#33
0
        public bool ProcessMessage(QueuedSceneMessage_Scene msgObject, out CustomYieldInstruction yieldInstruction)
        {
            string sceneId = msgObject.sceneId;
            string method  = msgObject.method;

            yieldInstruction = null;

            IParcelScene scene;
            bool         res         = false;
            IWorldState  worldState  = Environment.i.world.state;
            DebugConfig  debugConfig = DataStore.i.debugConfig;

            if (worldState.loadedScenes.TryGetValue(sceneId, out scene))
            {
#if UNITY_EDITOR
                if (debugConfig.soloScene && scene is GlobalScene && debugConfig.ignoreGlobalScenes)
                {
                    return(false);
                }
#endif
                if (!scene.GetSceneTransform().gameObject.activeInHierarchy)
                {
                    return(true);
                }

#if UNITY_EDITOR
                OnMessageProcessInfoStart?.Invoke(sceneId, method);
#endif
                ProfilingEvents.OnMessageProcessStart?.Invoke(method);

                ProcessMessage(scene as ParcelScene, method, msgObject.payload, out yieldInstruction);

                ProfilingEvents.OnMessageProcessEnds?.Invoke(method);

#if UNITY_EDITOR
                OnMessageProcessInfoEnds?.Invoke(sceneId, method);
#endif

                res = true;
            }

            else
            {
                res = false;
            }

            sceneMessagesPool.Enqueue(msgObject);

            return(res);
        }
 public TransactionProcessor(
     ISpecProvider?specProvider,
     IWorldState?worldState,
     IVirtualMachine?virtualMachine,
     ILogManager?logManager)
 {
     _logger          = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager));
     _specProvider    = specProvider ?? throw new ArgumentNullException(nameof(specProvider));
     _worldState      = worldState ?? throw new ArgumentNullException(nameof(worldState));
     _stateProvider   = worldState.StateProvider;
     _storageProvider = worldState.StorageProvider;
     _virtualMachine  = virtualMachine ?? throw new ArgumentNullException(nameof(virtualMachine));
     _ecdsa           = new EthereumEcdsa(specProvider.ChainId, logManager);
 }
示例#35
0
        public void CreateUIScene(string json)
        {
#if UNITY_EDITOR
            DebugConfig debugConfig = DataStore.i.debugConfig;

            if (debugConfig.soloScene && debugConfig.ignoreGlobalScenes)
            {
                return;
            }
#endif
            CreateUISceneMessage uiScene = Utils.SafeFromJson <CreateUISceneMessage>(json);

            string uiSceneId = uiScene.id;

            IWorldState worldState = Environment.i.world.state;

            if (worldState.loadedScenes.ContainsKey(uiSceneId))
            {
                return;
            }

            var newGameObject = new GameObject("UI Scene - " + uiSceneId);

            var newScene = newGameObject.AddComponent <GlobalScene>();
            newScene.ownerController    = this;
            newScene.unloadWithDistance = false;
            newScene.isPersistent       = true;

            LoadParcelScenesMessage.UnityParcelScene data = new LoadParcelScenesMessage.UnityParcelScene
            {
                id           = uiSceneId,
                basePosition = new Vector2Int(0, 0),
                baseUrl      = uiScene.baseUrl
            };

            newScene.SetData(data);

            worldState.loadedScenes.Add(uiSceneId, newScene);
            OnNewSceneAdded?.Invoke(newScene);

            worldState.globalSceneId = uiSceneId;

            Environment.i.messaging.manager.AddControllerIfNotExists(this, worldState.globalSceneId, isGlobal: true);

            if (VERBOSE)
            {
                Debug.Log($"Creating UI scene {uiSceneId}");
            }
        }
示例#36
0
        private static ParcelScene GetLoadedScene()
        {
            ParcelScene loadedScene = null;
            IWorldState worldState  = Environment.i.world.state;

            if (worldState != null && worldState.loadedScenes.Count > 0)
            {
                using (var iterator = worldState.loadedScenes.GetEnumerator())
                {
                    iterator.MoveNext();
                    loadedScene = iterator.Current.Value;
                }
            }

            return(loadedScene);
        }
示例#37
0
 public static void AddPlayerToPool(CvarcClient client, Configuration configuration, IWorldState worldState, ConfigurationProposal configProposal)
 {
     if (haveForceGame)
     {
         if (UnityConstants.OnlyGamesThroughServicePort)
             HttpWorker.SendInfoToLocal(configProposal.SettingsProposal.CvarcTag);
         if (forceRunner.AddPlayerAndCheck(new TournamentPlayer(client, configProposal, worldState)))
             haveForceGame = false;
         return;
     }
     lock (pool)
     {
         if (!pool.ContainsKey(configuration.LoadingData))
         {
             pool.Add(configuration.LoadingData, new TournamentRunner(worldState, configuration));
             Dispatcher.AddRunner(pool[configuration.LoadingData]);
         }
         if (pool[configuration.LoadingData].AddPlayerAndCheck(new TournamentPlayer(client, configProposal, worldState)))
             pool.Remove(configuration.LoadingData);
     }
 }
示例#38
0
        readonly IWorldState worldState; // откуда?

        #endregion Fields

        #region Constructors

        public TutorialRunner(LoadingData loadingData, Configuration configuration = null, IWorldState worldState = null)
        {
            factory = new TutorialControllerFactory();

            var competitions = Dispatcher.Loader.GetCompetitions(loadingData);
            if (configuration == null)
            {
                this.configuration = new Configuration
                {
                    LoadingData = loadingData,
                    Settings = competitions.Logic.CreateDefaultSettings()
                };
            }
            else
                this.configuration = configuration;

            this.worldState = worldState ?? competitions.Logic.CreateWorldState(competitions.Logic.PredefinedWorldStates[0]);
            //this.worldState = worldState ?? competitions.Logic.CreateWorldState("0"); // lol

            Name = "Tutorial";
            CanStart = true;
            CanInterrupt = true;
        }
示例#39
0
        public TournamentRunner(LoadingData loadingData, IWorldState worldState)
        {
            this.worldState = worldState;
            players = new List<TournamentPlayer>();

            var competitions = Dispatcher.Loader.GetCompetitions(loadingData);
            var settings = competitions.Logic.CreateDefaultSettings();
            configuration = new Configuration
            {
                LoadingData = loadingData,
                Settings = settings
            };

            //я игнорирую конфиги. надо хотя бы имя сохранять в метод "add player"

            controllerIds = competitions.Logic.Actors.Keys.ToArray();

            foreach (var controller in controllerIds
                .Select(x => new ControllerSettings
                {
                    ControllerId = x,
                    Type = ControllerType.Client,
                    Name = settings.Name
                }))
                settings.Controllers.Add(controller);

            requiredCountOfPlayers = controllerIds.Length;

            Debugger.Log(DebuggerMessageType.Unity, "t.runner created. count: " + requiredCountOfPlayers);
            if (requiredCountOfPlayers == 0)
                throw new Exception("requiered count of players cant be 0");

            Name = loadingData.AssemblyName + loadingData.Level;//"Tournament";
            CanInterrupt = false;
            CanStart = false;
        }
示例#40
0
    void Start()
    {
        //Screen.SetResolution(640, 480, true);
        Screen.SetResolution(320, 200, true);

        mainMenuState = new MenuWorldState();
        mainMenuState.Create();
        mainMenuState.Run();
        toLoad = "";
    }
示例#41
0
 public WorldState(IWorldState state)
 {
     State = state;
 }
示例#42
0
    public void RequestState(string stateIn)
    {
        //return;
        if(stateIn == "Menu")
        {
            if(gameState != null)
            {
                gameState.Pause();
                gameState.Hide();
                gameState.Teardown();
                gameState = null;
            }
            mainMenuState.Show(false);
            mainMenuState.Run();

        }
        if(stateIn == "GameMenu")
        {
            if(gameState != null)
            {
                gameState.Pause();
            }

            mainMenuState.Show(true);
            mainMenuState.Run();

        }
        if(stateIn == "Continue")
        {
            if(gameState != null)
            {
                gameState.Run();
                gameState.Show(false);
                mainMenuState.Hide();
                mainMenuState.Pause();
            }

        }

        if(stateIn == "NewGame")
        {
            if(gameState != null)
            {
                gameState.Hide();
                gameState.Teardown();
                gameState = null;
            }
            toLoad = "load_Game";
        }

        if(stateIn == "SaveQuit")
        {
            if(gameState != null)
            {
                gameState.Hide();
                gameState.Teardown();
                gameState = null;
            }
            mainMenuState.Teardown();
            mainMenuState.Hide();
        //			mainMenuState = null;
            Application.Quit();
        }

        //TOLOAD
        if(stateIn == "load_Game")
        {
            toLoad = "";
            mainMenuState.Hide();
            gameState = new GameWorldState(WorldCreate.WorldType.debug_game);
            gameState.Create();
            gameState.Run();
        }
    }