public static CustomSprite CreateSpriteFromBitmap(CustomBitmap bitmap) { CustomSprite ret = new CustomSprite(); ret.Bitmap = bitmap; return(ret); }
public OxygenTank() : base(Recipe) { CustomSprite icon = BitmapRepository.CreateSpriteFromBitmap(BitmapRepository.OxygenTank); icon.Scaling = DefaultScale; Icon = icon; }
public GreenCoral() { CustomSprite icon = BitmapRepository.CreateSpriteFromBitmap(BitmapRepository.Plant); icon.Scaling = DefaultScale; Icon = icon; }
public static void CenterSprite(CustomSprite sprite) { sprite.Position = new TGCVector2( (Width - sprite.Bitmap.Width * sprite.Scaling.X) / 2, (Height - sprite.Bitmap.Height * sprite.Scaling.Y) / 2 ); }
public void Load(string exampleDir, CustomBitmap spriteSheet) { asteroidBitmap = spriteSheet; sprites = new List <CustomSprite>(); spriteSize = new Vector2(SpriteWidth, SpriteHeight); size = 1.0f; angle = 0.0f; CustomSprite newSprite; //Creo 64 sprites asignando distintos clipping rects a cada uno. for (var i = 0; i < 8; i++) { for (var j = 0; j < 8; j++) { newSprite = new CustomSprite(); newSprite.Bitmap = asteroidBitmap; newSprite.SrcRect = new Rectangle(j * (int)spriteSize.X, i * (int)spriteSize.Y, (int)spriteSize.X, (int)spriteSize.Y); newSprite.Scaling = new Vector2(size, size); newSprite.Rotation = angle; sprites.Add(newSprite); } } currentSprite = 0; GenerateRandomPosition(); }
public void Init(TgcD3dInput input) { var d3dDevice = D3DDevice.Instance.Device; drawer2D = new Drawer2D(); #region configurarSprites CustomSprite sprite = new CustomSprite(); sprite.Bitmap = new CustomBitmap(GameModel.mediaDir + "\\sprites\\mata.png", D3DDevice.Instance.Device); var textureSize = sprite.Bitmap.Size; sprite.Position = new TGCVector2(FastMath.Max((D3DDevice.Instance.Width - textureSize.Width) * 0.5f, 0), FastMath.Max((D3DDevice.Instance.Height - textureSize.Height) * 0.5f, 0)); sprites.Add(sprite); CustomSprite sprite2 = new CustomSprite(); sprite2.Bitmap = new CustomBitmap(GameModel.mediaDir + "\\sprites\\evita.png", D3DDevice.Instance.Device); sprite2.Position = new TGCVector2(FastMath.Max((D3DDevice.Instance.Width - textureSize.Width) * 0.5f, 0), FastMath.Max((D3DDevice.Instance.Height - textureSize.Height) * 0.5f, 0)); sprites.Add(sprite2); CustomSprite sprite3 = new CustomSprite(); sprite3.Bitmap = new CustomBitmap(GameModel.mediaDir + "\\sprites\\crea.png", D3DDevice.Instance.Device); sprite3.Position = new TGCVector2(FastMath.Max((D3DDevice.Instance.Width - textureSize.Width) * 0.5f, 0), FastMath.Max((D3DDevice.Instance.Height - textureSize.Height) * 0.5f, 0)); sprites.Add(sprite3); #endregion time = new Timer(500); time.Elapsed += OnTimedEvent; time.AutoReset = true; time.Enabled = true; }
public Fish() { CustomSprite icon = BitmapRepository.CreateSpriteFromBitmap(BitmapRepository.Fish); icon.Scaling = DefaultScale; Icon = icon; }
public GreenPotion() : base(_Recipe) { CustomSprite icon = BitmapRepository.CreateSpriteFromBitmap(BitmapRepository.GreenPotion); icon.Scaling = DefaultScale; Icon = icon; }
public void Load(CustomBitmap spriteBitmap) { misilBitmap = spriteBitmap; sprite = new CustomSprite(); sprite.Bitmap = misilBitmap; }
protected override void UpdateMeshData(bool forceUpdate = false) { if (_meshRenderer == null || _meshFilter == null || IsPartOfStaticBatch) return; if (GameSpriteRenderer != null && (GameSpriteRenderer != _oldGameSpriteRenderer || forceUpdate || (_oldUnitySprite != null && _oldUnitySprite.sprite != null && _oldUnitySprite.sprite != Sprite) || (_oldCustomSprite != null && _oldCustomSprite.Sprite != null && _oldCustomSprite.Sprite != Sprite))) { _oldGameSpriteRenderer = GameSpriteRenderer; _oldCustomSprite = GameSpriteRenderer.GetComponent<CustomSprite>(); if (_oldCustomSprite != null) { Sprite = _oldCustomSprite.Sprite; } else { _oldUnitySprite = GameSpriteRenderer.GetComponent<SpriteRenderer>(); if (_oldUnitySprite != null) Sprite = _oldUnitySprite.sprite; } Material.EnableKeyword("NORMAL_TEXCOORD"); } if (_oldSecondaryColor != AdditiveColor || forceUpdate) { UpdateSecondaryColor(); _isMeshDirty = true; _oldSecondaryColor = AdditiveColor; } base.UpdateMeshData(forceUpdate); }
public PrincipalMenu(Subnautica gameInstance) : base() { input = gameInstance.Input; this.gameInstance = gameInstance; bitmapSlotBackground = new CustomBitmap(Game.Default.MediaDirectory + "craftingSlotBackground.jpg", D3DDevice.Instance.Device); background = new CustomSprite(Game.Default.MediaDirectory + "blackSquare.jpg"); background.Color = Color.FromArgb(80, 0, 0, 0); // para la transparencia background.SrcRect = new Rectangle(0, 0, D3DDevice.Instance.Width, D3DDevice.Instance.Height); background.Position = TGCVector2.Zero; wasdSprite = new CustomSprite(gameInstance.MediaDir + "Sprites//WASD.png"); wasdSprite.SrcRect = new Rectangle(0, 0, D3DDevice.Instance.Width, D3DDevice.Instance.Height); wasdSprite.Position = new TGCVector2(D3DDevice.Instance.Width / 8, D3DDevice.Instance.Height / 2.5f); escISprite = new CustomSprite(gameInstance.MediaDir + "Sprites//EscI.png"); escISprite.SrcRect = new Rectangle(0, 0, D3DDevice.Instance.Width, D3DDevice.Instance.Height); escISprite.Position = new TGCVector2(D3DDevice.Instance.Width / 2.7f, D3DDevice.Instance.Height / 2.5f); mouseSprite = new CustomSprite(gameInstance.MediaDir + "Sprites//Mouse.png"); mouseSprite.SrcRect = new Rectangle(0, 0, D3DDevice.Instance.Width, D3DDevice.Instance.Height); mouseSprite.Position = new TGCVector2(D3DDevice.Instance.Width / 1.5f, D3DDevice.Instance.Height / 2f); titleText = new TgcText2D(); titleText.Text = "Tgcito se va de buceo"; titleText.changeFont(new Font("TimesNewRoman", 50, FontStyle.Bold)); titleText.Align = TgcText2D.TextAlign.CENTER; titleText.Position = new Point(0, D3DDevice.Instance.Height / 6); titleText.Color = Color.AntiqueWhite; UpdateSlotDisplay(); }
public override void Init() { drawer2D = new Drawer2D(); //Crear Sprite sprite = new CustomSprite(); sprite.Bitmap = new CustomBitmap(MediaDir + "\\Texturas\\LogoTGC.png", D3DDevice.Instance.Device); //Ubicar centrado en la pantalla var textureSize = sprite.Bitmap.Size; centerScreen = new TGCVector2(FastMath.Max(D3DDevice.Instance.Width / 2 - textureSize.Width / 2, 0), FastMath.Max(D3DDevice.Instance.Height / 2 - textureSize.Height / 2, 0)); //Calculo el centro de la imagen. centroSprite = new TGCVector2(textureSize.Width / 2, textureSize.Height / 2); //Rotaciones animadas iniciales. rotationAnimateFrameDepend = TGCMatrix.Identity; rotationAnimateOneSec = TGCMatrix.Identity; rotationAnimate = TGCMatrix.Identity; //tiempo acumulado acumlatedTime = 0f; //Camara estatica (es igual que definir un view matrix en cada render) Camara.SetCamera(new TGCVector3(0, 0, -10), TGCVector3.Empty); }
private void CenterIconToCurrentBubble(CustomSprite icon) { icon.Position = bubble.Position + new TGCVector2( (bubble.Bitmap.Width * bubble.Scaling.X - icon.Bitmap.Width * icon.Scaling.X) / 2, (bubble.Bitmap.Height * bubble.Scaling.Y - icon.Bitmap.Height * icon.Scaling.Y) / 2 ); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="obj">The underlying in-game object.</param> /// <param name="tilePosition">The object's tile position in the current location (if applicable).</param> /// <param name="reflection">Simplifies access to private game code.</param> /// <param name="customFarming">Handles the logic for integrating with the Custom Farming Redux mod.</param> public CustomFarmingObjectTarget(Object obj, Vector2?tilePosition, IReflectionHelper reflection, CustomFarmingReduxIntegration customFarming) : base(obj, tilePosition, reflection) { this.CustomSprite = customFarming.IsLoaded ? customFarming.GetTexture(obj) : null; }
public override void OnInspectorGUI() { m_target = (CustomSprite)target; GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); m_target.customPixelVector = EditorGUILayout.Vector2Field("", m_target.customPixelVector); EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Custom Pixel", GUILayout.Width(90), GUILayout.Height(25))) { m_target.CustomPixel(); } GUILayout.Space(10); if (GUILayout.Button("Make Pixel Perfect")) { m_target.PixelPerfect(); } }
/// <summary> /// Initialise les données avec la durée de l'état. Les effets d'actualisation, d'expiration ou encore l'image /// de l'état sont optionnels. Un objet supplémentaire peut être passé pour stocker des informations. /// </summary> /// <param name="maxMs"> Le temps écoulé en millisecondes </param> /// <param name="effect"> L'effet d'actualisation </param> /// <param name="expiringEffect"> L'effet d'expiration </param> /// <param name="sprite"> L'image de l'effet </param> public StateData(int maxMs, Action <ControlledActor, int, object> effect = null, Action <ControlledActor, object> expiringEffect = null, CustomSprite sprite = null) { Effect = effect; MaxMs = maxMs; ExpiringEffect = expiringEffect; Sprite = sprite; }
private void InitDarknessCover() { darknessCover = BitmapRepository.CreateSpriteFromBitmap(BitmapRepository.BlackRectangle); Screen.FitSpriteToScreen(darknessCover); darknessCover.Color = Color.FromArgb(0, 0, 0, 0); }
public InfinityGauntlet() : base(Recipe, CreateMesh()) { CustomSprite icon = BitmapRepository.CreateSpriteFromBitmap(BitmapRepository.InfinityGauntlet); icon.Scaling = DefaultScale; Icon = icon; Mesh.Scale = new TGCVector3(.035f, .035f, .035f); }
public static void FitSpriteToScreen(CustomSprite sprite) { sprite.Scaling = new TGCVector2( (float)Width / sprite.Bitmap.Width, (float)Height / sprite.Bitmap.Height ); sprite.Position = new TGCVector2(0, 0); }
public bool isCollisionWithSprite(CustomSprite sprite) { if (sprite.Collision(this)) { return(true); } return(false); }
public CharacterSelect(GameModel gameModel, MyAbstractions.Tgc3dSound init) { this.gameModel = gameModel; this.init = init; this.init.play(true); this.planes.Add(new Plane(new TGCVector3(-90, 0, -90), new TGCVector3(90, 0, 90), new TGCVector3(0, 1, 0), "Otros\\Paredes\\2.jpg", 1, 1)); this.planes.Add(new Plane(new TGCVector3(-90, 0, -90), new TGCVector3(-90, 50, 90), new TGCVector3(1, 0, 0), "Otros\\Paredes\\1.jpg", 1, 1)); this.planes.Add(new Plane(new TGCVector3(90, 0, -90), new TGCVector3(90, 50, 90), new TGCVector3(-1, 0, 0), "Otros\\Paredes\\4.jpg", 1, 1)); this.planes.Add(new Plane(new TGCVector3(-90, 0, -90), new TGCVector3(90, 50, -90), new TGCVector3(0, 0, 1), "Otros\\Paredes\\3.jpg", 1, 1)); this.gameModel.Camara = new ThirdPersonCamera(new TGCVector3(0, 0, 0), 100f, 150f); this.soundManager = new SoundsManager(); var auto1 = new Van(new TGCVector3(0f, 0f, 0f), soundManager); auto1.matrixs.SetScalation(TGCMatrix.Scaling(0.2f, 0.2f, 0.2f)); auto1.Transform(); this.soundManager = new SoundsManager(); var auto2 = new Car(new TGCVector3(0f, 0f, 0f), soundManager); auto2.matrixs.SetScalation(TGCMatrix.Scaling(0.3f, 0.3f, 0.3f)); auto2.Transform(); this.soundManager = new SoundsManager(); var auto3 = new Hummer(new TGCVector3(0f, 0f, 0f), soundManager); auto3.matrixs.SetScalation(TGCMatrix.Scaling(0.25f, 0.25f, 0.25f)); auto3.Transform(); autos = new List <Vehicle> { auto1, auto2, auto3 }; selectedCar = auto1; CarsCount = autos.Count - 1; var deviceWidth = D3DDevice.Instance.Width; var deviceHeight = D3DDevice.Instance.Height; choose = new CustomSprite(); choose.Bitmap = new CustomBitmap(MediaDir + "GUI\\Menu\\choose.png", D3DDevice.Instance.Device); choose.Position = new TGCVector2((deviceWidth / 2f) - choose.Bitmap.Width / 2, deviceHeight * 0.6f); rightArrow = new CustomSprite(); rightArrow.Bitmap = new CustomBitmap(MediaDir + "GUI\\Menu\\right-arrow.png", D3DDevice.Instance.Device); rightArrow.Position = new TGCVector2(deviceWidth / 2 + rightArrow.Bitmap.Width * 3 / 4, deviceHeight / 2 - rightArrow.Bitmap.Height * 0.2f); rightArrow.Scaling = new TGCVector2(0.2f, 0.2f); leftArrow = new CustomSprite(); leftArrow.Bitmap = new CustomBitmap(MediaDir + "GUI\\Menu\\right-arrow.png", D3DDevice.Instance.Device); leftArrow.Rotation = FastMath.PI; leftArrow.Position = new TGCVector2(deviceWidth / 2 - leftArrow.Bitmap.Width * 3 / 4, deviceHeight / 2); leftArrow.Scaling = new TGCVector2(0.2f, 0.2f); }
private TGCVector2 GetScaleForSpriteByPixels(CustomSprite sprite, int xPixels, int yPixels) { float pixelWidth = sprite.Bitmap.Width; float pixelHeight = sprite.Bitmap.Height; float xScale = xPixels / pixelWidth; float yScale = yPixels / pixelHeight; return(new TGCVector2(xScale, yScale)); }
/// <summary> /// Draw a preloaded <c>CustomSprite</c> on the screen where a specified entity is. /// </summary> /// <param name="entity">Instance of <c>Entity</c> to mark</param> /// <param name="spr">Preloaded <c>CustomSprite</c> to mark the entity with</param> /// <param name="color">Force use of specified <c>Color</c></param> public static void markEntityOnScreen(Entity entity, CustomSprite spr, Color?color = null) { // get the position of the entity on screen & update the screen position of the sprite PointF screenPos = Screen.WorldToScreen(entity.Position); spr.Position = screenPos; // update screen position of sprite spr.Color = color ?? spr.Color; // update sprite color if needed; if null, keep original color spr.Draw(); }
public GameplayScene(GameState gameState) : base() { this.GameState = gameState; InitDialogBox(); InitStatsIndicator(); InitAim(); InitHand(); cursor = aim; }
private void Awake() { audioSource = gameObject.GetComponent <AudioSource>(); spriteRenderer = GetComponent <SpriteRenderer>(); rigidbody2D = gameObject.GetComponent <Rigidbody2D>(); animator = gameObject.GetComponent <Animator>(); sprite = gameObject.GetComponent <CustomSprite>(); maxHealth = health; }
/// <summary> /// Initialise le powerup avec sa position et son sprite associé. /// Lui donne également sa collision lui permettant d'être ramassé. /// </summary> /// <param name="position"> la position du powerup </param> /// <param name="sprite"> Le sprite du powerup </param> protected Powerup(Point position, CustomSprite sprite) : base(position) { SetCollision(new ActorCollision(this, Hitbox, HitboxType.Immaterial, actor => { var player = actor as PlayerCharacter; if (player != null && player.LootPowerup(this)) { Kill(); } })); SpriteHandler = new SpriteHandler(this, sprite); }
public Playing(GameModel gameModel, Vehicle car) { this.gameModel = gameModel; drawer = new Drawer2D(); velocimeter = new CustomSprite(); velocimeter.Bitmap = new CustomBitmap(MediaDir + "GUI\\HUB\\Velocimetro\\VelocimetroSinFlecha.png", D3DDevice.Instance.Device); velocimeter.Position = new TGCVector2(D3DDevice.Instance.Width * 0.84f, D3DDevice.Instance.Height * 0.70f); velocimeter.Scaling = new TGCVector2(0.2f, 0.2f); arrowVelocimeter = new CustomSprite(); arrowVelocimeter.Bitmap = new CustomBitmap(MediaDir + "GUI\\HUB\\Velocimetro\\Flecha.png", D3DDevice.Instance.Device); arrowVelocimeter.Position = new TGCVector2(D3DDevice.Instance.Width * 0.915f, D3DDevice.Instance.Height * 0.85f); arrowVelocimeter.Scaling = new TGCVector2(0.2f, 0.2f); arrowVelocimeter.RotationCenter = new TGCVector2(0, arrowVelocimeter.Bitmap.Height / 8); arrowVelocimeter.Rotation = -FastMath.PI; barOfLifeGreen = new CustomSprite(); barOfLifeGreen.Bitmap = new CustomBitmap(MediaDir + "GUI\\HUB\\BarraDeVida\\1.jpg", D3DDevice.Instance.Device); barOfLifeGreen.Position = new TGCVector2(D3DDevice.Instance.Width * 0.80f, D3DDevice.Instance.Height * 0.95f); barOfLifeGreen.Scaling = new TGCVector2(0.05f, 0.05f); barOfLifeRed = new CustomSprite(); barOfLifeRed.Bitmap = new CustomBitmap(MediaDir + "GUI\\HUB\\BarraDeVida\\2.jpg", D3DDevice.Instance.Device); barOfLifeRed.Position = new TGCVector2(D3DDevice.Instance.Width * 0.80f, D3DDevice.Instance.Height * 0.95f); barOfLifeRed.Scaling = new TGCVector2(0.07f, 0.05f); this.camaraInterna = new ThirdPersonCamera(camaraDesplazamiento, 0.8f, -33); //this.camaraManagement = new CamaraEnTerceraPersona(camaraDesplazamiento, 3f, -50); this.gameModel.Camara = camaraInterna; //this.auto = new Van(new TGCVector3(-60f, 0f, 0f), new SoundsManager()); this.auto = car; auto.ResetScale(); //this.auto.mesh.D3dMesh.ComputeNormals(); listener = this.auto.mesh.clone("clon"); this.gameModel.DirectSound.ListenerTracking = listener; Scene.GetInstance().SetVehiculo(this.auto); this.AI = new ArtificialIntelligence(new TGCVector3(70f, 0f, 0f), new SoundsManager()); Scene.GetInstance().AI = this.AI; Scene.GetInstance().SetCamera(camaraInterna); this.auto.SoundsManager.AddSound(this.auto.GetPosition(), 50f, -500, "BackgroundMusic\\Burn.wav", "YouCouldBeMine", false); this.auto.SoundsManager.GetSound("YouCouldBeMine").play(true); /*var aspectRatio = D3DDevice.Instance.AspectRatio; * TGCMatrix view = TGCMatrix.LookAtLH(gameModel.Camara.Position, gameModel.Camara.LookAt, gameModel.Camara.UpVector); * TGCMatrix proj = TGCMatrix.PerspectiveFovLH(Geometry.DegreeToRadian(360), aspectRatio, 0, 1); * this.gameModel.Frustum.updateVolume(view, proj); * D3DDevice.Instance.Device.Transform.View = view; * D3DDevice.Instance.Device.Transform.Projection = proj; */ this.Update(); }
private void InitBlackRectangle() { spriteBlackRectangle = BitmapRepository.CreateSpriteFromBitmap(BitmapRepository.BlackRectangle); spriteBlackRectangle.Color = Color.FromArgb(188, 0, 0, 0); spriteBlackRectangle.Scaling = new TGCVector2(1, .1f); Screen.CenterSprite(spriteBlackRectangle); spriteBlackRectangle.Position = new TGCVector2( spriteBlackRectangle.Position.X, Screen.Height * (3f / 4) ); }
public void Init(TgcD3dInput input) { var d3dDevice = D3DDevice.Instance.Device; drawer2D = new Drawer2D(); #region configurarSprites opciones.Bitmap = new CustomBitmap(GameModel.mediaDir + "\\sprites\\opciones.png", D3DDevice.Instance.Device); var textureSize = opciones.Bitmap.Size; opciones.Position = new TGCVector2(FastMath.Max((D3DDevice.Instance.Width - textureSize.Width) * 0.5f, 0), FastMath.Max((D3DDevice.Instance.Height - textureSize.Height) * 0.5f, 0)); CustomSprite normal = new CustomSprite(); normal.Bitmap = new CustomBitmap(GameModel.mediaDir + "\\sprites\\0_normal.png", D3DDevice.Instance.Device); normal.Position = opciones.Position; escenas.Add(normal); CustomSprite picante = new CustomSprite(); picante.Bitmap = new CustomBitmap(GameModel.mediaDir + "\\sprites\\0_picante.png", D3DDevice.Instance.Device); picante.Position = opciones.Position; escenas.Add(picante); CustomSprite helada = new CustomSprite(); helada.Bitmap = new CustomBitmap(GameModel.mediaDir + "\\sprites\\0_helado.png", D3DDevice.Instance.Device); helada.Position = opciones.Position; escenas.Add(helada); CustomSprite glow = new CustomSprite(); glow.Bitmap = new CustomBitmap(GameModel.mediaDir + "\\sprites\\0_noche.png", D3DDevice.Instance.Device); glow.Position = opciones.Position; escenas.Add(glow); CustomSprite god = new CustomSprite(); god.Bitmap = new CustomBitmap(GameModel.mediaDir + "\\sprites\\0_god.png", D3DDevice.Instance.Device); god.Position = opciones.Position; escenas.Add(god); CustomSprite on1 = new CustomSprite(); on1.Bitmap = new CustomBitmap(GameModel.mediaDir + "\\sprites\\1_on.png", D3DDevice.Instance.Device); on1.Position = opciones.Position; musicas.Add(on1); CustomSprite off1 = new CustomSprite(); off1.Bitmap = new CustomBitmap(GameModel.mediaDir + "\\sprites\\1_off.png", D3DDevice.Instance.Device); off1.Position = opciones.Position; musicas.Add(off1); #endregion #region inicializarTiempo time = new Timer(500); time.Elapsed += OnTimedEvent; time.AutoReset = true; time.Enabled = true; #endregion }
public Button(String Name, TgcD3dInput Input, CustomBitmap normal, CustomBitmap mouseover, Action Callback, FontFamily fontFamily) : base(Input) { this.nombre = Name; this.sprite_normal = normal; this.sprite_mouseover = mouseover; this.current_sprite = new CustomSprite(); this.current_sprite.Bitmap = sprite_normal; this.current_sprite.Scaling = new Vector2(0.5f, 0.5f); this.Callback = Callback; drawText = new TgcText2D(); drawText.Align = TgcText2D.TextAlign.LEFT; drawText.changeFont(new Font(fontFamily, 25, FontStyle.Regular)); }
private void RenderJugadoresMapa(List <Jugador> jugadores, CustomSprite punto) { foreach (Jugador jugador in jugadores) { Vector2 mapPosition = this.GetMapPosition(jugador.Position, this.mapa.Bitmap.Size, this.partido.Cancha.Size); //El 5 es porque en el x la imagen del a foto incluye mucho pasto fuera de las lineas float pX = this.mapa.Position.X - 5 + (this.mapa.Bitmap.Size.Width / 2) + mapPosition.X; float pZ = this.mapa.Position.Y + (this.mapa.Bitmap.Size.Height / 2) - mapPosition.Y; punto.Position = new Vector2(pX, pZ); drawer2D.DrawSprite(punto); } }