Beispiel #1
0
 public void OnCollisionInfo(LogicEntity e, RaycastCollisionInfo info)
 {
     if (collisions.ContainsKey(e.id.value))
     {
         print("yeah im here");
     }
     else
     {
         collisions.Add(e.id.value, true);
     }
 }
        public override void OnCollisionEnter(RaycastCollisionInfo info)
        {
            LogicEntity e = Contexts.sharedInstance.logic.GetEntityWithId(entityID);

            if (!e.isAttached && info.CollidesHorizontal() && e.velocity.value.x != 0)
            {
                e.ReplaceVelocity(e.velocity.value.SetX(-e.velocity.value.x.Mul(e.reflectionDampening.xDampening)));
                if (e.hasThrowTimer)
                {
                    e.RemoveThrowTimer();
                }
            }

            if (!e.isAttached && info.CollidesVertical() && e.velocity.value.y != 0)
            {
//				if (e.hasThrowTimer && e.throwTimer.timeLeft - FixedMath.Tenth > 0)
//					e.ReplaceVelocity (e.velocity.value.FlipY ());
//				else {
//					e.ReplaceVelocity (e.velocity.value.SetY (-e.velocity.value.y.Mul(e.reflectionDampening.yDampening / 2)));
//				}

                if (info.CollidesWithVertical(Tag.HAT))
                {
                    e.ReplaceVelocity(e.velocity.value.SetY(-e.velocity.value.y.Mul(e.reflectionDampening.yDampening / 2)));
                }
                else
                {
                    e.ReplaceVelocity(e.velocity.value.SetY(0));
                }
            }

            if (!e.isAttached && info.down != Tag.NONE)
            {
                e.isGrounded = true;
            }
            else
            {
                e.isGrounded = false;
            }

            if (e.isDangerous)
            {
                Hit(entityID, info.leftID, info.horizontalHit);
                Hit(entityID, info.rightID, info.horizontalHit);
                Hit(entityID, info.upID, info.verticalHit);
                Hit(entityID, info.downID, info.verticalHit);
            }
        }
Beispiel #3
0
    public void OnCollisionInfo(LogicEntity e, RaycastCollisionInfo info)
    {
        if (e.isDangerous)
        {
            //shake if other is player
            //or other is hat and is attached

//			float distanceModifier = 1 - Mathf.Clamp01 ((transform.position.z - minZ) / (maxZ - minZ));
//			CameraShaker.Instance.ShakeOnce (
//				6f,
//				1f,
//				0.1f,
//				0.2f
//			);
        }
    }
Beispiel #4
0
        public virtual void OnCollisionEnter(RaycastCollisionInfo info)
        {
            LogicEntity e = Contexts.sharedInstance.logic.GetEntityWithId(entityID);

            if (e.isStunned && (info.left != Tag.NONE || info.right != Tag.NONE) && !info.CollidesWithHorizontal(Tag.HAT))
            {
                e.ReplaceVelocity(new FixedVector2(

                                      -e.velocity.value.x.Mul(FixedMath.Create(7, 10)),
                                      e.velocity.value.y + (e.velocity.value.y.Sign() * (e.velocity.value.x.Abs() / 2)))

                                  );

                return;
            }

            else if ((info.up != Tag.NONE || info.down != Tag.NONE) && !info.CollidesWithVertical(Tag.HAT))
            {
                e.ReplaceVelocity(e.velocity.value.SetY(0));
            }
        }
Beispiel #5
0
    public void OnCollisionInfo(LogicEntity e, RaycastCollisionInfo info)
    {
        if (info.horizontalEntered)
        {
            jiggler.Splash(
                e.position.value.ToVector3(),
                e.lastVelocity.value.ToVector3() / 200,
                10
                );
        }

        if (info.verticalEntered)
        {
            jiggler.Splash(
                e.position.value.ToVector3(),
                e.lastVelocity.value.ToVector3() / 200,
                10
                );
        }

        if (info.horizontalExited)
        {
            jiggler.Splash(
                e.position.value.ToVector3(),
                e.lastVelocity.value.ToVector3() / 200,
                10
                );
        }

        if (info.VerticalExited)
        {
            jiggler.Splash(
                e.position.value.ToVector3(),
                e.lastVelocity.value.ToVector3() / 200,
                10
                );
        }
    }
        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);
            }
        }
Beispiel #7
0
    protected override void Execute(List <LogicEntity> entities)
    {
        foreach (LogicEntity e in entities)
        {
            horizontalHit = FixedVector2.NAN;
            verticallHit  = FixedVector2.NAN;

            r = e.rayCastCollision.value;
            c = e.collider.value;

            left = right = up = down = -1;

            int  direction = e.direction.value;
            long rayLength = e.move.target.x.Abs() + r.skinWidth;

            if (e.move.target.x.Abs() < r.skinWidth)
            {
                rayLength = r.skinWidth;
            }

            for (int i = 0; i < r.horizontalRayCount; i++)
            {
                FixedVector2 origin = (direction == -1) ? c.broadBounds.bottomLeft : c.broadBounds.bottomRight;
                origin += FixedVector2.UP * (r.horizontalRaySpacing * i);

                FixedVector2 hit;
                FixedVector2 end = FixedVector2.RIGHT * (rayLength * direction);
                l = new FixedLine2(origin, origin + end);

                int otherId = -1;
                if (RayCastSystem.Check(origin, end, out hit, e.id.value, c.check, out otherId))
                {
                    if (direction < 0)
                    {
                        left = otherId;
                    }

                    else
                    {
                        right = otherId;
                    }

                    long distance = (hit - origin).magnitude;
                    if (distance > minDistance)
                    {
                        distance -= minDistance;
                    }
                    else
                    {
                        distance = 0;
                    }

                    e.move.target.x = distance * direction;

                    horizontalHit = hit;
                }
            }

            direction = e.move.target.y.Sign();
            rayLength = e.move.target.y.Abs() + r.skinWidth;

            for (int i = 0; i < r.verticalRayCount; i++)
            {
                FixedVector2 origin = (direction == -1) ? c.broadBounds.bottomLeft : c.broadBounds.topLeft;
                origin.x += e.move.target.x;
                origin   += FixedVector2.RIGHT * (r.verticalRaySpacing * i);

                FixedVector2 hit;
                FixedVector2 end = FixedVector2.UP * (rayLength * direction);
                l = new FixedLine2(origin, origin + end);

                int otherId = -1;
                if (RayCastSystem.Check(origin, end, out hit, e.id.value, c.check, out otherId))
                {
                    if (direction < 0)
                    {
                        down = otherId;
                    }

                    else
                    {
                        up = otherId;
                    }

                    long distance = (hit - origin).magnitude;
                    if (distance > minDistance)
                    {
                        distance -= minDistance;
                    }
                    else
                    {
                        distance = 0;
                    }

                    e.move.target.y = distance * direction;

                    verticallHit = hit;
                }
            }

            r = null;
            c = null;

            e.ReplaceLastPosition(e.position.value);
            e.ReplacePosition(e.position.value + e.move.target);

            e.collider.value.MoveCollider(e.position.value);
            e.RemoveMove();

            RaycastCollisionInfo info = new RaycastCollisionInfo(left, right, up, down, horizontalHit, verticallHit);

            if (e.hasCollisionInfo)
            {
                info.RecordLastPreviousCollision(
                    e.collisionInfo.value.leftID,
                    e.collisionInfo.value.rightID,
                    e.collisionInfo.value.upID,
                    e.collisionInfo.value.downID
                    );
            }

            e.ReplaceCollisionInfo(info);
        }
    }