private Entity getEntity(ModelObjectGraphSimulator.Vertex v)
 {
     if (!entities.ContainsKey(v))
     {
         var ent = new Entity();
         ent.Mesh    = UtilityMeshes.CreateMeshWithText(0.4f, v.ModelObject.GetType().Name, TW.Graphics);
         entities[v] = ent;
         TW.Data.Get <Data>().OwnedEntities.Add(ent);
     }
     return(entities[v]);
 }
        public void initRendering()
        {
            text             = new TextRectangle();
            text.IsBillboard = true;
            plusBoxEnt       = new Entity();
            minBoxEnt        = new Entity();

            plusBoxEnt.Mesh = UtilityMeshes.CreateMeshWithText(0.5f, "+", TW.Graphics);
            minBoxEnt.Mesh  = UtilityMeshes.CreateMeshWithText(0.5f, "-", TW.Graphics);

            Update();
            Hide();
        }
        private Physical getPhysical(IHotbarItem item)
        {
            if (physicals.ContainsKey(item))
            {
                return(physicals[item]);
            }

            var physical = new Physical();

            physical.Mesh = UtilityMeshes.CreateMeshWithText(0.5f, item.Name, TW.Graphics);

            physicals[item] = physical;

            return(physical);
        }
示例#4
0
        public void FixMesh()
        {
            var text = "Wants: " + TraderPart.WantsAmount + " " + TraderPart.WantsType.Name + "\n"
                       + "You get: " + TraderPart.GivesAmount + " " + TraderPart.GivesType.Name;

            if (TraderPart.StoredResourcesCount < TraderPart.GivesAmount)
            {
                text += "\nOut of resources";
            }

            //text = "hello";


            Physical.Mesh         = UtilityMeshes.CreateMeshWithText(1, text, TW.Graphics);
            Physical.ObjectMatrix = Matrix.Translation(new Vector3(0, 1, 0));
        }
        public PrototypeObjectsFactory(IGameObjectsRepository repository)
        {
            this.repository = repository;

            TubeType = new ItemType()
            {
                Name = "Tube", Mesh = TW.Assets.LoadMesh("SkyMerchant/TubePart/TubePart")
            };
            CogType = new ItemType()
            {
                Name = "Cog", Mesh = TW.Assets.LoadMesh("SkyMerchant/Cogs/Cog01")
            };
            WoodType = new ItemType()
            {
                Name = "Wood", Mesh = UtilityMeshes.CreateMeshWithText(0.4f, "Wood", TW.Graphics)
            };
        }
        public void Show(Vector3 pos, Vector3 lookDir, Vector3 up)
        {
            Visible       = true;
            Position      = pos;
            lookDirection = lookDir;

            this.up = up;
            right   = -Vector3.Cross(up, lookDirection);
            up      = Vector3.Cross(lookDirection, up);

            foreach (var i in config.Items)
            {
                var color = new Color4(0.5f, 1, 0);
                if (provider.IsTargeted(i))
                {
                    color = new Color4(1, 0, 0);
                }

                var bb = getBoundingBox(i);

                if (!map.ContainsKey(i))
                {
                    var e = new Entity()
                    {
                        Mesh = UtilityMeshes.CreateMeshWithText(bb.GetSize().X * 0.5f, i.Name, TW.Graphics)
                               //Visible = false
                    };

                    entities.Add(e);

                    map[i] = e;
                }
                var ent = map[i];
                ent.WorldMatrix = Matrix.Translation(bb.GetCenter());
                ent.Visible     = true;
            }

            provider.Enabled = true;
        }