Exemplo n.º 1
0
        /// <summary>
        /// If the creature has meat or bones, creates resources
        /// which get released when the creature dies.
        /// </summary>
        public virtual void CreateMeatAndBones()
        {
            if (HasMeat)
            {
                ResourceLibrary.ResourceType type = Species + " " + ResourceLibrary.ResourceType.Meat;

                if (!ResourceLibrary.Resources.ContainsKey(type))
                {
                    ResourceLibrary.Add(new Resource(ResourceLibrary.GetMeat(Species))
                    {
                        Type      = type,
                        ShortName = type
                    });
                }

                Inventory.AddResource(new ResourceAmount(type, 1));
            }

            if (HasBones)
            {
                ResourceLibrary.ResourceType type = Species + " " + ResourceLibrary.ResourceType.Bones;

                if (!ResourceLibrary.Resources.ContainsKey(type))
                {
                    ResourceLibrary.Add(new Resource(ResourceLibrary.Resources[ResourceLibrary.ResourceType.Bones])
                    {
                        Type      = type,
                        ShortName = type
                    });
                }

                Inventory.AddResource(new ResourceAmount(type, 1));
            }

            if (HasCorpse)
            {
                ResourceLibrary.ResourceType type = AI.Stats.FullName + "'s " + "Corpse";

                if (!ResourceLibrary.Resources.ContainsKey(type))
                {
                    ResourceLibrary.Add(new Resource(ResourceLibrary.Resources["Corpse"])
                    {
                        Type      = type,
                        ShortName = type
                    });
                }

                Inventory.AddResource(new ResourceAmount(type, 1));
            }
        }
Exemplo n.º 2
0
        private void CreateGraphics()
        {
            Physics.AddChild(new Shadow(Manager));

            var animFile = Bonesnake ? ContentPaths.Entities.Animals.Snake.bonesnake_animation :
                           ContentPaths.Entities.Animals.Snake.snake_animation;

            var tailFile = Bonesnake ? ContentPaths.Entities.Animals.Snake.bonetail_animation :
                           ContentPaths.Entities.Animals.Snake.tail_animation;


            var sprite = CreateSprite(animFile, Manager, 0.0f);

            Tail = new List <TailSegment>();

            for (int i = 0; i < 10; ++i)
            {
                var tailPiece = CreateSprite(tailFile, Manager, 0.0f, false);

                Tail.Add(
                    new TailSegment()
                {
                    Sprite = Manager.RootComponent.AddChild(tailPiece) as Body,
                    Target = Physics.LocalTransform.Translation
                });


                tailPiece.AddChild(new Shadow(Manager));

                var inventory = tailPiece.AddChild(new Inventory(Manager, "Inventory", Physics.BoundingBox.Extents(), Physics.LocalBoundingBoxOffset)) as Inventory;
                inventory.SetFlag(Flag.ShouldSerialize, false);

                if (HasMeat)
                {
                    ResourceLibrary.ResourceType type = Species + " " + ResourceLibrary.ResourceType.Meat;

                    if (!ResourceLibrary.Resources.ContainsKey(type))
                    {
                        ResourceLibrary.Add(new Resource(ResourceLibrary.GetMeat(Species))
                        {
                            Type      = type,
                            ShortName = type
                        });
                    }

                    inventory.AddResource(new ResourceAmount(type, 1));
                }

                if (HasBones)
                {
                    ResourceLibrary.ResourceType type = Name + " " + ResourceLibrary.ResourceType.Bones;

                    if (!ResourceLibrary.Resources.ContainsKey(type))
                    {
                        ResourceLibrary.Add(new Resource(ResourceLibrary.Resources[ResourceLibrary.ResourceType.Bones])
                        {
                            Type      = type,
                            ShortName = type
                        });
                    }

                    inventory.AddResource(new ResourceAmount(type, 1));
                }
            }
        }