コード例 #1
0
        private void LoadCollisionComponent(GameEntity entity, CollisionComponentInfo info)
        {
            var comp = new CollisionComponent();

            entity.AddComponent(comp);
            comp.Loadinfo(info);
        }
コード例 #2
0
        public IComponentInfo Load(XElement node, Project project)
        {
            var component = new CollisionComponentInfo();

            foreach (var boxnode in node.Elements("Hitbox"))
            {
                var box = GetHitbox(boxnode);

                foreach (var groupnode in boxnode.Elements("Hits"))
                {
                    box.Hits.Add(groupnode.Value);
                }

                foreach (var groupnode in boxnode.Elements("Group"))
                {
                    box.Groups.Add(groupnode.Value);
                }

                foreach (var resistNode in boxnode.Elements("Resist"))
                {
                    var   resistName = resistNode.GetAttribute <string>("name");
                    float mult       = resistNode.GetAttribute <float>("multiply");
                    box.Resistance.Add(resistName, mult);
                }

                component.HitBoxes.Add(box);
            }

            component.Enabled = node.TryAttribute <bool>("Enabled");

            return(component);
        }
コード例 #3
0
        internal void Loadinfo(CollisionComponentInfo info)
        {
            Enabled = info.Enabled;

            foreach (var box in info.HitBoxes)
            {
                var coll = new CollisionBox(box);
                coll.SetParent(this);
                AddBox(coll);
            }
        }