Exemplo n.º 1
0
    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);
    }