Ejemplo n.º 1
0
        public override void ResolveCollision(BladeTrapCollisionResponse other)
        {
            BladeTrapMovement btMovement = entity.GetComponent <BladeTrapMovement>();

            if (entity.GetComponent <BladeTrapMovement>().state == BladeTrapMovement.State.EXTENDING)
            {
                btMovement.ReverseDirection();
            }
        }
Ejemplo n.º 2
0
        // Unsure why I need to duplicate this for BladeTrap... It *should* be using the Enemy one
        public override void ResolveCollision(BladeTrapCollisionResponse other)
        {
            LinkBehavior linkBehavior = entity.GetComponent <LinkBehavior>();

            // Change to Hurt Sprite (enables and disables immunity inside)
            if (!entity.GetComponent <LinkHealthManagement>().immune)
            {
                // Take Damage
                entity.GetComponent <LinkHealthManagement>().Damage(other.damage);

                // Push back
                Vector2 linkPos  = entity.GetComponent <Transform>().WorldPosition;
                Vector2 enemyPos = other.entity.GetComponent <Transform>().position;
                Vector2 diff     = linkPos - enemyPos;
                int     distance = Constants.ENEMY_KNOCKBACK_DISTANCE;
                int     frames   = Constants.ENEMY_KNOCKBACK_FRAMES;

                // Enemy is Up from Link
                // UPWARD && MORE VERTICAL THAN HORIZONTAL
                if (enemyPos.Y <= linkPos.Y && Math.Abs(diff.Y) >= Math.Abs(diff.X))
                {
                    entity.AddComponent(new LinkKnockback(Constants.Direction.DOWN, distance, frames));
                    // Console.WriteLine("Enemy is up from link!");
                }

                // Enemy is Right from Link
                // RIGHTWARD && MORE HORIZONTAL THAN VERTICAL
                else if (enemyPos.X >= linkPos.X && Math.Abs(diff.X) >= Math.Abs(diff.Y))
                {
                    entity.AddComponent(new LinkKnockback(Constants.Direction.LEFT, distance, frames));
                    // Console.WriteLine("Enemy is right from link!");
                }

                // Enemy is Down from Link
                // DOWNWARD && MORE VERTICAL THAN HORIZONTAL
                else if (enemyPos.Y >= linkPos.Y && Math.Abs(diff.Y) >= Math.Abs(diff.X))
                {
                    entity.AddComponent(new LinkKnockback(Constants.Direction.UP, distance, frames));
                    // Console.WriteLine("Enemy is down from link!");
                }

                // Enemy is Left from Link
                // LEFTWARD && MORE HORIZONTAL THAN VERTICAL
                else if (enemyPos.X <= linkPos.X && Math.Abs(diff.X) >= Math.Abs(diff.Y))
                {
                    entity.AddComponent(new LinkKnockback(Constants.Direction.RIGHT, distance, frames));
                    // Console.WriteLine("Enemy is left from link!");
                }

                // Debug; If this ever gets output, something is wrong.
                else
                {
                    Console.WriteLine("Enemy was unrecognized direction!");
                }
            }
        }