Example #1
0
        public override bool Contains(GameObject obj)
        {
            bool result = attachedObjects.Contains(obj);

            if (result)
            {
                return(true);
            }

            Physical physical = obj as Physical;

            if (physical == null)
            {
                return(false);
            }
            foreach (GameObject attached in attachedObjects)
            {
                PhysicalAmalgam amalgam = attached as PhysicalAmalgam;
                if (amalgam == null)
                {
                    continue;
                }

                if (amalgam.Contains(physical))
                {
                    return(true);
                }
            }

            return(false);
        }
 public override void AssignPage(DescriptivePage page)
 {
     base.AssignPage(page);
     if (page != null)
     {
         amalgam = page.target as PhysicalAmalgam;
     }
 }
Example #3
0
        protected override object CreateInstance(Dictionary <string, object> context = null)
        {
            PhysicalAmalgam amalgam = null;

            try {
                amalgam = new PhysicalAmalgam(GenerateData(context));

                PostInstantiate(amalgam, context);
            } catch (Exception e) {
                Console.WriteLine($"ERROR: Could not instantiate PhysicalAmalgam from PhysicalAmalgamData: {e}");
            }

            return(amalgam);
        }
Example #4
0
        protected override void PostInstantiate(GameObject gameObject, Dictionary <string, object> context = null)
        {
            PhysicalAmalgam amalgam = gameObject as PhysicalAmalgam;

            foreach (SpawnEntry entry in parts)
            {
                GameObject[] parts = entry.Spawn(1);
                foreach (GameObject part in parts)
                {
                    Physical physicalPart = part as Physical;
                    if (physicalPart != null)
                    {
                        amalgam.AddPart(physicalPart);
                    }
                }
            }
        }
        protected virtual void DisplayBodyPart(GameObject obj, StackPanel stack)
        {
            Grid entry = GameManager.instance.GetResource <Grid>("AttachmentObjectEntry");

            if (entry == null)
            {
                throw new System.NullReferenceException("Resource 'AttachmentObjectEntry' could not be found");
            }
            stack.Children.Add(entry);

            TextBlock text = Utilities.FindNode <TextBlock>(entry, "Data1");

            if (text != null)
            {
                text.Inlines.Add(observer.Observe(obj, "name upper").span);
            }

            text = Utilities.FindNode <TextBlock>(entry, "Data2");
            if (text != null)
            {
                text.Inlines.Add(observer.Observe(obj, "weight partial").span);
            }

            text = Utilities.FindNode <TextBlock>(entry, "Data3");
            if (text != null)
            {
                text.Inlines.Add(observer.Observe(obj, "volume partial").span);
            }

            StackPanel      subData = Utilities.FindNode <StackPanel>(entry, "SubData");
            PhysicalAmalgam part    = obj as PhysicalAmalgam;

            if (part != null)
            {
                foreach (Physical child in part.GetParts())
                {
                    DisplayBodyPart(child, subData);
                }
            }

            if (subData.Children.Count == 0)
            {
                subData.Visibility = System.Windows.Visibility.Collapsed;
            }
        }