コード例 #1
0
ファイル: Player.cs プロジェクト: Zeldorks/Zeldorks
        public void ProcessMovement(GameInputs.Movement movement)
        {
            if (movement == GameInputs.Movement.None)
            {
                return;
            }

            entityOpt.Update(
                world.ecsRegistry,
                entity => {
                Ecs.Systems.Movement.Process(
                    movement,
                    entity,
                    world.ecsRegistry
                    );
                Ecs.Systems.CharacterOrientation.Process(
                    movement,
                    entity,
                    world.ecsRegistry
                    );
                Ecs.Systems.CharacterAttack.Process(
                    movement,
                    entity,
                    world.ecsRegistry
                    );
            }
                );
        }
コード例 #2
0
        // Pre-condition: `movement != GameInputs.Movement.None`
        public static void Process(
            GameInputs.Movement movement,
            Entity entity,
            Registry registry
            )
        {
            var character = registry
                            .GetComponentUnsafe <Comps.Character>(entity);

            var orientation = registry
                              .GetComponentUnsafe <Comps.Orientations.Cardinal>(entity);

            Physical.Orientation.Cardinal movementDirection =
                movement.ToCardinalDirection();

            if (character.kind == Comps.Character.Kind.Aquamentus)
            {
                // Aquamentus can only face left and right
                switch (movementDirection)
                {
                case Physical.Orientation.Cardinal.Left:
                case Physical.Orientation.Cardinal.Right:
                    orientation.data = movementDirection;
                    break;
                }
            }
            else
            {
                orientation.data = movementDirection;
            }
        }
コード例 #3
0
ファイル: Movement.cs プロジェクト: Zeldorks/Zeldorks
 // Pre-condition: `movement != GameInputs.Movement.None`
 public static void Process(
     GameInputs.Movement movement,
     Entity entity,
     Registry registry
     )
 {
     registry.AssignComponent(
         entity,
         new VelocityComp {
         data = movement.ToVector2() * 15
     }
         );
 }
コード例 #4
0
ファイル: CharacterAttack.cs プロジェクト: Zeldorks/Zeldorks
        // Pre-condition: `movement != GameInputs.Movement.None`
        public static void Process(
            GameInputs.Movement movement,
            Entity entity,
            Registry registry
            )
        {
            // Stop attacking when moving
            var characterCompOpt = registry.GetComponent <Comps.Character>(entity);

            characterCompOpt.MatchSome(characterComp => {
                characterComp.attacking = false;
            });
        }