Exemplo n.º 1
0
 public BuffComponent(LogicEntity entity) : base(entity)
 {
 }
Exemplo n.º 2
0
 public LogicAnim(LogicEntity entity) : base(entity)
 {
 }
        public void Hit(int eID, int otherID, FixedVector2 hitPoint)
        {
            LogicEntity e     = Contexts.sharedInstance.logic.GetEntityWithId(eID);
            LogicEntity other = Contexts.sharedInstance.logic.GetEntityWithId(otherID);

            if (other == null)
            {
                return;
            }

            if (other.hasFollowPoint && other.isAttached)
            {
                other = Contexts.sharedInstance.logic.GetEntityWithId(other.followPoint.targetID);
            }

            if (!other.isHitable)
            {
                return;
            }


//			FixedVector2 offset = new FixedVector2 (
//				(e.collider.value.halfExtents.x / 2) * e.velocity.value.x.Sign (),
//				//- (e.collider.value.halfExtents.y / 2)
//				0
//			);
            FixedVector2 offset = new FixedVector2(
                //(e.collider.value.halfExtents.x / 2) * e.velocity.value.x.Sign (),
                //- (e.collider.value.halfExtents.y / 2)
                0,
                -FixedMath.Create(1, 10)
                );

            long knockback = e.knockBack.value.Mul(e.weight.value);

            FixedVector2 direction = (hitPoint - (e.position.value + offset)).normalized;

            if (other.hasHat)
            {
                other.ReplaceVelocity(direction * knockback);
                e.ReplaceFreeze(5);
                other.ReplaceFreeze(5);

                LogicEntity otherHat = Contexts.sharedInstance.logic.GetEntityWithId(other.hat.entityID);

                if (otherHat.isAttached)
                {
                    otherHat.ReplaceVelocity((other.velocity.value.FlipX().FlipY()));
                    otherHat.ReplaceFreeze(5);
                    otherHat.throwMovement.throwPositionY = other.position.value.y;
                    otherHat.isAttached = false;
                    otherHat.isFalling  = true;
                }

                other.isStunned = true;
                other.ReplaceStunTimer(e.stunTime.value);
                other.ReplaceCurrentMovementX(
                    other.velocity.value.x,
                    other.stunMovement.accelerationTime,
                    0);
            }
            else if (other.isDangerous)
            {
                e.ReplaceFreeze(5);
                other.ReplaceFreeze(5);
            }
            else
            {
                direction = e.position.value - other.position.value;
                other.ReplaceVelocity(direction * knockback / 2);
            }

            if (e.hasThrowTimer)
            {
                e.RemoveThrowTimer();
            }
        }
Exemplo n.º 4
0
 private void DangerOverFX(LogicEntity obj)
 {
     AudioManager.singleton.PostWwiseEvent(HatSounds.EXTINGUISH_SOUND, go);
 }
Exemplo n.º 5
0
 private void ThrowFX(LogicEntity obj)
 {
     AudioManager.singleton.PostWwiseEvent(name + HatSounds.THROW_SOUND, go);
 }
Exemplo n.º 6
0
 private void HitPlayerFX(LogicEntity obj)
 {
     AudioManager.singleton.PostWwiseEvent(HatSounds.PLAYER_HIT_SOUND, go);
     Debug.Log("Hit");
 }
Exemplo n.º 7
0
 private void EmptyFunction(LogicEntity obj)
 {
 }
Exemplo n.º 8
0
 public virtual void OnDangerous(LogicEntity entity)
 {
     prefabManager.ManageGameObject("Fire", true);
     prefabManager.ManageGameObject("Trail", true);
 }
Exemplo n.º 9
0
 public virtual void OnDangerousRemoved(LogicEntity entity)
 {
     prefabManager.ManageGameObject("Fire", false);
     prefabManager.ManageGameObject("Trail", false);
 }
Exemplo n.º 10
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);
    }
Exemplo n.º 11
0
 public virtual void OnDirty(LogicEntity entity)
 {
 }
Exemplo n.º 12
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);
    }
Exemplo n.º 13
0
 public EffectReceiver(LogicEntity entity) : base(entity)
 {
 }
        public override void OnCollisionEnter(RaycastCollisionInfo info)
        {
            LogicEntity e = Contexts.sharedInstance.logic.GetEntityWithId(entityID);

            if (e.isStunned)
            {
                if (!info.CollidesWithHorizontal(Tag.HAT) &&
                    info.CollidesHorizontal())
                {
                    e.ReplaceVelocity(new FixedVector2(

                                          -e.velocity.value.x.Mul(e.reflectionDampening.xDampening),
                                          e.velocity.value.y + (e.velocity.value.y.Sign() * e.velocity.value.x.Abs()).Mul(e.reflectionDampening.yDampening))

                                      );
                }

                if (!info.CollidesWithVertical(Tag.HAT) &&
                    info.up != Tag.NONE)
                {
                    e.ReplaceVelocity(e.velocity.value.SetY(0));
                }

                return;
            }

            LogicEntity leftEntity  = Contexts.sharedInstance.logic.GetEntityWithId(info.leftID);
            LogicEntity rightEntity = Contexts.sharedInstance.logic.GetEntityWithId(info.rightID);
            LogicEntity upEntity    = Contexts.sharedInstance.logic.GetEntityWithId(info.upID);
            LogicEntity downEntity  = Contexts.sharedInstance.logic.GetEntityWithId(info.downID);

            if (!info.CollidesWithVertical(Tag.HAT) && info.CollidesVertical())
            {
                e.ReplaceVelocity(e.velocity.value.SetY(0));
            }

            if ((info.left != Tag.NONE || info.right != Tag.NONE))
            {
                if (info.horizontalHit.y > e.position.value.y)
                {
                    e.isWallRiding = true;
                    e.isDashing    = false;
                }
            }

            if ((info.down == Tag.HAT && info.downID != e.hat.entityID) && !downEntity.isDangerous && !downEntity.isInvincible)
            {
                LogicEntity hat = Contexts.sharedInstance.logic.GetEntityWithId(info.downID);
                hat.isDead = true;
                hat.ReplaceDeathTimer(DEATH_TIME);

                LogicEntity player = Contexts.sharedInstance.logic.GetEntityWithId(hat.followPoint.targetID);
                player.isDead = true;
                player.ReplaceFreeze(DEATH_FREEZE_FRAMES);
                player.ReplaceDeathTimer(DEATH_TIME);
            }

            if (info.down == Tag.DEFAULT)
            {
                e.ReplaceJumpsCompleted(0);
                e.isGrounded   = true;
                e.isWallRiding = false;
            }
            else if ((info.down == Tag.HAT || info.down == Tag.PLAYER) && !downEntity.isDangerous)
            {
                //Bounce
                if (info.down == Tag.PLAYER && !e.isStunned)
                {
                    downEntity.isStunned = true;
                    downEntity.ReplaceStunTimer(e.stunTime.value);
                    downEntity.ReplaceCurrentMovementX(0, 0, 0);
                    downEntity.ReplaceVelocity(downEntity.velocity.value.SetX(0));
                }

                e.ReplaceVelocity(e.velocity.value.SetY(e.bounceVelocity.value));
                e.jumpsCompleted.value = 0;

                e.isGrounded = false;
                e.isDashing  = false;
            }
            else
            {
                e.isGrounded = false;
                e.isDashing  = false;
            }

            if (e.hasPusher)
            {
                if (info.left != Tag.NONE && leftEntity.isPusheable && !leftEntity.isStunned && !leftEntity.isDangerous)
                {
                    e.pusher.passengers.Add(new Passenger(info.leftID, true, false));
                }

                if (info.right != Tag.NONE && rightEntity.isPusheable && !rightEntity.isStunned && !rightEntity.isDangerous)
                {
                    e.pusher.passengers.Add(new Passenger(info.rightID, true, false));
                }

                if (info.up != Tag.NONE && upEntity.isPusheable && !upEntity.isStunned && !upEntity.isDangerous)
                {
                    e.pusher.passengers.Add(new Passenger(info.upID, false, true));
                }

                if (info.down != Tag.NONE && downEntity.isPusheable && !downEntity.isStunned && !downEntity.isDangerous)
                {
                    e.pusher.passengers.Add(new Passenger(info.downID, false, true));
                }

                e.ReplacePusher(e.pusher.passengers);
            }
        }
Exemplo n.º 15
0
 private void StunRepeatFX(LogicEntity e)
 {
     GlobalVFX.PlayStunnedParticles(e.position.value.ToVector3());
 }
Exemplo n.º 16
0
 public virtual void OnFreeze(LogicEntity entity, int value)
 {
     sr.material.SetFloat("_InvertColors", 1);
 }
Exemplo n.º 17
0
 private void HitLevelFX(LogicEntity obj)
 {
     AudioManager.singleton.PostWwiseEvent(HatSounds.LEVEL_HIT_SOUND, go);
 }
Exemplo n.º 18
0
 public virtual void OnFreezeRemoved(LogicEntity entity)
 {
     sr.material.SetFloat("_InvertColors", 0);
 }
Exemplo n.º 19
0
 private void HitHatFX(LogicEntity obj)
 {
     AudioManager.singleton.PostWwiseEvent(HatSounds.HAT_HIT_SOUND, go);
 }
Exemplo n.º 20
0
 public virtual void OnStunnedRemoved(LogicEntity entity)
 {
     prefabManager.ManageGameObject("Stun_FX", false);
 }
Exemplo n.º 21
0
 private void FrictionFX(LogicEntity obj)
 {
 }
Exemplo n.º 22
0
 public virtual void OnInvincibleRemoved(LogicEntity entity)
 {
     sr.material.SetColor("_OverrideColor", new Color(1, 1, 1, 0));
 }
Exemplo n.º 23
0
 private void HatDeathFX(LogicEntity obj)
 {
     AudioManager.singleton.PostWwiseEvent(HatSounds.DEATH_SOUND, go);
 }
Exemplo n.º 24
0
 public virtual void OnDead(LogicEntity entity)
 {
     prefabManager.ManageGameObject("Soul", true);
     prefabManager.InitializeGameObject("Soul", entity, transform);
 }
Exemplo n.º 25
0
 private void PickUpFX(LogicEntity obj)
 {
     AudioManager.singleton.PostWwiseEvent(HatSounds.PICKUP_SOUND, go);
 }
Exemplo n.º 26
0
 public virtual void OnDeadRemoved(LogicEntity entity)
 {
 }
Exemplo n.º 27
0
 public LogicTransform(LogicEntity entity, SafeV3 pos)
     : base(entity)
 {
     this.position = pos;
 }
Exemplo n.º 28
0
 public virtual void Update(bool condition, LogicEntity e)
 {
 }
Exemplo n.º 29
0
 public void EmptyFunction(LogicEntity e)
 {
     //get required data from the entity
 }
Exemplo n.º 30
0
 public virtual void OnRotation(LogicEntity entity, long value)
 {
     rotation = value.ToFloat();
 }