Пример #1
0
    private void CreatePlayer(int id, CharacterBlueprint c)
    {
        LogicEntity e = Contexts.sharedInstance.logic.CreateEntity();

        //Add the logic
        e.AddPlayerID(id);

        e.AddPosition(
            new FixedVector2(0, 0)
            );

        e.AddRotation(0);
        e.AddScale(
            new FixedVector2(
                CharacterBlueprint.scale,
                CharacterBlueprint.scale)
            );

        e.AddVelocity(
            new FixedVector2(0, 0)
            );

        e.AddAcceleration(
            new FixedVector2(0, 0)
            );

        e.isMovable = true;
        e.AddLastPosition(e.position.value);
        e.AddLastVelocity(e.velocity.value);

        //Movement
        e.AddCurrentMovementX(0, 0, 0);
        e.AddGroundMovement(c.groundSpeed, c.groundAcceleration);
        e.AddAirMovement(c.airSpeed, c.airAcceleration);
        e.AddDashMovement(c.dashSpeed, c.dashAcceleration, c.dashLength);
        e.AddStunMovement(0, FixedMath.Create(2));
        e.AddWallRideMovement(
            c.maxSlideSpeed,
            c.fastSlideFactor,
            c.innerJump,
            c.neutralJump,
            c.outerJump,
            //acceleration
            FixedMath.Create(2, 10),
            //walljump length
            FixedMath.Create(25, 100),
            //stick time
            FixedMath.Create(5, 100)

            );

        e.AddDirection(1);

        //Jump
        e.AddTimeToApex(c.timeToJumpApex);
        e.AddMinJump(c.minJump);          // 1.5
        e.AddMaxJump(c.maxJump);

        e.AddJumpsAllowed(c.jumpsAllowed);
        e.AddJumpsCompleted(0);
        e.AddFastFallFactor(c.fastFallFactor);
        e.AddTerminalVelocity(c.terminalVelocity);
        e.AddFastFallTerminalVelocity(c.terminalVelocityFastFall);
        e.AddBounceHeight(c.bounceHeight);
        e.AddStunTime(FixedMath.Hundredth * 2);

        e.AddReflectionDampening(c.reflectionDampPlayer.x, c.reflectionDampPlayer.y);

        e.AddCollider(new Determinism.BoxCollider(e.position.value, c.playerColOffsetPosition * CharacterBlueprint.scale, c.playerColScale * CharacterBlueprint.scale));
        e.AddOnRayCastCollision(new CommandInput.PlayerRayCastCollisionCommand(e.id.value));
        e.AddOnTriggerEnter(new OnTriggerEnterCommand(e.id.value));

        e.collider.value.tag  = Tag.PLAYER;
        e.collider.value.mask = (Mask)(1 << (id + 1));

        e.collider.value.check =
            e.collider.value.check.AddFlags(Mask.DEFAULT, Mask.P1, Mask.P2, Mask.P3, Mask.P4, Mask.P5, Mask.P6, Mask.P7, Mask.P8);

        e.collider.value.check =
            e.collider.value.check.RemoveFlag(e.collider.value.mask);

        e.AddPusher(new List <Passenger> ());
        e.isHitable = true;

        e.AddWeight(c.weightFactor);

        e.AddHat(CreateHat(id, e.id.value, c));
        e.isRespawn = true;


        var view = Object.Instantiate(c.player).GetComponent <IView>();

        view.Link(e, Contexts.sharedInstance.logic);
    }