void ChangeChildren()
        {
            if (OldChildren != null)
            {
                foreach (BasicGameForm f in OldChildren)
                {
                    f.SetSection(null);
                }
            }

            int childCount = 0;

            foreach (GameObject f in HierarchyChildren)
            {
                if (f.GetType().IsSubclassOf(typeof(BasicGameForm)))
                {
                    BasicGameForm b = (BasicGameForm)f;
                    b.SetSection(this);
                    childCount++;
                }
            }

            OldChildren    = new BasicGameForm[childCount];
            CenterPosition = Vector2.Zero;

            int i = 0;

            foreach (GameObject o in HierarchyChildren)
            {
                if (o.GetType().IsSubclassOf(typeof(BasicGameForm)))
                {
                    BasicGameForm f = (BasicGameForm)o;
                    OldChildren[i++] = f;
                    CenterPosition  += f.Position.get();
                }
            }

            CenterPosition /= childCount;

            float BestDistance = 10000;

            foreach (BasicGameForm f in OldChildren)
            {
                float d = Vector2.Distance(f.Position.get(), CenterPosition);
                if (d < BestDistance)
                {
                    BestDistance = d;
                    CenterForm   = f;
                }
            }
        }
Beispiel #2
0
        public void SetCurrentForm(BasicGameForm Form)
        {
            if (this.CurrentForm != null)
            {
                this.CurrentForm.MarkerLeave(this);
            }

            this.CurrentForm = Form;

            if (Form != null)
            {
                Form.MarkerEnter(this);
            }
        }
        public override void PlayerJoinedEvent(PlayerProfile p)
        {
            PlayerMarker m = new PlayerMarker(p);

            foreach (GameObject o in GetList(GameObjectTag.Form))
            {
                BasicGameForm f = (BasicGameForm)o;
                if (f.StartingForm.get())
                {
                    m.SetCurrentForm(f);
                }
            }

            Add(m);
            base.PlayerJoinedEvent(p);
        }
Beispiel #4
0
 public void Add(BasicGameForm Form)
 {
     FormChildren.AddLast(Form);
     Form.AddToFrame(this);
 }
 static BasicGameForm Add(BasicGameForm Form)
 {
     GameManager.GetLevel().AddObject(Form);
     CurrentFrame.Add(Form);
     return(Form);
 }
        static bool DropPlayer(BasicGameForm form, BasicMarker trigger)
        {
            PlayerProfile.RemovePlayer(trigger.MyPlayer);

            return(true);
        }