示例#1
0
        public bool Translate(Scene?scene, TextureTranslationEventArgs e, out TextureResource resource)
        {
            var name = e.Name.ToLower();

            if (Resource.ContainsKey(name))
            {
                var translationFile = Resource[name];

                switch (Path.GetExtension(translationFile))
                {
                case ".png":
                    resource = new TextureResource(1, 1, TextureFormat.ARGB32, null, File.ReadAllBytes(translationFile));
                    return(true);

                case ".tex":
                    resource = TexUntil.LoadTexture(e.Name, File.ReadAllBytes(translationFile));
                    if (resource == null)
                    {
                        return(false);
                    }
                    return(true);

                default:
                    resource = null;
                    return(false);
                }
            }
            resource = null;
            return(false);
        }
示例#2
0
        public string ReadTextureEntry(ResourceEntry entry, XmlWriter resourceXML, string name)
        {
            TextureResource resource = new TextureResource();

            using (MemoryStream stream = new MemoryStream(entry.Data))
            {
                resource.Deserialize(entry.Version, stream, Endian);
            }

            string FetchedName = "";

            if (_TextureNames.ContainsKey(resource.NameHash))
            {
                FetchedName = _TextureNames[resource.NameHash];

                if (!string.IsNullOrEmpty(FetchedName))
                {
                    name = FetchedName;
                }
            }

            resourceXML.WriteElementString("File", name);

            // We lack the file hash in M3 and M1: DE. So we have to add it to the file.
            var game = GameStorage.Instance.GetSelectedGame();

            if (game.GameType == GamesEnumerator.MafiaI_DE || game.GameType == GamesEnumerator.MafiaIII)
            {
                resourceXML.WriteElementString("FileHash", resource.NameHash.ToString());
            }

            resourceXML.WriteElementString("HasMIP", resource.HasMIP.ToString());
            entry.Data = resource.Data;
            return(name);
        }
示例#3
0
        public static Resources.IResource Get(GameDatabase.TextureInfo textureObject)
        {
            TextureData textureData;

            if (iManagedTextures.TryGetValue(textureObject, out textureData))
            {
                if ((textureData.NativeId == -1) || (textureData.File == null))
                {
                    return(new Resources.ResourceDummy());
                }
                TextureResource textureResource;
                if (textureData.LoadedTextureResource == null || !textureData.LoadedTextureResource.IsAlive)
                {
                    textureResource = new TextureResource(textureData);
                    textureData.LoadedTextureResource = new WeakReference(textureResource);
                }
                else
                {
                    // Todo: Potential race condition. Hope we asap get .net 4 and thus WeakRef.TryGet... don't see another way to fix that if-else
                    textureResource = (TextureResource)textureData.LoadedTextureResource.Target;
                }
                return(new TextureReference(textureResource));
            }
            else
            {
                return(null);
            }
        }
示例#4
0
    private static IntPtr TextureLoaderLoad(IntPtr path, out int width, out int height, out int format)
    {
        var pathstr = Marshal.PtrToStringUni(path);

        // HACK
        var combinedPath = CombinePathForResource(currentLoadingEffectPath, pathstr);

        var res = new TextureResource();

        if (res.Load(combinedPath, pathstr, EffekseerSystem.Instance.assetBundle))
        {
            EffekseerSystem.Instance.textureList.Add(res);
            width  = res.texture.width;
            height = res.texture.height;
            switch (res.texture.format)
            {
            case TextureFormat.DXT1: format = 1; break;

            case TextureFormat.DXT5: format = 2; break;

            default: format = 0; break;
            }

            return(res.GetNativePtr());
        }
        width  = 0;
        height = 0;
        format = 0;
        return(IntPtr.Zero);
    }
示例#5
0
        public void Merge(TilePool pool, TileImportPolicy policy)
        {
            Dictionary <string, Tile> existingHashes = new Dictionary <string, Tile>();
            Dictionary <string, Tile> newHashes      = new Dictionary <string, Tile>();

            using (SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider()) {
                foreach (Tile tile in _tiles)
                {
                    TextureResource tileTex = Tiles.GetTileTexture(tile.Uid);
                    string          hash    = Convert.ToBase64String(sha1.ComputeHash(tileTex.RawData));
                    existingHashes[hash] = tile;
                }

                foreach (Tile tile in pool.Tiles)
                {
                    TextureResource tileTex = pool.Tiles.GetTileTexture(tile.Uid);
                    string          hash    = Convert.ToBase64String(sha1.ComputeHash(tileTex.RawData));

                    if (policy == TileImportPolicy.SourceUnique && newHashes.ContainsKey(hash))
                    {
                        continue;
                    }
                    else if (policy == TileImportPolicy.SetUnique && existingHashes.ContainsKey(hash))
                    {
                        continue;
                    }

                    Tile newTile = _tiles.Add(tileTex);

                    existingHashes[hash] = newTile;
                    newHashes[hash]      = newTile;
                }
            }
        }
示例#6
0
        private void CommandImportObject()
        {
            if (CommandCanImportObject())
            {
                using (ImportObject form = new ImportObject()) {
                    foreach (ObjectClass objClass in SelectedObjectPool.Objects)
                    {
                        form.ReservedNames.Add(objClass.Name);
                    }

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        TextureResource resource = TextureResourceBitmapExt.CreateTextureResource(form.SourceFile);
                        ObjectClass     objClass = new ObjectClass(form.ObjectName)
                        {
                            MaskBounds = new Rectangle(form.MaskLeft ?? 0, form.MaskTop ?? 0,
                                                       (form.MaskRight ?? 0) - (form.MaskLeft ?? 0), (form.MaskBottom ?? 0) - (form.MaskTop ?? 0)),
                            Origin = new Point(form.OriginX ?? 0, form.OriginY ?? 0),
                        };

                        SelectedObjectPool.AddObject(objClass);
                        objClass.Image = resource;

                        RefreshObjectPoolCollection();
                        OnSyncObjectPoolManager(EventArgs.Empty);
                    }
                }
            }
        }
示例#7
0
        public void CreateTextureResource(string name)
        {
            var             typeResource = typeList["Texture"];
            TextureResource resource     = new TextureResource();

            resource.HasMIP = 0;
            resource.SetEntryVersion(typeResource.GetSerializationVersion());
            resource.SetFileName(name);
            AddResource("Texture", BuildResourceTreeNode(name, resource));

            // Try and add the Mipmap only if it exists in the parent folder.
            string MippedTexture = "MIP_" + name;
            string MippedPath    = GetParentFolder() + "//" + MippedTexture;

            if (File.Exists(MippedPath))
            {
                // See if we can construct MipMap resource.
                var      MipMapTypeResource = typeList["Mipmap"];
                FileInfo MipInfo            = new FileInfo(MippedPath);
                CreateBaseResource("Mipmap", MipInfo);

                // Set 'HasMIP' because we have one now.
                resource.HasMIP = 1;
            }
        }
示例#8
0
        public Tile Add(TextureResource texture)
        {
            if (texture.Width != TileWidth || texture.Height != TileHeight)
            {
                throw new ArgumentException("Supplied texture does not have tile dimensions", "texture");
            }

            Tile tile = new PhysicalTile()
            {
                Pool = _pool
            };

            if (ShouldExpandTexture())
            {
                ExpandTexture();
            }

            TileCoord coord = _openLocations[_openLocations.Count - 1];

            _openLocations.RemoveAt(_openLocations.Count - 1);

            _tileSource.Set(texture, new Point(coord.X * TileWidth, coord.Y * TileHeight));
            _texturePool.Invalidate(_tileSource.Uid);

            _locations[tile.Uid] = coord;

            Add(tile);

            return(tile);
        }
示例#9
0
        protected TechGroup()
        {
            var thisType = this.GetType();
            var name     = thisType.Name;

            if (!name.StartsWith("TechGroup", StringComparison.Ordinal))
            {
                throw new Exception("TechGroup class name must start with \"TechGroup\": " + thisType.Name);
            }

            this.ShortId = name.Substring(startIndex: "TechGroup".Length);

            var protoTechGroup = typeof(TechGroup);
            var iconPath       = thisType.FullName
                                 // remove namespace of base class
                                 .Substring(protoTechGroup.FullName.Length - protoTechGroup.Name.Length);

            iconPath = iconPath.Substring(0, iconPath.Length - thisType.Name.Length) + "Group";

            var icon = new TextureResource("Technologies/" + iconPath.Replace('.', '/'));

            if (!Api.Shared.IsFileExists(icon))
            {
                Api.Logger.Warning("Icon not found: " + icon.FullPath + ", using default generic icon.");
                // icon not found - fallback to default texture
                icon = new TextureResource("Technologies/GenericGroupIcon.png");
            }

            this.Icon = icon;
        }
示例#10
0
        public ResourceEntry WriteMipmapEntry(ResourceEntry entry, XPathNodeIterator nodes, string sdsFolder, XmlNode descNode)
        {
            //texture data storage.
            MemoryStream    data = new MemoryStream();
            TextureResource resource;

            byte[] texData;

            //get xml stuff
            nodes.Current.MoveToNext();
            string file = nodes.Current.Value;

            nodes.Current.MoveToNext();
            entry.Version = Convert.ToUInt16(nodes.Current.Value);

            //read file data.
            using (BinaryReader reader = new BinaryReader(File.Open(sdsFolder + "/" + file, FileMode.Open)))
                texData = reader.ReadBytes((int)reader.BaseStream.Length);

            resource = new TextureResource(FNV64.Hash(file.Remove(0, 4)), 0, texData);
            resource.SerializeMIP(entry.Version, data, Endian.Little);

            //finish.
            descNode.InnerText = file.Remove(0, 4);
            entry.Data         = data.GetBuffer();
            return(entry);
        }
示例#11
0
            public override void RenderContent(RenderLayer renderContext, SpriteBatch spriteBatch)
            {
                Dictionary <string, Texture2D> brushClassOverlays = _form._brushClassOverlays;
                DynamicTileBrush brush = _form._brush;

                if (!brushClassOverlays.ContainsKey(brush.BrushClass.ClassName))
                {
                    System.Drawing.Bitmap overlayBitmap = null;
                    if (brush.BrushClass.ClassName == "Basic")
                    {
                        overlayBitmap = Properties.Resources.DynBrushBasic;
                    }
                    else if (brush.BrushClass.ClassName == "Extended")
                    {
                        overlayBitmap = Properties.Resources.DynBrushExtended;
                    }
                    else
                    {
                        return;
                    }

                    TextureResource overlayResource = TextureResourceBitmapExt.CreateTextureResource(overlayBitmap);
                    brushClassOverlays.Add(brush.BrushClass.ClassName, overlayResource.CreateTexture(spriteBatch.GraphicsDevice));
                }

                Texture2D overlay = brushClassOverlays[brush.BrushClass.ClassName];

                int width  = (int)(overlay.Width * renderContext.LevelGeometry.ZoomFactor * (brush.TileWidth / 16.0));
                int height = (int)(overlay.Height * renderContext.LevelGeometry.ZoomFactor * (brush.TileHeight / 16.0));

                Microsoft.Xna.Framework.Rectangle dstRect = new Microsoft.Xna.Framework.Rectangle(0, 0, width, height);
                spriteBatch.Draw(overlay, dstRect, new Microsoft.Xna.Framework.Color(1f, 1f, 1f, .5f));
            }
        private void OnTextureLoad(object sender, TextureTranslationEventArgs e)
        {
            string textureName = e.Name;

            if (lastFoundTexture != textureName)
            {
                lastFoundTexture = textureName;
                Logger.WriteLine(ResourceType.Textures, LogLevel.Minor, $"FindTexture::{textureName}");
            }

            var replacement = Memory.GetTexture(textureName);
            TextureResource resource = null;

            switch (replacement.TextureType)
            {
                case TextureType.PNG:
                    resource = new TextureResource(1, 1, TextureFormat.ARGB32, File.ReadAllBytes(replacement.FilePath));
                    break;
                case TextureType.TEX:
                    resource = TexUtils.ReadTexture(File.ReadAllBytes(replacement.FilePath), textureName);
                    break;
                case TextureType.None:
                default:
                    if (e.OriginalTexture != null)
                        Logger.DumpTexture(DumpType.TexSprites, e, true, CurrentLevel);
                    return;
            }

            if (lastLoadedTexture != textureName)
                Logger.WriteLine(ResourceType.Textures, $"Texture::{textureName}");
            lastLoadedTexture = textureName;

            e.Data = resource;
        }
示例#13
0
 public ImageButton(Vector2 size, TextureResource tex, Action <ImageButton> cbDown = null, Action <ImageButton> cbUp = null) : base("imagebutton", size)
 {
     Icon         = tex;
     MouseEnabled = true;
     callbackDown = cbDown;
     callbackUp   = cbUp;
 }
示例#14
0
        public ResourceEntry WriteTextureEntry(ResourceEntry entry, XPathNodeIterator nodes, string sdsFolder, XmlNode descNode)
        {
            //texture data storage.
            MemoryStream    data = new MemoryStream();
            TextureResource resource;

            byte[] texData;

            //read from xml.
            nodes.Current.MoveToNext();
            string file = nodes.Current.Value;

            nodes.Current.MoveToNext();
            byte hasMIP = Convert.ToByte(nodes.Current.Value);

            nodes.Current.MoveToNext();
            entry.Version = Convert.ToUInt16(nodes.Current.Value);

            //do main stuff
            texData  = File.ReadAllBytes(sdsFolder + "/" + file);
            resource = new TextureResource(FNV64.Hash(file), hasMIP, texData);

            //entry.SlotVramRequired = (uint)(texData.Length - 128);
            //if (hasMIP == 1)
            //{
            //    using (BinaryReader reader = new BinaryReader(File.Open(sdsFolder + "/MIP_" + file, FileMode.Open)))
            //        entry.SlotVramRequired += (uint)(reader.BaseStream.Length - 128);
            //}

            resource.Serialize(entry.Version, data, Endian.Little);
            descNode.InnerText = file;
            entry.Version      = Convert.ToUInt16(nodes.Current.Value);
            entry.Data         = data.ToArray();
            return(entry);
        }
示例#15
0
        public override void SetParameter(string name, TextureResource parameter, int index)
        {
            GL.GetError();

            GL.ActiveTexture(TextureUnit.Texture0 + index);

            if (parameter is GlUpdatableTexture)
            {
                ((GlUpdatableTexture)parameter).Bind(index);
            }
            else
            {
                ((GlTexture)parameter).Bind(index);
            }

            Uniform u = getUniform(name);

            if (u.GlHandle == -1)
            {
                return;
            }

            GL.Uniform1(u.GlHandle, index);

            ErrorCode r = GL.GetError();

            if (r != ErrorCode.NoError)
            {
                throw new Exception("Unable to set shader parameter: " + name);
            }
        }
示例#16
0
        protected ProtoQuest()
        {
            var thisType = this.GetType();
            var name     = thisType.Name;

            if (name.StartsWith("Quest"))
            {
                name = name.Substring("Quest".Length);
            }

            this.ShortId = name;

            var protoQuest = typeof(ProtoQuest);
            var iconPath   = thisType.FullName
                             // remove namespace of base class
                             .Substring(protoQuest.FullName.Length - protoQuest.Name.Length);

            var icon = new TextureResource("Quests/" + iconPath.Replace('.', '/'));

            if (!Api.Shared.IsFileExists(icon))
            {
                // TODO: restore this when we will implement the quest icons
                //Logger.Warning("Icon not found: " + icon.FullPath + ", using default generic icon.");
                // icon not found - fallback to default texture
                icon = new TextureResource("Quests/Unknown.png");
            }

            this.Icon = icon;
        }
示例#17
0
        public override void LoadResources()
        {
            // load icons
            iconsTexture = (TextureResource)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png", ref checkedOutResources, devIf);
            // ^need??
            xAxisIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:xAxis", ref checkedOutResources, devIf);
            yAxisIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:yAxis", ref checkedOutResources, devIf);
            zAxisIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:zAxis", ref checkedOutResources, devIf);
            tickIcon  = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:tick", ref checkedOutResources, devIf);
            crossIcon = (TextureResource.Icon)devIf.GetSharedResource("file://Media/UI/InViewIconsX16.png:areas:icon:cross", ref checkedOutResources, devIf);

            // create GUI items
            // TODO: Needs layout manager support
            AddItem(new GUIIcon(new Point(10, 10), new Size(16, 16), xAxisIcon, true, true));
            AddItem(new GUIIcon(new Point(32, 10), new Size(16, 16), yAxisIcon, true, true));
            AddItem(new GUIIcon(new Point(54, 10), new Size(16, 16), zAxisIcon, true, true));

            AddItem(LayoutManager.AlignItem(new GUIIcon(new Point(-48, -50),
                                                        new Size(16, 16), tickIcon, true, false),
                                            LayoutRules.Positioning.Far,
                                            LayoutRules.Positioning.Far),
                    null, null, OnTickClick);
            AddItem(LayoutManager.AlignItem(new GUIIcon(new Point(-32, -50),
                                                        new Size(16, 16), crossIcon, true, false),
                                            LayoutRules.Positioning.Far,
                                            LayoutRules.Positioning.Far));
        }
示例#18
0
    public PaletteColorPicker()
    {
        RobustXamlLoader.Load(this);
        IoCManager.InjectDependencies(this);

        _tex = _resourceCache.GetResource <TextureResource>("/Textures/Interface/Nano/button.svg.96dpi.png");

        var i = 0;

        foreach (var palette in _prototypeManager.EnumeratePrototypes <ColorPalettePrototype>())
        {
            Palettes.AddItem(palette.Name);
            Palettes.SetItemMetadata(i, palette); // ew
            i += 1;
        }

        Palettes.OnItemSelected += args =>
        {
            Palettes.SelectId(args.Id);
            SetupList();
        };

        Palettes.Select(0);
        SetupList();
    }
示例#19
0
        public Texture2D Resolve(Guid textureId)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("TextureCache");
            }

            if (_device == null || _sourcePool == null)
            {
                return(null);
            }

            Texture2D tex;

            if (_cache.TryGetValue(textureId, out tex) && tex != null)
            {
                return(tex);
            }

            TextureResource resource = _sourcePool.GetResource(textureId);

            if (resource != null)
            {
                tex = resource.CreateTexture(_device);
                _cache.Add(textureId, tex);
            }

            return(tex);
        }
示例#20
0
        protected override ITextureResource PrepareDefaultTexture(Type thisType)
        {
            var texturePath = GenerateTexturePath(thisType);

            textureActive = new TextureResource(texturePath + "Active");
            return(new TextureResource(texturePath));
        }
示例#21
0
 public ObjectClass(string name, TextureResource image)
     : this(name)
 {
     _image       = image;
     _imageBounds = image.Bounds;
     _maskBounds  = image.Bounds;
 }
示例#22
0
        public TextureMaterial(string textureFilename, string normalsFilename, bool useVertexNormals, bool receiveShadows)
        {
            ready        = true;
            UseTexture   = false;
            UseNormalMap = false;

            if (textureFilename != "")
            {
                textureResource = EngineBase.Manager.GetTexture(textureFilename);
                if (textureResource.Ready)
                {
                    UseTexture = true;
                }
                else
                {
                    ready = false;
                    return;
                }
            }

            if (normalsFilename != "")
            {
                normalsResource = EngineBase.Manager.GetTexture(normalsFilename);
                if (normalsResource.Ready)
                {
                    UseNormalMap = true;
                }
                else
                {
                    ready = false;
                    return;
                }
            }

            // defines that need to be enabled in the shader
            List <string> defines = new List <string>();

            if (UseTexture)
            {
                defines.Add("USE_COLOR_MAP");
            }
            if (UseNormalMap)
            {
                defines.Add("USE_NORMAL_MAP");
            }
            if (useVertexNormals)
            {
                defines.Add("USE_VERTEX_NORMALS");
            }
            if (receiveShadows)
            {
                defines.Add("USE_SHADOW_MAP");
            }

            shaderResource = EngineBase.Manager.GetShader("texture", defines);
            if (!shaderResource.Ready)
            {
                ready = false;
            }
        }
示例#23
0
        private TilePool LoadFile()
        {
            if (_fileStream == null)
            {
                return(null);
            }

            if (_fileStream.Position != 0)
            {
                _fileStream.Position = 0;
            }

            _localManager.Reset();

            TextureResource resource = TextureResourceBitmapExt.CreateTextureResource(_fileStream);

            TilePool.TileImportOptions options = new TilePool.TileImportOptions()
            {
                TileHeight    = (int)_numTileHeight.Value,
                TileWidth     = (int)_numTileWidth.Value,
                SpaceX        = (int)_numXSpacing.Value,
                SpaceY        = (int)_numYSpacing.Value,
                MarginX       = (int)_numXMargin.Value,
                MarginY       = (int)_numYMargin.Value,
                ImportPolicty = TileImportPolicy.SetUnique,
            };

            _previewPool      = _localManager.ImportPool(_textName.Text, resource, options);
            _originalResource = _previewPool.TileSource.Crop(_previewPool.TileSource.Bounds);

            if (_useTransColor)
            {
                SetTransparentColor();
            }

            // Update preview window

            if (_previewLayer != null)
            {
                _previewLayer.Dispose();
            }

            Model.TileSetLayer layer = new Model.TileSetLayer(_previewPool.Name, _previewPool);
            _previewLayer = new TileSetLayerPresenter(layer)
            {
                LevelGeometry = _layerControl.LevelGeometry,
            };

            _rootLayer.Layers.Clear();
            _rootLayer.Layers.Add(_previewLayer);

            // Update stats

            _countTilesHigh.Text   = ((_height + (int)_numYSpacing.Value) / ((int)_numTileHeight.Value + (int)_numYSpacing.Value + (int)_numYMargin.Value)).ToString();
            _countTilesWide.Text   = ((_width + (int)_numXSpacing.Value) / ((int)_numTileWidth.Value + (int)_numXSpacing.Value + (int)_numXMargin.Value)).ToString();
            _countUniqueTiles.Text = _previewPool.Count.ToString();

            return(_previewPool);
        }
示例#24
0
        protected sealed override void PrepareProtoWeaponRanged(
            out IEnumerable <IProtoItemAmmo> compatibleAmmoProtos,
            ref DamageDescription overrideDamageDescription)
        {
            this.CachedWeaponTextureResourceReady = this.WeaponReadyTextureResource;

            this.PrepareProtoWeaponBow(out compatibleAmmoProtos, ref overrideDamageDescription);
        }
示例#25
0
 public virtual void ClientSetupItemInHand(
     IComponentSkeleton skeletonRenderer,
     string attachmentName,
     TextureResource textureResource)
 {
     skeletonRenderer.SetAttachmentSprite(this.SlotNameItemInHand, attachmentName, textureResource);
     skeletonRenderer.SetAttachment(this.SlotNameItemInHand, attachmentName);
 }
示例#26
0
 public ImageButton(Vector2 size, string image, Action <ImageButton> cbDown = null, Action <ImageButton> cbUp = null) : base("imagebutton", size)
 {
     //ImageFilename = image;
     Icon         = EngineBase.Manager.GetTexture(image);
     MouseEnabled = true;
     callbackDown = cbDown;
     callbackUp   = cbUp;
 }
示例#27
0
文件: Squad.cs 项目: laiqiqi/Unity-8
    public void AddUnits(UnitType type, Vector3 location, int count, Allegiance allegiance)
    {
        if (count == 0)
        {
            return;
        }

        if (mSquadMembers == null)
        {
            mSquadMembers = new List <Unit>();
        }

        mAllegiance = allegiance;

        this.transform.position = location;

        GameObject unitPrefab = TextureResource.GetUnitPrefab(type, (allegiance == Allegiance.Rodelle));

        List <Vector3> randomPositions = this.RandomSectionLocations(count, kSquadMemberWidth * 1.5f);

        for (int i = 0; i < count; ++i)
        {
            // instantiate the unit from the prefab
            GameObject o = (GameObject)Instantiate(unitPrefab);
            Unit       u = (Unit)o.GetComponent <Unit>();
            u.Squad = this;
            mSquadMembers.Add(u);
            u.Allegiance = mAllegiance;

            // offset from squad center
            Vector3 memberPosition = this.transform.position;
            memberPosition      += randomPositions [i];
            u.transform.position = memberPosition;
        }

        float squadSpeed = UnitStats.GetStat(SquadLeader.UnitType, UnitStat.MovementSpeed);

        // Sets the speed of the squad to the speed of the squad leader
        for (int i = 0; i < mSquadMembers.Count; ++i)
        {
            // TODO refactor this process. Remove the public access to MoveSpeed and implement a better method of
            // modifying a unit's base stats
            mSquadMembers[i].MoveSpeed = squadSpeed;
        }

        if (SquadLeader.Allegiance == Allegiance.AI) // Reduce the sight range of armed enemy peasants
        {
            SquadLeader.SightRange = UnitStats.GetStat(UnitType.Peasant, UnitStat.SightRange);
        }

        float sightRadius = SquadLeader.SightRange;

        this.GetComponent <CircleCollider2D> ().radius            = 3;
        this.GetComponent <SpriteRenderer>().transform.localScale = new Vector3(sightRadius / 3, sightRadius / 3, 0f);

        this.SetDestination(this.RallyPoint);
        this.ShowSelector(false);
    }
示例#28
0
        public ResourceEntry ReadMipmapEntry(ResourceEntry entry, XmlWriter resourceXML, string name)
        {
            TextureResource resource = new TextureResource();

            resource.DeserializeMIP(entry.Version, new MemoryStream(entry.Data), Endian);
            resourceXML.WriteElementString("File", "MIP_" + name);
            entry.Data = resource.Data;
            return(entry);
        }
示例#29
0
        TextureResource <Info> CreateTextureResource(int slice)
        {
            var info = new Info()
            {
                Slice = slice, Width = FWidthIn[slice], Height = FHeightIn[slice]
            };

            return(TextureResource.Create(info, CreateTexture, UpdateTexture));
        }
示例#30
0
 public SkeletonSlotAttachment(
     string skeletonName,
     string attachmentName,
     TextureResource textureResource)
 {
     this.AttachmentName  = attachmentName;
     this.TextureResource = textureResource;
     this.SkeletonName    = skeletonName;
 }
示例#31
0
 public GUIIcon(Point origin, Size dimensions, TextureResource.Icon icon,
                bool highlight, bool enabled)
     : base(origin, dimensions, icon.Texture)
 {
     this.icon = icon;
     this.highlight = highlight;
     wantMouseOver = true;
     this.enabled = enabled;
 }
示例#32
0
        public void GivenTheCurrentSceneContainsATextureResourceNamedWithPath(string textureName, string path)
        {
            IDTFScene currentScene = ScenarioContext.Current.Get<IDTFScene>();

            TextureResource t1 = new TextureResource();
            t1.Name = textureName;
            t1.TexturePath = path;

            currentScene.TextureResources.Add(textureName, t1);
            ScenarioContext.Current.Set<TextureResource>(t1, textureName);
        }
示例#33
0
 private static IntPtr TextureLoaderLoad(IntPtr path)
 {
     var pathstr = Marshal.PtrToStringUni(path);
     var res = new TextureResource();
     if (res.Load(pathstr)) {
         EffekseerSystem.Instance.textureList.Add(res);
         return res.GetNativePtr();
     }
     return IntPtr.Zero;
 }
示例#34
0
 public GUIImage(Point origin, Size dimensions, TextureResource texture)
     : base(origin, dimensions)
 {
     this.texture = texture;
 }
示例#35
0
文件: Brush.cs 项目: Elof3/Treefrog
 public PatternBrush(TextureResource pattern)
     : this(pattern, 1.0)
 {
 }
示例#36
0
文件: Brush.cs 项目: Elof3/Treefrog
 public PatternBrush(TextureResource pattern, double opacity)
 {
     Pattern = pattern.Crop(pattern.Bounds);
     Opacity = opacity;
 }
示例#37
0
文件: Brush.cs 项目: Elof3/Treefrog
        private static TextureResource ConvertStipplePattern(bool[,] pattern, Color color)
        {
            int width = pattern.GetLength(0);
            int height = pattern.GetLength(1);

            TextureResource image = new TextureResource(width, height);
            for (int y = 0; y < height; y++)
                for (int x = 0; x < width; x++)
                    if (pattern[y, x])
                        image[y, x] = color;

            return image;
        }
        public override void Init(DeviceInterface devIf, SceneManager sManager)
        {
 	        base.Init(devIf, sManager);

            BuildGeometry();
            
            axisHelper.Init(devIf, sManager);
            rotAxisHelper.Init(devIf, sManager);

            List<ISharableResource> shared = new List<ISharableResource>();
            overlayTexRz = (TextureResource)devIf.GetSharedResource("file://media/ui/vis/overlay-1s.png", ref shared);

            ShaderHLSL shader;
            if (gProfile.SupportsShaderOverlay)
            {
                shader = new ShaderHLSL(gDevice, devIf.LocalSettings["Base.Path"] + @"shaders\cpu_dem.fx");
                shader.Effect.Technique = shader.Effect.GetTechnique("LitTextured");
                defaultShader = new ShaderInterface(shader);
            }
            /*shader = new ShaderHLSL(gDevice, devIf.LocalSettings["Base.Path"] + @"shaders\cpu_dem_hClr.fx");
            shader.Effect.Technique = shader.Effect.GetTechnique("CPU_DEM_HeightClr");
            hClrShader = new ShaderInterface(shader);*/

            shader = new ShaderHLSL(gDevice, devIf.LocalSettings["Base.Path"] + @"shaders\gpu_dem.fx");
            shader.Effect.Technique = shader.Effect.GetTechnique("Basic");
            sm3Shader = new ShaderInterface(shader);
            
            /*Shape shape = ShapeContentLoader.LoadShape(gDevice, NuGenDEMVis.Properties.Resource1.VerticalPointer_Shape);
            pointerEntity = new VerticalPointerEntity(shape, rDb.Layers[0], maxDataValue);
            pointerEntity.Init(devIf, sManager);
            sManager.AddEntity(pointerEntity);*/

            /*axisHelper.Init(devIf, sManager);
            sManager.AddEntity(axisHelper);

            SetChildren(new IWorldEntity[] { axisHelper, pointerEntity });*/

            //geom.RebuildDiffuseTextures(new HeightMapDEMSampler());
        }