Esempio n. 1
0
        public void Grapple(int targetPos)
        {
            var angle  = Curio.GetAngle() + targetPos * MathHelper.PiOver4;
            var offset = Util.AngleToVector(angle);

            var grappleTarget = Curio.GetGrappleTarget(offset);

            var actions = new List <ActionWrapper>();

            if (grappleTarget != null)
            {
                foreach (var grapple in grappleTarget.GetBehaviors <IGrappleTarget>())
                {
                    grapple.AddGrappleAction(actions, Curio, offset);
                }
            }
            else
            {
                actions.Add(new ActionGrappleNothing(Curio, GetFurthestGrapple(offset), offset, 10, 5).InSlot(ActionSlot.Active));
                actions.Add(new ActionKeepMoving(Curio).InSlot(ActionSlot.Active));
            }
            actions.Apply(Curio);
        }
Esempio n. 2
0
        public void MoveTick(Vector2 direction)
        {
            SparkFrame += Curio.GetWorld().TimeModCurrent;
            if (SparkFrame.Done)
            {
                SparkFrame.Reset();

                if (Position == 0)
                {
                    return;
                }

                var tile     = Curio.GetMainTile();
                var angle    = Curio.GetAngle() + Position * MathHelper.PiOver4;
                var offset   = Util.AngleToVector(angle).ToTileOffset();
                var neighbor = tile.GetNeighborOrNull(offset.X, offset.Y);
                if (neighbor != null && neighbor.IsSolid())
                {
                    Vector2 sparkDirection = direction;
                    if (Position < 0)
                    {
                        sparkDirection = sparkDirection.TurnLeft();
                    }
                    if (Position > 0)
                    {
                        sparkDirection = sparkDirection.TurnRight();
                    }
                    Vector2 tip = GetBlade(8);
                    for (int i = 0; i < 3; i++)
                    {
                        Vector2 randomOffset = Util.AngleToVector(Random.NextAngle()) * 20;
                        new SparkParticle(Curio.GetWorld(), SpriteLoader.Instance.AddSprite("content/effect_cinder"), tip, 10)
                        {
                            Velocity     = sparkDirection * Random.Next(24, 48) + randomOffset,
                            Color        = Color.White,
                            Size         = Random.NextFloat(),
                            VelocityLerp = LerpHelper.QuadraticIn,
                            DrawPass     = DrawPass.EffectCreatureAdditive,
                        };
                    }
                }
            }
        }