public static BadPixel CreateCloaky()
        {
            BadPixel p = new BadPixel(Level.Current.pixie);

            p.IsCloaky = true;
            return(p);
        }
Esempio n. 2
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);
            Pixie pixie = Level.Current.pixie;

            // if attached, disable motion
            MyMotion.Active = true; // !(Parent is Pixie);

            // hack - not visible at first to avoid position-flicker
            if (SimTime < 0.3f)
            {
                Visible = false;
            }
            else
            {
                Visible = true;
            }

            // when floating free - check start of attachment to pixie
            if (!(Parent is Thing))
            {
                List <Thing> l = DetectCollisions(vecDown);
                if (l.Count > 0)
                {
                    foreach (Thing t in l)
                    {
                        if (t is BadPixel)
                        {
                            BadPixel bp = t as BadPixel;
                            if (bp.Parent is Pixie)
                            {
                                pixie.AddNextUpdate(this);                                                          // become a child - attach to it.
                                AttachmentPosition = new Vector2(TargetX - pixie.TargetX, TargetY - pixie.TargetY); // new relative position
                                TTutil.Round(ref AttachmentPosition);
                                pixie.Score += 1;
                                break;
                            }
                        }
                        else if (t is Pixie)
                        {
                            pixie.AddNextUpdate(this); // become a child - attach to it.
                            //AttachmentPosition = (new Vector2(PositionX, PositionY) - pixie.Target); // new relative position
                            //AttachmentPosition = new Vector2(1f,PositionY-pixie.TargetY); // new relative position
                            AttachmentPosition = new Vector2(TargetX - pixie.TargetX, TargetY - pixie.TargetY); // new relative position
                            TTutil.Round(ref AttachmentPosition);
                            //Level.Current.Subtitles.Show(2, "Ouch! That sticks!",3f);
                            pixie.Score += 1;
                            break;
                        }
                    }
                }
            }

            // check self-delete
            Vector2 pp = pixie.Target;

            if (TargetY > pixie.TargetY + 130f)     // if way down player somewhere, delete
            {
                Delete = true;
            }
            if (SimTime < 0.2f && CollidesWithBackground(Vector2.Zero))  // new entities that get stuck on background - delete
            {
                Delete = true;
            }
        }