Пример #1
0
        public void CameraFollowSystem_WithSingletons()
        {
            // Setup camera follow system mock for update function
            Mock <CameraFollowSystem> cameraFollowMock = new Mock <CameraFollowSystem>();

            this.cameraFollow = World.AddSystem <CameraFollowSystem>(cameraFollowMock.Object);
            cameraFollowMock.Protected().Setup("OnUpdate");

            // Create target entity
            var cameraTarget = this.CreateTargetEntity();
            int playerId     = 1;

            // Move starting entity
            Vector3 targetPos = new float3(CameraFollowSystemTests.StartingPosition) + new float3(1, 1, 1);

            m_Manager.SetComponentData(cameraTarget, new Translation {
                Value = targetPos
            });
            m_Manager.SetComponentData(cameraTarget, new PlayerId {
                playerId = playerId
            });
            this.CreateNetworkSingletons(playerId);

            // Ensure that camera doesn't move without required singletons
            this.cameraFollow.Update();

            // Ensure update function has been invoked
            cameraFollowMock.Protected().Verify("OnUpdate", Times.Once());
        }
Пример #2
0
 private void Start()
 {
     playerInputSystem     = World.Active.GetOrCreateSystem <PlayerInputSystem>();
     playerMovementSystem  = World.Active.GetOrCreateSystem <PlayerMovementSystem>();
     playerTurningSystem   = World.Active.GetOrCreateSystem <PlayerTurningSystem>();
     playerAnimationSystem = World.Active.GetOrCreateSystem <PlayerAnimationSystem>();
     cameraFollowSystem    = World.Active.GetOrCreateSystem <CameraFollowSystem>();
 }
    private void Start()
    {
        var world = World.DefaultGameObjectInjectionWorld;

        playerInputSystem     = world.GetOrCreateSystem <PlayerInputSystem>();
        playerMovementSystem  = world.GetOrCreateSystem <PlayerMovementSystem>();
        playerTurningSystem   = world.GetOrCreateSystem <PlayerTurningSystem>();
        playerAnimationSystem = world.GetOrCreateSystem <PlayerAnimationSystem>();
        cameraFollowSystem    = world.GetOrCreateSystem <CameraFollowSystem>();
    }
Пример #4
0
 /// <summary>
 /// Where systems are added to the EntiyController.
 /// Currently you have to add them here manually
 /// </summary>
 private void InitSystems()
 {
     //generalSystems.Add(new PhysicsSystem(CIP,this));
     backGroundSystem   = new BackGroundSystem(graphicsDevice, this);
     chunkSystem        = new ChunkSystem(graphicsDevice, this, 100);
     playerSystem       = new PlayerSystem(this);
     cameraFollowSystem = new CameraFollowSystem(graphicsDevice, this);
     renderSystem       = new RenderSystem(new SpriteBatch(graphicsDevice), graphicsDevice, this);
     UIRenderSystem     = new UIRenderSystem(new SpriteBatch(graphicsDevice), this);
 }
Пример #5
0
        /// <summary>
        /// Called from <see cref="PlayerInteractiveObjectCreatedEvent"/>.
        /// </summary
        protected virtual void OnPlayerInteractiveObjectCreated(IPlayerInteractiveObject IPlayerInteractiveObject)
        {
            //set initial position
            this.CameraPivotPointTransform[0].position = IPlayerInteractiveObject.InteractiveGameObject.InteractiveGameObjectParent.transform.position;

            this._cameraFollowSystem = new CameraFollowSystem(IPlayerInteractiveObject.InteractiveGameObject.InteractiveGameObjectParent.transform,
                                                              CameraConfigurationGameObject.Get().CameraMovementConfiguration.CameraFollowManagerComponent);

            var CameraMovementJobStateStruct = this.CameraMovementJob.GetCameraMovementJobState();

            CameraMovementJobStateStruct.CameraObject.Initialize(CameraPivotPointTransform[0], MainCamera);
            this._cameraFollowSystem.InitState(ref CameraMovementJobStateStruct);
            this.CameraMovementJob.SetCameraMovementJobState(CameraMovementJobStateStruct);
        }
Пример #6
0
    private void Start()
    {
        playerInputSystem     = World.Active.GetOrCreateSystem <PlayerInputSystem>();
        playerMovementSystem  = World.Active.GetOrCreateSystem <PlayerMovementSystem>();
        playerTurningSystem   = World.Active.GetOrCreateSystem <PlayerTurningSystem>();
        playerAnimationSystem = World.Active.GetOrCreateSystem <PlayerAnimationSystem>();
        cameraFollowSystem    = World.Active.GetOrCreateSystem <CameraFollowSystem>();

        World.Active.GetExistingSystem <EnemyMovementSystem>().Enabled  = false;
        World.Active.GetExistingSystem <EnemyShootingSystem>().Enabled  = false;
        World.Active.GetExistingSystem <PlayerMovementSystem>().Enabled = false;
        World.Active.GetExistingSystem <PlayerShootingSystem>().Enabled = false;
        World.Active.GetExistingSystem <PlayerTurningSystem>().Enabled  = false;
        World.Active.GetExistingSystem <ZoneShrinkingSystem>().Enabled  = false;
    }
Пример #7
0
        public void CameraFollowSystem_NoSingletons()
        {
            // Setup camera follow system mock for update function
            Mock <CameraFollowSystem> cameraFollowMock = new Mock <CameraFollowSystem>();

            this.cameraFollow = World.AddSystem <CameraFollowSystem>(cameraFollowMock.Object);
            cameraFollowMock.Protected().Setup("OnUpdate");

            // Destroy the netwok singletons
            if (this.cameraFollow.HasSingleton <NetworkIdComponent>())
            {
                World.EntityManager.DestroyEntity(World.EntityManager.CreateEntityQuery(ComponentType.ReadOnly <NetworkIdComponent>()));
            }

            // Ensure that camera doesn't move without required singletons
            this.cameraFollow.Update();

            // Ensure update function has not been invoked
            cameraFollowMock.Protected().Verify("OnUpdate", Times.Never());;
        }
Пример #8
0
    protected override void OnCreate()
    {
        var world = World.DefaultGameObjectInjectionWorld;

        animationSystem    = world.GetOrCreateSystem <AnimationSystem>();
        cameraFollowSystem = world.GetOrCreateSystem <CameraFollowSystem>();

        retrieveInteractableCollisionsSystem = world.GetOrCreateSystem <RetrieveInteractableCollisionsSystem>();
        playerCollisionSystem       = world.GetOrCreateSystem <PlayerCollisionSystem>();
        temporaryEnemySpawnerSystem = world.GetOrCreateSystem <TemporaryEnemySpawnerSystem>();

        var lateSimulation = world.GetOrCreateSystem <LateSimulationManager>();

        lateSimulation.AddSystemToUpdateList(animationSystem);
        lateSimulation.AddSystemToUpdateList(cameraFollowSystem);
        lateSimulation.AddSystemToUpdateList(retrieveInteractableCollisionsSystem);
        lateSimulation.AddSystemToUpdateList(playerCollisionSystem);
        lateSimulation.AddSystemToUpdateList(temporaryEnemySpawnerSystem);

        lateSimulation.SortSystemUpdateList();
    }
Пример #9
0
        public override void Setup()
        {
            base.Setup();

            // Ensure that camera exists
            if (Camera.main == null)
            {
                this.camera = GameObject.Instantiate(new GameObject(), Vector3.zero, Quaternion.identity);
                var cameraComponent = this.camera.AddComponent <Camera>();
                this.camera.tag = "MainCamera";
            }
            else
            {
                this.camera = Camera.main.gameObject;
                this.camera.transform.position = StartingPosition;
                this.camera.transform.rotation = StartingRotation;
            }

            // Setup camera follow system
            this.cameraFollow = World.CreateSystem <CameraFollowSystem>();
        }
Пример #10
0
        public void Execute(int index, TransformAccess transform)
        {
            var CameraMovementJobStateStruct = this.CameraMovementJobState[0];

            var cameraFollowPosition        = CameraFollowSystem.CameraFollowTargetMovement(ref CameraMovementJobStateStruct);
            var cameraDeltaRotation         = CameraOrientationSystem.CameraRotation(in CameraMovementJobStateStruct);
            var cameraPanningDeltaPosition  = CameraPanningSystem.CameraPanningMovement(ref CameraMovementJobStateStruct);
            var cameraVerticalRotationDelta = CameraVerticalRotationSystem.CameraVerticalRotation(ref CameraMovementJobStateStruct);
            var cameraZoomValue             = CameraZoomSystem.CameraZoom(ref CameraMovementJobStateStruct);

            var CameraObject = CameraMovementJobStateStruct.CameraObject;

            var rotation = math.mul(cameraDeltaRotation, CameraObject.CameraPivotPointTransformWithoutOffset.rot);

            CameraObject.CameraPivotPointTransformWithoutOffset = new RigidTransform(rotation, cameraFollowPosition);
            CameraObject.CameraSize = cameraZoomValue;

            CameraMovementJobStateStruct.CameraObject = CameraObject;

            this.CameraMovementJobState[0] = CameraMovementJobStateStruct;

            transform.position = cameraFollowPosition + cameraPanningDeltaPosition;
            transform.rotation = math.mul(rotation, cameraVerticalRotationDelta);
        }
Пример #11
0
 /// <summary>
 /// Called from <see cref="PlayerInteractiveObjectDestroyedEvent"/>
 /// </summary>
 private void OnPlayerInteractiveObjectDestroyed()
 {
     this._cameraFollowSystem = null;
 }