Пример #1
0
        private static void InitCustomComponents()
        {
            Config = UnityGameFramework.Runtime.GameEntry.GetComponent <ConfigComponent>();
            HPBar  = UnityGameFramework.Runtime.GameEntry.GetComponent <HPBarComponent>();

            PlayerAction = UnityGameFramework.Runtime.GameEntry.GetComponent <PlayerActionComponent>();
        }
Пример #2
0
        protected override void Initialize()
        {
            base.Initialize();

            BuildEngines();
            var input = SetupInput();


            List <IImplementor> testEntityImplementors = new List <IImplementor>();

            world = new World(Vector2.Zero);

            var floor = BodyFactory.CreateBody(world);

            var body = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(64f), ConvertUnits.ToSimUnits(64f), 1f, Vector2.One, bodyType: BodyType.Dynamic);

            body.Mass = 1f;
            body.SetTransform(Vector2.Zero, 0f);


            var rigidBodyComponent = new RigidBodyComponentImplementor(body);
            var forceComponent     = new PhysicsForceComponent();
            var impulseComponent   = new PhysicsImpulseComponent();
            var torqueComponent    = new PhysicsTorqueComponent();

            testEntityImplementors.Add(rigidBodyComponent);
            testEntityImplementors.Add(forceComponent);
            testEntityImplementors.Add(impulseComponent);
            testEntityImplementors.Add(torqueComponent);

            //add movement driver, the vector value inside
            var movementDriverComponent = new MovementDriverComponent();

            var playerActionSetContext   = new PlayerActionContextComponent();
            var playerActionSetComponent = new PlayerActionSetComponent(input.playerActionSetOne);

            var playerActionLeftStickComponent  = new PlayerTwoAxisActionComponent(input.playerActionSetOne.LeftStick);
            var playerActionRightStickComponent = new PlayerTwoAxisActionComponent(input.playerActionSetOne.RightStick);
            var playerActionOneComponent        = new PlayerActionComponent(input.playerActionSetOne.Action1);
            var playerActionTwoComponent        = new PlayerActionComponent(input.playerActionSetOne.Action2);

            testEntityImplementors.Add(movementDriverComponent);
            testEntityImplementors.Add(playerActionOneComponent);
            testEntityImplementors.Add(playerActionTwoComponent);
            testEntityImplementors.Add(playerActionSetComponent);
            testEntityImplementors.Add(playerActionLeftStickComponent);
            testEntityImplementors.Add(playerActionRightStickComponent);
            testEntityImplementors.Add(playerActionSetContext);


            var Joint = JointFactory.CreateFrictionJoint(world, floor, body);

            Joint.MaxForce  = 80f;
            Joint.MaxTorque = 80f;

            var playerActionLeftStickSequencer = new Sequencer();

            var playerActionLeftStickUpdateEngine = new PlayerActionLeftStickUpdateEngine(playerActionLeftStickSequencer);
            var basicMoveEngine             = new BasicMoveEngine();
            var physicsForceEngine          = new PhysicsForceEngine();
            var movementDriverEngine        = new MovementDriverEngine();
            var playerActionSetUpdateEngine = new PlayerActionSetUpdateEngine();

            var testEngine = new TestEngine();

            playerActionLeftStickSequencer.SetSequence(
                new Steps
            {
                {
                    playerActionLeftStickUpdateEngine,
                    new To
                    {
                        { PlayerActionContext.Roam, new IStep[] { basicMoveEngine } },
                        { PlayerActionContext.UI, new IStep[] { basicMoveEngine } },
                    }
                },
                {
                    basicMoveEngine,
                    new To
                    {
                        new IStep[] { testEngine }
//                            {PlayerActionContext.Roam, new IStep[] {basicMoveEngine}},
//                            {PlayerActionContext.UI, new IStep[] {basicMoveEngine}},
                    }
                }
            }

                );


            gameEnginesRoot.AddEngine(testEngine);
            gameEnginesRoot.AddEngine(basicMoveEngine);
            gameEnginesRoot.AddEngine(physicsForceEngine);

            gameEnginesRoot.AddEngine(movementDriverEngine);
            gameEnginesRoot.AddEngine(playerActionSetUpdateEngine);
            gameEnginesRoot.AddEngine(playerActionLeftStickUpdateEngine);

            gameEngineEntityFactory.BuildEntity <TestEntityDescriptor>(1, testEntityImplementors.ToArray());
        }