コード例 #1
0
        public EntitySpawnSelectButton(EntityPrototype entityTemplate, string templateName)
        {
            var spriteNameParam = entityTemplate.GetBaseSpriteParamaters().FirstOrDefault();
            var spriteName      = "";

            if (spriteNameParam != null)
            {
                spriteName = spriteNameParam.GetValue <string>();
            }
            var objectName = entityTemplate.Name;

            _associatedTemplate     = entityTemplate;
            _associatedTemplateName = templateName;

            _sprite = new Sprite(_resourceCache.GetSprite(spriteName));

            Font font = _resourceCache.GetResource <FontResource>(@"Fonts/CALIBRI.TTF");

            _name           = new TextSprite("Name", font);
            _name.FillColor = Color.Black;
            _name.Text      = objectName;

            DrawBackground = true;
            DrawBorder     = true;
        }
コード例 #2
0
        private void PreparePlacement(string templateName)
        {
            EntityPrototype prototype =
                IoCManager.Resolve <IPrototypeManager>().Index <EntityPrototype>(templateName);

            ComponentParameter spriteParam = prototype.GetBaseSpriteParamaters().FirstOrDefault();
            //Will break if states not ordered correctly.

            var    spriteName = spriteParam == null ? "" : spriteParam.GetValue <string>();
            Sprite sprite     = ResourceCache.GetSprite(spriteName);

            CurrentBaseSprite    = sprite;
            CurrentBaseSpriteKey = spriteName;
            CurrentPrototype     = prototype;

            IsActive = true;
        }
コード例 #3
0
        public EntitySpawnSelectButton(EntityPrototype entityTemplate, string templateName,
                                       IResourceCache resourceCache)
        {
            _resourceCache = resourceCache;

            var    spriteNameParam = entityTemplate.GetBaseSpriteParamaters().FirstOrDefault();
            string SpriteName      = "";

            if (spriteNameParam != null)
            {
                SpriteName = spriteNameParam.GetValue <string>();
            }
            string ObjectName = entityTemplate.Name;

            associatedTemplate     = entityTemplate;
            associatedTemplateName = templateName;

            objectSprite = _resourceCache.GetSprite(SpriteName);

            font       = _resourceCache.GetResource <FontResource>(@"Fonts/CALIBRI.TTF").Font;
            name       = new TextSprite("Label" + SpriteName, "Name", font);
            name.Color = Color4.Black;
            name.Text  = ObjectName;
        }
コード例 #4
0
        public EntitySpawnSelectButton(EntityPrototype entityTemplate, string templateName,
                                       IResourceManager resourceManager)
        {
            _resourceManager = resourceManager;

            var    spriteNameParam = entityTemplate.GetBaseSpriteParamaters().FirstOrDefault();
            string SpriteName      = "";

            if (spriteNameParam != null)
            {
                SpriteName = spriteNameParam.GetValue <string>();
            }
            string ObjectName = entityTemplate.Name;

            associatedTemplate     = entityTemplate;
            associatedTemplateName = templateName;

            objectSprite = _resourceManager.GetSprite(SpriteName);

            font       = _resourceManager.GetFont("CALIBRI");
            name       = new TextSprite("Label" + SpriteName, "Name", font);
            name.Color = Color.Black;
            name.Text  = ObjectName;
        }