Beispiel #1
0
        private void CreateModels(PlayerView[] playerViews)
        {
            _playerModels = new PlayerModel[playerViews.Length];
            for (var i = 0; i < playerViews.Length; i++)
            {
                var view = playerViews[i];

                var slideBounds = view.SlideBounds;
                var slideAxis   = Vector3.Cross(Vector3.forward, view.Direction).normalized;

                IInputSystem inputSystem;
                if (Input.touchSupported)
                {
                    inputSystem = new TouchInputSystem(slideBounds, slideAxis);
                }
                else
                {
                    inputSystem = new MouseInputSystem(slideBounds, slideAxis);
                }

                var model = new PlayerModel(view.transform.position, view.Direction, slideBounds, inputSystem);
                _playerModels[i] = model;

                view.Init(model);
            }
        }
    private void InstantiateSystemsManager()
    {
        SystemsManager      = Instantiate(new GameObject());
        SystemsManager.name = "SystemsManager";


        movementSystem       = SystemsManager.AddComponent <MovementSystem>();
        keyboardInputSystem  = SystemsManager.AddComponent <KeyboardInputSystem>();
        mouseInputSystem     = SystemsManager.AddComponent <MouseInputSystem>();
        factorySystem        = SystemsManager.AddComponent <FactorySystem>();
        lSystemSystem        = SystemsManager.AddComponent <LSystemSystem>();
        lSystemFactorySystem = SystemsManager.AddComponent <LSystemFactorySystem>();

        entityPool = SystemsManager.AddComponent <EntityPool>();
        entityPool.InitialiseEntitiesList();


        movementSystem.entityPool       = entityPool;
        keyboardInputSystem.entityPool  = entityPool;
        mouseInputSystem.entityPool     = entityPool;
        factorySystem.entityPool        = entityPool;
        lSystemSystem.entityPool        = entityPool;
        lSystemFactorySystem.entityPool = entityPool;
    }