Ejemplo n.º 1
0
        private void BuildEye(float openAmount)
        {
            var count    = 32;
            var left     = new Vector2(-100, 0);
            var right    = -left;
            var basePull = new Vector2(0, openAmount);
            var curves   = new CatmullRomCurve[6];
            // top curve
            var topPull = basePull - lookOffset * 5 * openAmount;

            curves[0] = CatmullRomCurve.Create(count,
                                               topPull,
                                               left,
                                               right,
                                               topPull);

            // bottom curve
            var bottomPull = -basePull - lookOffset * 2 * openAmount;

            curves[1] = CatmullRomCurve.Create(count,
                                               bottomPull,
                                               left,
                                               right,
                                               bottomPull);

            CatmullRomCurve BuildIrisSegment(float progress, Vector2 pull)
            {
                var start = curves[0].GetPointAlong(progress);
                var end   = curves[1].GetPointAlong(progress);

                return(CatmullRomCurve.Create(count,
                                              pull,
                                              start,
                                              end,
                                              pull));
            }

            var progressForIris = 0.4f * (this.aimTimer / 20 + 1);
            var pullFactor      = (1 + this.aimTimer);

            curves[2] = BuildIrisSegment(Math.Clamp(progressForIris + lookOffset.X, 0.2f, 0.8f), right * pullFactor);
            curves[3] = BuildIrisSegment(Math.Clamp(1 - progressForIris + lookOffset.X, 0.2f, 0.8f), left * pullFactor);

            this.eyeCurves = curves;
        }
Ejemplo n.º 2
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            var curve = CatmullRomCurve.Create(25,
                                               transform.ChildAt(0).transform.Position,
                                               transform.ChildAt(1).transform.Position,
                                               transform.ChildAt(2).transform.Position,
                                               transform.ChildAt(3).transform.Position);

            for (int i = 0; i < curve.Count - 1; i++)
            {
                if (this.time > i && this.time < i + 1)
                {
                    spriteBatch.DrawCircle(new CircleF(curve.points[i], 5f), 3, Color.White, 1f, transform.Depth);
                }
            }

            if (time > curve.Count)
            {
                time = 0;
            }

            curve.Draw(spriteBatch, Vector2.Zero, transform.Depth, 1f);
        }