AABB buttonBounds; //it is easy to store button bounds as an AABB public Button(TextureName image, float width, float height, Vector2 position, float scale, Scene scene, OnMouseHover mouseHoverEvent = null, OnMouseEnter mouseEnterEvent = null, OnMouseLeave mouseLeaveEvent = null) : base(image, position, scale, 0, null, true) { buttonBounds = new AABB(new Vector2(width / 2, height / 2), width, height); if (scene != null) { scene.AddUIElement(this); } if (mouseHoverEvent == null) { mH += DefaultHoverEvent; } else { mH += mouseHoverEvent; } if (mouseLeaveEvent == null) { mL += DefaultExitEvent; } else { mL += mouseLeaveEvent; } if (mouseEnterEvent == null) { mE += DefaultEnterEvent; } else { mE += mouseEnterEvent; } }
public static Texture2D GetTexture(TextureName textureName) { if (textureDictionary.Count == 0) { LoadTexture(); } return(textureDictionary[textureName]); }
public override void SetSilentValue(string propertyName, object value) { base.SetSilentValue(propertyName, value); if (propertyName == nameof(TextureName)) { TextureName.SetSilentValue((string)value); } }
public static Texture Find(TextureName texName) { TextureManager texMan = TextureManager.GetInstance(); return((Texture)texMan.BaseFind((DLink) new Texture { name = texName })); }
public static Texture getTexture(TextureName textureName) { if (textures.Count == 0) { LoadTextures(); } return textures[textureName]; }
public static Texture GetTexture(TextureName textureName) { if (textures.Count == 0) { LoadTextures(); } return(textures[textureName]); }
public static Texture GetTexture(TextureName name) { Texture tex = null; cachedTextures.TryGetValue(name, out tex); return(tex); }
public Texture2D GetTexture(TextureName textureName) { //make sure we're asking for a valid texture if (textureName < 0 || textureName >= TextureName.zMAX /*|| textureName == TextureName.NullImage*/) { return(null); //forgot to add the texture to the enum or to the asset list ? } return(textures[(int)textureName]); }
public static Texture Add(TextureName texName, string assetName) { TextureManager texMan = TextureManager.GetInstance(); Texture tex = (Texture)texMan.BaseAdd(); Debug.Assert(tex != null); tex.Set(texName, assetName); return(tex); }
public static Image Add(ImageName imgName, TextureName texName, float x, float y, float width, float height) { // Remove from Reserve, Add to Active ImageManager imageMan = ImageManager.GetInstance(); Image pImage = (Image)imageMan.BaseAdd(); Debug.Assert(pImage != null); pImage.Set(imgName, texName, x, y, width, height); return(pImage); }
public static Font Add(FontName fontName, int key, TextureName texName, float x, float y, float w, float h) { FontManager fontMan = FontManager.GetInstance(); Font font = (Font)fontMan.BaseAdd(); Debug.Assert(font != null); font.Set(fontName, key, texName, x, y, w, h); return(font); }
public Arm(TextureName image, Vector2 offset, float scale, float rotation, Player player) : base(image, offset, scale, rotation, player) { firstAngle = rotation; secondAngle = rotation; firstLength = GetSprite().CurrentTexture().width / 2; secondLength = firstLength; second = new GameObject(image, offset + new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation)) * firstLength, scale, secondAngle, this); position = offset; this.player = player; }
/// <inheritdoc /> public override int GetHashCode() { unchecked { var hashCode = (TextureName != null ? TextureName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TexturePath != null ? TexturePath.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Size.GetHashCode(); return(hashCode); } }
public void Set(FontName fontName, int key, TextureName textureName, float x, float y, float w, float h) { Debug.Assert(this.pAzulRect != null); this.name = fontName; this.pTexture = TextureManager.Find(textureName); Debug.Assert(pTexture != null); this.pAzulRect.Set(x, y, w, h); this.key = key; }
public void Set(TextureName textureName, string assetName) { this.name = textureName; this.assetName = assetName; Azul.Texture pTex = new Azul.Texture(assetName); if (pTex == null) { pTex = new Azul.Texture("HotPink.tga"); } this.pAzulTexture = pTex; }
public TextureAtlasEntry(TextureName name, Vector2 tLeft, Vector2 tRight, Vector2 bRight, Vector2 bLeft) { textureName = name; topLeft = tLeft; topRight = tRight; bottomRight = bRight; bottomLeft = bLeft; width = topRight.X - topLeft.X; height = bottomLeft.Y - topLeft.Y; }
public HungerHolder(TextureName image, Vector2 position, float scale, Scene scene) : base(image, position, scale, 0, null, false) { if (scene != null) { scene.AddUIElement(this); } new GameObject(image, Vector2.zero, 0.25f, 0, this); size = new Vector2(70, 45); hungerSize = size; pos = new Vector2(position.x - 30, position.y); }
public HoverableElement(Screen screen, Renderer renderer, Rectangle rect, TextureName background) { this.Renderer = renderer; this.Screen = screen; this.Rect = rect; this.Texture = background; this.HoverTexture = TextureName.BasicButtonHover; hovering = false; Highlight = true; this.Screen.renderableChildren.Add(this); this.Screen.hoverableChildren.Insert(0, this); isVisible = true; }
public Vector2[] GetTextureCoordinates(TextureName textureName) { Vector2[] result = null; if (textureAtlasEntries.ContainsKey(textureName)) { result = new Vector2[4]; result[0] = new Vector2(textureAtlasEntries[textureName].topLeft.X / width, textureAtlasEntries[textureName].topLeft.Y / height); result[1] = new Vector2(textureAtlasEntries[textureName].topRight.X / width, textureAtlasEntries[textureName].topRight.Y / height); result[2] = new Vector2(textureAtlasEntries[textureName].bottomRight.X / width, textureAtlasEntries[textureName].bottomRight.Y / height); result[3] = new Vector2(textureAtlasEntries[textureName].bottomLeft.X / width, textureAtlasEntries[textureName].bottomLeft.Y / height); } //If texture does not exist, default to error texture return(result); }
public virtual object Clone() { Geometry2D NewGeom = new Geometry2D(Name); NewGeom.HasCull = HasCull; NewGeom.TextureName = (string)TextureName.Clone(); NewGeom.PX = PX; NewGeom.PY = PY; NewGeom.SX = PX; NewGeom.SY = PY; NewGeom.TX = TX; NewGeom.TY = TY; NewGeom.TSX = TSX; NewGeom.TSY = TSY; NewGeom.Z = Z; return(NewGeom); }
public Player(TextureName fileName, Vector2 position, Scene scene, Collider collider) : base(fileName, position, 1, collider, 0.5f, 3f, 0f, 0f, scene, 1, true, false) { spriteManager = new Sprite(Sprite.GetFramesFromFolder("Player"), 30, 1, 23, this, RLColor.WHITE); spriteManager.Pause(); spriteManager.SetFrame(0); //player has 3 children. two eyes and the head holder eye1 = new Eye(new Vector2(-34, -21), 7, 0.14f); eye2 = new Eye(new Vector2(9, -19), eye1); AddChild(eye1); AddChild(eye2); // the head holder holds the head gameobject, the chicken (only visible when a chicken is sucked in), // and a gameobject called 'fix' (there was a weird black thing added to the head sprite when it was exported from adobe animate, this is just a strip of color that covers that black line for ez fix) headHolder = new GameObject(TextureName.Head, headOffset, 1, 0, this, false); headHolder.GetSprite().SetSort(0); head = new GameObject(TextureName.Head, Vector2.zero, 1, 0, headHolder); //might as well get a reference to the head sprite since it's animation is controlled through the player. headSprite = new Sprite(Sprite.GetFramesFromFolder("PlayerHead"), 30, 0, 9, head, RLColor.WHITE, true, 0); head.SetSprite(headSprite); headSprite.Pause(); fix = new GameObject(TextureName.HeadFix, Vector2.up * -150, 1, 0, head) { LocalScale = new Vector2(1, 3) //just learnt that you can do this. pretty cool huh? }; chicken = new GameObject(TextureName.CookedChicken, eatingOffset, 0.5f, 0, headHolder); chicken.GetSprite().SetSort(-1); chicken.SetDrawn(false); SortChildren(); headHolder.SortChildren(); LocalPosition = Vector2.one * 100; collider.SetCollisionLayer(CollisionLayer.Player); spriteManager.SetLayer(SpriteLayer.Midground); defaultIMass = iMass; //some parts of the hunger holder is controlled through the player h = new HungerHolder(TextureName.Xray, new Vector2(Game.screenWidth - 100, 130), 1, null); Game.GetCurrentScene().AddUIElement(h); }
float deathPercentDone = 0; //value used when player is vacuuming the chicken. when it reaches 100 the chicken is pulled toward the player public Chicken(TextureName fileName, Vector2 position, Player player, Sprite loadedSprite = null) : base(fileName, position, 0.5f, new Collider(-40, -55, 80, 110, CollisionLayer.Enemy), 0.5f, 0.5f, 1f, 0f, density: 1, isRotatable: false) { if (loadedSprite != null) { spriteManager = loadedSprite; } else { spriteManager = new Sprite(frames, 24, 1, 11, this, colour); } spriteManager.SetFrame(0); spriteManager.Pause(); spriteManager.SetLayer(SpriteLayer.Background); spriteManager.SetTint(colour); timer += (float)Game.globalRand.NextDouble(); this.player = player; }
public List <byte> Get() { List <byte> output = new List <byte>((int)Size + 4); output.AddRange(((Data4Bytes)Size).B); output.AddRange(((Data4Bytes)TextureNameLength).B); foreach (byte b in TextureName.ToArray()) { output.Add(b); } foreach (Data4Bytes d in Unknown) { output.AddRange(d.B); } output.AddRange(Unknown_Reserved); return(output); }
private void addStats(UnitType type, TextureName picture, int health, int attack, int defense, int attackSpeed, int moveSpeed, int range, int maxTargets) { Type = type; IsInSquad = false; SquadPosition = -1; MaxHealth = health; Attack = attack; Defense = defense; AttackSpeed = attackSpeed; MoveSpeed = moveSpeed; Range = range; MaxTargets = maxTargets; //get this from type in the future Picture = picture; Size = 7; Name = type.ToString(); Level = 1; }
public PhysicsObject(TextureName image, Vector2 position, float scale, Collider collider = null, float drag = 0, float angularDrag = 0, float restitution = 0, float rotation = 0, GameObject parent = null, float density = 1, bool isDynamic = true, bool isRotatable = true, bool isDrawn = true) : base(image, position, scale, rotation, parent, isDrawn) { hasPhysics = true; this.collider = collider; this.restitution = restitution; this.drag = drag; this.angularDrag = angularDrag; this.density = density; if (collider != null) { collider.SetConnectedPhysicsObject(this); //mass and inertia are set by the collider, using the physics object's density collider.GetMass(out mass, out inertia); //everything with a collider is added to the scene's collision manager //should probably have made it so that it was the scene that this object is a decendant of but that would have been more difficult Game.GetCurrentScene().GetCollisionManager().AddObject(this); } if (isDynamic) { iMass = 1 / mass; iInertia = 1 / inertia; } else { //if it isn't dynamic it also isn't rotatable isRotatable = false; //inverse mass being set to zero makes the physics calculations all work out mass = 0; iMass = 0; } if (!isRotatable) { //if it isn't rotatable inertia and inverse of inertia are set to zero. //inverse inertia being set to zero makes the physics calculations all work out inertia = 0; iInertia = 0; } }
//all constructors are just using this (so I don't have to rewrite the same thing a billion times) protected void Init(TextureName image, Vector2 position, float scale, float rotation, GameObject parent, bool isDrawn = true, SpriteLayer layer = SpriteLayer.Midground) { this.isDrawn = isDrawn; id = idCounter; idCounter++; spriteManager = new Sprite(Game.GetTextureFromName(image), this, RLColor.WHITE, 1, layer); if (parent != null) { parent.AddChild(this); } //position and scale will be zero if no values are given localTransform = Matrix3.GetTranslation(position) * Matrix3.GetRotateZ(rotation) * Matrix3.GetScale(Vector2.one * scale); this.position = position; this.rotation = rotation; this.scale = Vector2.one * scale; sortingOffset = spriteManager.CurrentTexture().height / 2 * scale; UpdateTransforms(); }
public void LoadTexture(string filename, TextureName name) { var texture = new TextureImage(); if (!Il.ilLoadImage(filename)) { throw new Exception("Cann't load texture image!"); } texture.Width = Il.ilGetInteger(Il.IL_IMAGE_WIDTH); texture.Height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT); texture.BitePerPixel = Il.ilGetInteger(Il.IL_IMAGE_BYTES_PER_PIXEL); texture.Image = Il.ilGetData(); Il.ilEnable(Il.IL_CONV_PAL); int type = Il.ilGetInteger(Il.IL_IMAGE_FORMAT); int imageId; Gl.glGenTextures(1, out imageId); texture.Id = imageId; Gl.glBindTexture(Gl.GL_TEXTURE_2D, imageId); Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, texture.BitePerPixel, texture.Width, texture.Height, type, Gl.GL_UNSIGNED_BYTE, texture.Image); //Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, texture.Width, texture.Height, 0, // texture.BitePerPixel == 24 ? Gl.GL_RGB : Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, // texture.Image); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR_MIPMAP_NEAREST); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR); TextureImages.Add(name, texture); Il.ilDeleteImages(1, ref imageId); }
/// <summary> /// Attempts to add a block at the specified position /// </summary> /// <param name="position">NOTE: Will need to determine that global position is within chunk</param> /// <returns></returns> public bool AddBlock(Vector3 globalPosition, AbstractBlock block) { if (TEMPTexture == null) { TEMPTexture = block.TEMPTexture; } //--------------TEMP------------------------------ block.OnBuildBuffersRequest += BuildBuffers; //------------------------------------------------- bool result = false; //NOTE: Will need to set the block's position here to ensure valid placement Vector3 localPosition = new Vector3(Math.Abs(Math.Abs(globalPosition.X) - Math.Abs(position.X)), globalPosition.Y, Math.Abs(Math.Abs(globalPosition.Z) - Math.Abs(position.Y))); // if(localPosition.X<blocks.GetLength(0) //NOTE: Validate position if ((int)localPosition.X >= 0 && (int)localPosition.Y >= 0 && (int)localPosition.Z >= 0 && (int)localPosition.X < blocks.GetLength(0) && (int)localPosition.Y < blocks.GetLength(1) && (int)localPosition.Z < blocks.GetLength(2)) { if (blocks[(int)localPosition.X, (int)localPosition.Y, (int)localPosition.Z] == null) { blocks[(int)localPosition.X, (int)localPosition.Y, (int)localPosition.Z] = block; block.Position = new Vector3(localPosition.X + position.X, localPosition.Y, localPosition.Z + position.Y); //NOTE: May need to move this to OnBlockAdded in chunkManager HideBlockNeighbourFaces((int)localPosition.X, (int)localPosition.Y, (int)localPosition.Z, blocks[(int)localPosition.X, (int)localPosition.Y, (int)localPosition.Z]); if (BlockAdded != null) { BlockAdded(position, (int)localPosition.X, (int)localPosition.Y, (int)localPosition.Z, blocks[(int)localPosition.X, (int)localPosition.Y, (int)localPosition.Z]); } result = true; } } return(result); }
public Texture2D GetTexture(TextureName textureName) { //make sure we're asking for a valid texture if (textureName < 0 || textureName >= TextureName.zMAX /*|| textureName == TextureName.NullImage*/) return null; //forgot to add the texture to the enum or to the asset list ? return textures[(int)textureName]; }
public GameObject(TextureName image) { Init(image, Vector2.zero, 1, 0, null, true); }
//scale is a float because It is best for x and y scaling to be of equal magnitude otherwise it can lead to some bugs, so i just decided to make it always start with a scale with equal magnitude public GameObject(TextureName image, Vector2 position, float scale, float rotation = 0, GameObject parent = null, bool isDrawn = true, SpriteLayer layer = SpriteLayer.Midground) { Init(image, position, scale, rotation, parent, isDrawn, layer); }
public void Add(TextureName name, string filePath) { textures.AddResource(name, filePath); }
//------------------------------------------// // 関数名 GetTexture // // Function name GetTexture // 機能 テクスチャの取得 // // Get the texture function // 引数 テクスチャの識別ナンバー // // Identification number of arguments texture // 戻り値 テクスチャデータ // // Returns the texture data //------------------------------------------// public Texture2D GetTexture(TextureName name) { // I examine whether the range if (name < 0 || name >= TextureName.MAX_TEX_NUM) { return null; } // Return null if none if (this.texture[(int)name] == null) { return null; } return this.texture[(int)name]; }