Beispiel #1
0
        private void EnterPlayTestMode()
        {
            skybox = Instantiate <GameObject> (Assets.Get(environment).skybox);

            LogicEntity e = Contexts.sharedInstance.logic.CreateEntity();

            e.AddCollider(new Determinism.RectilinearCollider(LevelBuilder.GenerateDeterministicCollider(map)));
            e.collider.value.mask = Mask.DEFAULT;
            e.collider.value.tag  = Tag.DEFAULT;

            FixedVector2[] spawnPositions = new FixedVector2[numPlayers];

            for (int i = 0; i < numPlayers; i++)
            {
                spawnPositions[i] = new FixedVector2(spawnPoints[i].transform.position);
            }

            Contexts.sharedInstance.logic.ReplaceSpawnPoints(spawnPositions);

            orthoCam.SetActive(false);
            cameraHolder.SetActive(true);

            isInEditMode = false;
        }
    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);
    }
    private int CreateHat(int id, int ownerID, CharacterBlueprint c)
    {
        LogicEntity e = Contexts.sharedInstance.logic.CreateEntity();

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

        e.AddRotation(0);
        e.AddLastRotation(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.AddDirection(1);

        //Follow
        e.isAttached = true;
        e.AddFollowPoint(ownerID, c.followSpeed, c.followPoint, c.pickUpRadius, c.maxRotation);

        //gravity is 50 * greater than in game
        e.AddGravity(c.gravity * 50);

        e.AddFriction(c.normalFriction, c.dangerousFriction);
        e.AddDrag(c.normalDrag, c.dangerousDrag);


        //* 50 / 10 from original amt
        e.AddThrowMovement(c.throwPower * 5, 0);

        //Throw
        e.AddKnockBack(c.blowBack);
        e.AddStunTime(c.stunTime);

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

        //collision
        e.AddCollider(new Determinism.BoxCollider(e.position.value, c.hatColOffsetPosition * CharacterBlueprint.scale, c.hatColScale * CharacterBlueprint.scale));
        e.AddOnRayCastCollision(new CommandInput.HatRayCastCollisionCommand(e.id.value));

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

        e.collider.value.isTrigger = true;

        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.isHitable   = true;
        e.isPusheable = true;
        e.AddWeight(c.weightFactor);

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

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

        return(e.id.value);
    }