public PlayerWeapon(List<DrawableObjectAbstract> pipeline, CharacterAbstract character, GameTexture animation, Vector2 gunHandle, AmmoTypeEnum ammoType, int clipSize) : base(pipeline, character, animation, gunHandle, ammoType, clipSize) { laserImage_ = TextureMap.fetchTexture(TARGET_TEXTURE_NAME); weaponFired_ = false; }
public Texture2D GetTexture(GameTexture Texture) { if (!_textures.ContainsKey(Texture)) _textures.Add(Texture, Texture2D.FromStream(_device, File.Open((string.Format("Content\\{0}.png", Texture)), FileMode.Open))); return _textures[Texture]; }
/// <summary> /// Constructor determines whether PC or Xbox 360 and initializes /// variables accordingly. /// /// For PC, this means creating the controller and trying to get a /// storage device. /// /// For the Xbox 360, we don't need to do much as we rely on update() /// logic to determine active controller and storage device. /// </summary> /// <param name="engine"></param> public EngineStateStart(Engine engine) : base(engine) { m_engine = engine; m_logoImage = new GameTexture(@"Sprites\TitleScreen"); #if !XBOX { Settings settings = Settings.getInstance(); if (Settings.getInstance().IsUsingMouse) { m_engine.Controls = new PCControllerInput(m_engine); settings.CurrentPlayer = PlayerIndex.One; TEXT_MESSAGE = "Press " + m_engine.Controls.getControlName(InputsEnum.CONFIRM_BUTTON).ToUpper() + " to Continue"; } else { m_engine.Controls = new X360ControllerInput(m_engine, PlayerIndex.One); settings.CurrentPlayer = PlayerIndex.One; TEXT_MESSAGE = "Press " + m_engine.Controls.getControlName(InputsEnum.CONFIRM_BUTTON).ToUpper() + " to Continue"; } prepareStorageDevice(); m_returnFlag = true; } #else { m_engine.Controls = null; // reset controls if they are coming back to this m_returnFlag = false; } #endif }
/// <summary> /// Create a HeadsUpDisplayObject with the specified texture, position, direction, and depth. /// </summary> /// <param name="pipeline">Drawing pipeline in which to register the object</param> /// <param name="texture">GameTexture for this HeadsUpDisplayObject</param> /// <param name="position">Position as a Vector relative to the top left corner</param> /// <param name="direction">Direction of the HeadsUpDisplayObject as a Vector</param> /// <param name="depth">Drawing depth of the object</param> public HeadsUpDisplayObjectAbstract(List<DrawableObjectAbstract> pipeline, GameTexture texture, Vector2 position, Vector2 direction, float depth) : base(pipeline, position, direction, depth) { modified_ = false; newValue_ = 0; texture_ = texture; }
public Grenade(List<DrawableObjectAbstract> pipeline, GameTexture texture, CollisionDetectorInterface detector, Vector2 direction, Vector2 position, Vector2 directionFacing) : base(pipeline, texture, detector, null, RADIUS, HEIGHT, CommonFunctions.normalizeNonmutating(direction) * SPEED, position, directionFacing, DEPTH) { boundsPolygon_ = new ConvexPolygon(BOUNDS_POINTS, Vector2.Zero); fuseTime_ = FUSE; started_ = false; }
/// <summary> /// Constructor determines whether PC or Xbox 360 and initializes /// variables accordingly. /// /// For PC, this means creating the controller and trying to get a /// storage device. /// /// For the Xbox 360, we don't need to do much as we rely on update() /// logic to determine active controller and storage device. /// </summary> /// <param name="engine"></param> public EngineStateStart(Engine engine) { engine_ = engine; //logo_ = TextureMap.fetchTexture(@"Sprites\TitleScreen"); //logo_ = new GameTexture(@"Sprites\TitleScreen", engine.spriteBatch_, engine.GraphicsDevice, engine.Content); logo_ = new GameTexture(@"Sprites\TitleScreen"); #if !XBOX { Settings settings = Settings.getInstance(); if (Settings.getInstance().IsUsingMouse_) { engine_.Controls_ = new PCControllerInput(engine_); settings.CurrentPlayer_ = PlayerIndex.One; TEXT_MESSAGE = "Press " + engine_.Controls_.getControlName(InputsEnum.CONFIRM_BUTTON).ToUpper() + " to Continue"; } else { engine_.Controls_ = new X360ControllerInput(engine_, PlayerIndex.One); settings.CurrentPlayer_ = PlayerIndex.One; TEXT_MESSAGE = "Press " + engine_.Controls_.getControlName(InputsEnum.CONFIRM_BUTTON).ToUpper() + " to Continue"; } prepareStorageDevice(); returnFlag_ = true; } #else { engine_.Controls_ = null; // reset controls if they are coming back to this returnFlag_ = false; } #endif }
public EngineStateDialogue(int character, CharacterController _npc, CharacterController player, bool is_companion) : base(EngineManager.Engine) { m_baseImage = new GameTexture(@"Sprites/RPG/PopupScreen"); if (GameplayManager.ActiveArea.GlobalLocation != Area.PARTY) { m_dialog = DialogManager.get(character); } else { // TODO put social game results here! m_dialog = new Dialog(character+" played a social game, or passed or whatever...", false, Color.WhiteSmoke); } m_button4_released = false; drawOnCompanionSide = is_companion; //brewMode = false; bouncerMode = false; bouncerPass = false; bouncerDist = 0; bouncerI = 0; npc = _npc; if (npc != null && npc.getCollider().m_type == ColliderType.NPC && player != null && player.brew != null) { if (npc.bouncer != null) { m_dialog = null; bouncerMode = true; bouncerPass = npc.bouncer.canPass(player.brew, (int)npc.getCollider().Bounds.Center().X, (int)npc.getCollider().Bounds.Center().Y, (int)npc.getCollider().Bounds.Width, (int)npc.getCollider().Bounds.Height, (int)player.getCollider().Bounds.Center().X, (int)player.getCollider().Bounds.Center().Y, (int)player.getCollider().Bounds.Width, (int)player.getCollider().Bounds.Height); //if what was passed in is the player, then add what task he's currently doing to the plan. if (bouncerPass && !is_companion) { player.addTaskToPlan(npc.bouncer); } } else if (npc.brew != null) { //if what was passed in is the player, then add what task he's currently doing to the plan. //brewMode = true; if (player.brew.mix(npc.brew)) { m_dialog = null; if (!is_companion) { player.addTaskToPlan(npc.brew); } } else { m_dialog = new Dialog("I don't have the right brew for this mixture"); } } } }
public LevelAbstract(List<RoomAbstract> rooms, Dictionary<string, string> properties, string name, int levelNumber, GameTexture introScreen) { rooms_ = rooms; properties_ = properties; name_ = name; levelNumber_ = levelNumber; introScreen_ = introScreen; }
// --- Implemented Functions --- public TransitionObjectAbstract(List<DrawableObjectAbstract> pipeline, CollisionDetectorInterface detector, GameTexture image, Vector2 position, Vector2 direction, float depth, float radius, Height height) : base(pipeline, image, position, direction, depth) { if (detector != null) { detector.register(this); } detector_ = detector; radius_ = radius; height_ = height; }
public Projectile(List<DrawableObjectAbstract> pipeline, GameTexture texture, CollisionDetectorInterface detector, ConvexPolygonInterface bounds, float radius, Height height, Vector2 velocity, Vector2 position, Vector2 direction, float depth) : base(pipeline, velocity, position, direction, depth) { texture_ = texture; if (detector != null) { detector.register(this); collisionDetector_ = detector; } boundsPolygon_ = bounds; radius_ = radius; height_ = height; }
public ItemAbstract(CollisionDetectorInterface detector, List<Vector2> points, Vector2 center, float radius, Height height, List<DrawableObjectAbstract> pipeline, GameTexture image, Vector2 position, Vector2 direction, float depth) : base(pipeline, image, position, direction, depth) { bounds_ = new ConvexPolygon(points, center); bounds_.rotate(direction_, position_); radius_ = radius; height_ = height; hasBeenPickedUp_ = false; if (detector != null) { detector.register(this); } detector_ = detector; }
public ProjectileController(IGameObject owner, Vector2 position, Vector2 velocity, ProjectileType type, int damage, String texturePath) { Rectangle bounds = new Rectangle((int)position.X - 1, (int)position.Y - 1, 3, 3); m_collider = new Collider(this, bounds, ColliderType.Projectile); Owner = owner; Velocity = velocity; Damage = damage; Tint = Color.White; Freezes = false; m_position = position; m_type = type; m_texture = new GameTexture(texturePath); }
public NonLoopAnimation(GameTexture sprites, float frameLengthModifier, float depth, List<Vector2> boundsPoints) { sprites_ = sprites; currentFrame_ = 0; totalFrames_ = sprites.getNumberOfImages(); position_ = Vector2.Zero; rotation_ = Vector2.Zero; frameLengthModifier_ = frameLengthModifier; moved_ = Vector2.Zero; depth_ = depth; boundsPolygon_ = new ConvexPolygonInterface[1]; boundsPolygon_[0] = new ConvexPolygon(boundsPoints, Vector2.Zero); perFrameBounds_ = false; }
/// <summary> /// Renders a specified texture onto a RenderTexture or the GameScreen (if renderTarget is passed as null) at the /// coordinates given using a specified blending mode. /// </summary> /// <param name="tex">The texture to draw</param> /// <param name="x">X coordinate on the render target to draw to</param> /// <param name="y">Y coordinate on the render target to draw to</param> /// <param name="renderColor">Color mask to draw with. Default is Color.White</param> /// <param name="renderTarget">Where to draw to. If null it this will draw to the game screen.</param> /// <param name="blendMode">Which blend mode to use when rendering</param> public static void DrawGameTexture( GameTexture tex, float x, float y, Color renderColor, GameRenderTexture renderTarget = null, GameBlendModes blendMode = GameBlendModes.None, GameShader shader = null, float rotationDegrees = 0.0f, bool drawImmediate = false ) { var destRectangle = new FloatRect(x, y, tex.GetWidth(), tex.GetHeight()); var srcRectangle = new FloatRect(0, 0, tex.GetWidth(), tex.GetHeight()); DrawGameTexture( tex, srcRectangle, destRectangle, renderColor, renderTarget, blendMode, shader, rotationDegrees, drawImmediate ); }
public NonLoopAnimation(GameTexture sprites, float frameLengthModifier, float depth, List<List<Vector2>> boundsPoints) { sprites_ = sprites; currentFrame_ = 0; totalFrames_ = sprites.getNumberOfImages(); position_ = Vector2.Zero; rotation_ = Vector2.Zero; frameLengthModifier_ = frameLengthModifier; moved_ = Vector2.Zero; depth_ = depth; boundsPolygon_ = new ConvexPolygonInterface[boundsPoints.Count]; for (int i = 0; i < boundsPoints.Count; i++) { boundsPolygon_[i] = new ConvexPolygon(boundsPoints[i], Vector2.Zero); } perFrameBounds_ = true; }
protected override void OnInit() { base.OnInit(); this.m_selfTex = Make <GameTexture>("self"); this.m_selfSpine = Make <GameSpine>("self_spine"); this.m_npcTex = Make <GameTexture>("npc"); this.m_npcSpine = Make <GameSpine>("npc_spine"); this.m_contentLab = Make <GameLabel>("Image_chat:ContentLab"); this.m_contentFader = this.m_contentLab.GetComponent <TextFader>(); this.m_leftBtn = Make <GameButton>("Image_chat:btnLeft"); this.m_rightBtn = Make <GameButton>("Image_chat:btnRight"); this.m_serialIconGrid = Make <GameUIContainer>("Image_chat:serialIconGrid"); this.m_Image_chat = Make <GameUIComponent>("Image_chat"); this.m_confutBtn = Make <GameButton>("btnConfut"); this.m_iconCom = Make <GameUIComponent>("Image_icon"); this.m_iconImg = this.m_iconCom.Make <GameImage>("icon"); }
/// <summary> /// return true if all pixels match with another gameTexture /// </summary> /// <param name="texToCompare"></param> Gametexture to test equality /// <returns></returns> true if textures are equal public bool Equals(GameTexture texToCompare) { if (width != texToCompare.width || height != texToCompare.height) { return(false); } else { for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (!GetPixel(x, y).Equals(texToCompare.GetPixel(x, y))) { return(false); } } } return(true); } }
public Single(GameTexture texture, float x, float y, float w, float h) { mTexture = texture; float texw = 1; float texh = 1; if (mTexture != null) { texw = mTexture.GetWidth(); texh = mTexture.GetHeight(); } mUv = new float[4]; mUv[0] = x / texw; mUv[1] = y / texh; mUv[2] = (x + w) / texw; mUv[3] = (y + h) / texh; mWidth = (int)w; mHeight = (int)h; }
public void RunOverlayKernel(GameTexture tex, GameTexture overlay, float weight) { GL.BindTexture(TextureTarget.Texture2D, tex.textureID); GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureWidth, out float width); GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureHeight, out float height); byte[] buffer = new byte[(int)(width * height * 4)]; GL.GetTexImage(TextureTarget.Texture2D, 0, PixelFormat.Bgra, PixelType.UnsignedByte, buffer); MemoryBuffer mb = c.CreateBuffer(MemoryFlag.CopyHostPointer, buffer); //Custom CLFilter filter = _kernels["overlay"]; byte[] bufferOverlay = new byte[(int)(width * height * 4)]; GL.BindTexture(TextureTarget.Texture2D, overlay.textureID); GL.GetTexImage(TextureTarget.Texture2D, 0, PixelFormat.Bgra, PixelType.UnsignedByte, bufferOverlay); MemoryBuffer mbOverlay = c.CreateBuffer(MemoryFlag.CopyHostPointer, bufferOverlay); filter.SetArg(0, mb); filter.SetArg(1, new int3((int)width, (int)height, 1)); filter.SetArg(2, 4); filter.SetArg(3, enablechannels); //Custom filter.SetArg(5, mbOverlay); filter.SetArg(6, weight); CommandQueue cq = CommandQueue.CreateCommandQueue(c, d); cq.EnqueueNDRangeKernel(filter.kernel, 1, buffer.Length); buffer = cq.EnqueueReadBuffer <byte>(mb, buffer.Length); GL.BindTexture(TextureTarget.Texture2D, tex.textureID); GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)width, (int)height, PixelFormat.Bgra, PixelType.UnsignedByte, buffer); }
public void RunCheckerBoardKernel(GameTexture tex, float length) { //Custom CLFilter filter = _kernels["checkerboard"]; //Get Width & Height GL.BindTexture(TextureTarget.Texture2D, tex.textureID); GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureWidth, out float width); GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureHeight, out float height); //Get Image source from opengl //Custom byte[] buffer = new byte[(int)(width * height * 4)]; GL.GetTexImage(TextureTarget.Texture2D, 0, PixelFormat.Bgra, PixelType.UnsignedByte, buffer); //Create buffer with image content MemoryBuffer mb = c.CreateBuffer(MemoryFlag.ReadWrite | MemoryFlag.CopyHostPointer, buffer); filter.SetArg(0, mb); filter.SetArg(1, new int3((int)width, (int)height, 1)); filter.SetArg(2, 4); filter.SetArg(3, enablechannels); //Custom filter.SetArg(3, length); filter.SetArg(4, (int)width); CommandQueue cq = CommandQueue.CreateCommandQueue(c, d); cq.EnqueueNDRangeKernel(filter.kernel, 1, buffer.Length); buffer = cq.EnqueueReadBuffer <byte>(mb, buffer.Length); GL.BindTexture(TextureTarget.Texture2D, tex.textureID); GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)width, (int)height, PixelFormat.Bgra, PixelType.UnsignedByte, buffer); }
protected override void OnInit() { base.OnInit(); m_3D_view = Make <Combine3DView>("Panel:3D"); m_tex_view = Make <GameTexture>("Panel:RawImage_Tex"); m_icon_view = Make <GameImage>("Panel:Image_Icon"); m_left_toggles[0] = Make <ToggleWithArrowTween>("leftBtn:btnTotal"); m_left_toggles[0].Refresh((int)ENUM_COMBINE_TYPE.POLICE, ENUM_COMBINE_TYPE.POLICE.ToString(), false, LeftToggleChecked); m_left_toggles[1] = Make <ToggleWithArrowTween>("leftBtn:btnRecently"); m_left_toggles[1].Refresh((int)ENUM_COMBINE_TYPE.COLLECTION, ENUM_COMBINE_TYPE.COLLECTION.ToString(), false, LeftToggleChecked); m_left_toggles[2] = Make <ToggleWithArrowTween>("leftBtn:btnEnergy"); m_left_toggles[2].Refresh((int)ENUM_COMBINE_TYPE.OTHER, ENUM_COMBINE_TYPE.OTHER.ToString(), false, LeftToggleChecked); m_top_toggle_grid = Make <GameLoopUIContainer <ToggleCheckMarkView> >("Panel:ScrollView:Viewport"); m_drop_grid_ori_local_x = m_top_toggle_grid.gameObject.transform.localPosition.x; m_drop_layout = m_top_toggle_grid.GetComponent <UnityEngine.UI.GridLayoutGroup>(); m_drop_item_size_x = m_drop_layout.cellSize.x; m_drop_item_space_x = m_drop_layout.spacing.x; m_big_stuffs[0] = Make <BigStuffItemView>("Panel:Panel:Big0"); m_big_stuffs[1] = Make <BigStuffItemView>("Panel:Panel:Big1"); m_big_stuffs[2] = Make <BigStuffItemView>("Panel:Panel:Big2"); m_big_stuffs[3] = Make <BigStuffItemView>("Panel:Panel:Big3"); m_big_stuffs[4] = Make <BigStuffItemView>("Panel:Panel:Big4"); m_big_stuffs[5] = Make <BigStuffItemView>("Panel:Panel:Big5"); m_small_stuffs[0] = Make <SmallStuffItemView>("Panel:Panel:Image (6)"); m_small_stuffs[1] = Make <SmallStuffItemView>("Panel:Panel:Image (7)"); m_small_stuffs[2] = Make <SmallStuffItemView>("Panel:Panel:Image (8)"); m_small_stuffs[3] = Make <SmallStuffItemView>("Panel:Panel:Image (9)"); m_gift_btn = Make <GameButton>("Panel:Image:Button"); m_combine_btn = Make <GameButton>("Panel:Panel:Button"); m_stored_img = Make <GameImage>("Panel:Panel:Image_colected"); m_name_txt = Make <GameLabel>("Panel:Text"); m_No_txt = Make <GameLabel>("Panel:Text (1)"); m_progress_txt = Make <GameLabel>("Panel:Text (2)"); }
public override void Initialize() { D3D9Manager.Instance.CreateFont("Default", "Segoe UI", 25, false); messageBoxTex = D3D9Manager.Instance.CreateTexture( "MessageBox", "./Resource/MessageBox.png"); quitButtonTex = D3D9Manager.Instance.CreateTexture( "MessageBoxQuitButton", "./Resource/MessageBoxQuitButton.png"); quitButton = new Button() { ButtonTexture = quitButtonTex, IsMouseOverResize = true, Position = Position + new Vector3(0, 70, 0), Scale = new Vector3(1, 1, 1), IsAllowDuplicateClick = true }; quitButton.Initialize(); quitButton.OnButtonClick += QuitButton_OnButtonClick; D3D9Manager.Instance.OnMouseClickToMessageBoxEvent += quitButton.OnClick; quitButton.OnButtonClick += OnQuitButtonClick; }
public void RunLightKernel(GameTexture tex) { //MemoryBuffer buf = c.CreateFromGLTexture2D(MemoryFlag.ReadWrite | MemoryFlag.UseHostPointer, (uint)TextureTarget.Texture2D, 0, (uint)tex.textureID); //string test = d.GetDeviceInformation<string>(DeviceInformation.Extensions); //DevicesNativeApi.GetDeviceInformation(d, DeviceInformation.Extensions, UIntPtr.Zero, ) GL.BindTexture(TextureTarget.Texture2D, tex.textureID); //Custom CLFilter filter = _kernels["light"]; GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureWidth, out float width); GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureHeight, out float height); byte[] buffer = new byte[(int)(width * height * 4)]; GL.GetTexImage(TextureTarget.Texture2D, 0, PixelFormat.Bgra, PixelType.UnsignedByte, buffer); MemoryBuffer mb = c.CreateBuffer(MemoryFlag.ReadWrite | MemoryFlag.CopyHostPointer, buffer); filter.SetArg(0, mb); filter.SetArg(1, new int3((int)width, (int)height, 1)); filter.SetArg(2, 4); filter.SetArg(3, enablechannels); CommandQueue cq = CommandQueue.CreateCommandQueue(c, d); cq.EnqueueNDRangeKernel(filter.kernel, 1, buffer.Length); buffer = cq.EnqueueReadBuffer <byte>(mb, buffer.Length); GL.BindTexture(TextureTarget.Texture2D, tex.textureID); GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)width, (int)height, PixelFormat.Bgra, PixelType.UnsignedByte, buffer); }
protected override void OnInit() { base.OnInit(); m_desc_txt = this.Make <GameLabel>("Panel_down:Image_1:Text"); m_output_title_txt = this.Make <GameLabel>("Panel_down:RawImage:Panel_output:Text_2"); m_time_txt = Make <GameLabel>("Panel_down:RawImage:Panel_output:Image:Text"); m_thumbnail_tex = Make <GameTexture>("Panel_down:RawImage"); m_output_grid = this.Make <GameUIContainer>("Panel_down:RawImage:Panel_output:Grid"); m_case_name_txt = this.Make <GameLabel>("Panel_down:RawImage:Image:Text"); m_action_btn = this.Make <GameButton>("Panel_down:btn_action"); m_action_btn_title_txt = m_action_btn.Make <GameLabel>("Text"); m_action_btn_effect = m_action_btn.Make <GameUIEffect>("UI_pintukaishi_anniu"); m_action_btn_effect.EffectPrefabName = "UI_pintukaishi_anniu.prefab"; m_ticket_icon = m_action_btn.Make <GameImage>("Image_item"); m_action_btn_num_txt = m_action_btn.Make <GameLabel>("Text_item"); this.m_btnClose = Make <GameButton>("Panel_down:Button_close"); m_video_root = Make <GameUIComponent>("Panel_down:video_Image"); m_video = m_video_root.Make <GameVideoComponent>("RawImage_Video"); m_btn_play_video = Make <GameImage>("Panel_down:RawImage:Image_play"); m_btn_close_video = m_video.Make <GameButton>("Btn_Close_Video"); m_bg_img = Make <GameImage>("RawImage"); m_bg_alpha = m_bg_img.GetComponent <TweenAlpha>(); m_tween_root = Make <GameUIComponent>("Panel_down"); //m_show_tween_scale = m_tween_root.GetComponent<TweenScale>(); //m_show_tween_scale.AddTweenCompletedCallback(ShowTweenScaleFinished); //var show_tween_poses = m_tween_root.GetComponents<TweenPosition>().Where((i) => UITweenerBase.TweenTriggerType.Manual == i.m_triggerType); //m_show_tween_pos = show_tween_poses.First(); //var show_tween_alphas = m_tween_root.GetComponents<TweenAlpha>().Where((i) => UITweenerBase.TweenTriggerType.OnShow == i.m_triggerType); //m_show_tween_alpha = show_tween_alphas.First(); }
private void Init( GameTexture texture, float x, float y, float w, float h, Margin inMargin, float drawMarginScale = 1.0f ) { mTexture = texture; mMargin = inMargin; SetRect(0, x, y, mMargin.Left, mMargin.Top); SetRect(1, x + mMargin.Left, y, w - mMargin.Left - mMargin.Right, mMargin.Top); SetRect(2, x + w - mMargin.Right, y, mMargin.Right, mMargin.Top); SetRect(3, x, y + mMargin.Top, mMargin.Left, h - mMargin.Top - mMargin.Bottom); SetRect( 4, x + mMargin.Left, y + mMargin.Top, w - mMargin.Left - mMargin.Right, h - mMargin.Top - mMargin.Bottom ); SetRect(5, x + w - mMargin.Right, y + mMargin.Top, mMargin.Right, h - mMargin.Top - mMargin.Bottom - 1); SetRect(6, x, y + h - mMargin.Bottom, mMargin.Left, mMargin.Bottom); SetRect(7, x + mMargin.Left, y + h - mMargin.Bottom, w - mMargin.Left - mMargin.Right, mMargin.Bottom); SetRect(8, x + w - mMargin.Right, y + h - mMargin.Bottom, mMargin.Right, mMargin.Bottom); mMargin.Left = (int)(mMargin.Left * drawMarginScale); mMargin.Right = (int)(mMargin.Right * drawMarginScale); mMargin.Top = (int)(mMargin.Top * drawMarginScale); mMargin.Bottom = (int)(mMargin.Bottom * drawMarginScale); mWidth = w - x; mHeight = h - y; }
public override void Initialize() { D3D9Manager.Instance.CreateFont("CreateWindowInputFont", "Segoe UI", 50, false); background = D3D9Manager.Instance.CreateTexture("CreateRoomWindowBG", "./Resource/CreateRoomWindow.png"); createButton = new Button(); createButton.ButtonTexture = D3D9Manager.Instance.CreateTexture("CreateButton", "./Resource/Create.png"); createButton.IsMouseOverResize = true; createButton.Parent = this; createButton.Position = new Vector3(-187, 130, 0); createButton.UseParentMatrix = true; createButton.OnButtonClick += CreateButton_OnButtonClick; cancelButton = new Button(); cancelButton.ButtonTexture = D3D9Manager.Instance.CreateTexture("CancelButton", "./Resource/Cancel.png"); cancelButton.IsMouseOverResize = true; cancelButton.Parent = this; cancelButton.Position = new Vector3(198, 134, 0); cancelButton.UseParentMatrix = true; cancelButton.OnButtonClick += CancelButton_OnButtonClick; roomNameInput = new TextInputField("CreateWindowInputFont"); roomNameInput.Position = new Vector3(0, 0, 0); roomNameInput.FieldTexture = D3D9Manager.Instance.CreateTexture("RoomNameInput", "./Resource/RoomNameInput.png"); roomNameInput.StringOffset = new Vector3(20, 0, 0); roomNameInput.Text = "New Room"; roomNameInput.MaxLength = 15; roomNameInput.Parent = this; GameObjectManager.Instance.AddObject(createButton); GameObjectManager.Instance.AddObject(cancelButton); GameObjectManager.Instance.AddObject(roomNameInput); }
// Start is called before the first frame update void Start() { //GameTexture firstLayer = ShapeModifer.changeColor(new GameTexture(startingTexture), new GameColor(startingColor)); Texture2D firstLayer = ShapeModifer.changeColor(startingTexture, new GameColor(startingColor)); //Debug.Log(firstLayer); Node thisNode = new Node(firstLayer); //thisNode.addTex(new GameTexture(addLayers[0])); for (int i = 0; i < addLayers.Length; i++) { Texture2D thisTex = addLayers[i]; GameColor thisColor = new GameColor(addColors[i]); GameTexture newTex = new GameTexture(ShapeModifer.changeColor(thisTex, thisColor)); Node newNode = new Node(newTex); thisNode.addNode(newNode); } for (int i = 0; i < subLayers.Length; i++) { GameTexture thisTex = new GameTexture(subLayers[i]); GameColor thisColor = new GameColor(subColors[i]); GameTexture newTex = ShapeModifer.changeColor(thisTex, thisColor); Node newNode = new Node(newTex); thisNode.subNode(newNode); } Texture2D tex = thisNode.GetTexture2D(); //Texture2D tex = firstLayer.getTex(); Sprite newSprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.one * 0.5f); rend.sprite = newSprite; }
public static void DrawGameTexture( GameTexture tex, FloatRect srcRectangle, FloatRect targetRect, Color renderColor, GameRenderTexture renderTarget = null, GameBlendModes blendMode = GameBlendModes.None, GameShader shader = null, float rotationDegrees = 0.0f, bool drawImmediate = false ) { if (tex == null) { return; } Renderer.DrawTexture( tex, srcRectangle.X, srcRectangle.Y, srcRectangle.Width, srcRectangle.Height, targetRect.X, targetRect.Y, targetRect.Width, targetRect.Height, Color.FromArgb(renderColor.A, renderColor.R, renderColor.G, renderColor.B), renderTarget, blendMode, shader, rotationDegrees, false, drawImmediate ); }
protected override void OnInit() { base.OnInit(); m_time_txt = Make <GameLabel>("Text"); m_input_tex = Make <GameTexture>("RawImage_bg"); m_pause_btn = Make <GameButton>("Button_pause"); m_clue_progress_grid = Make <GameUIContainer>("Canvas:ClueProgressGrid"); m_clue_progress_grid.Visible = false; m_normal_grid = Make <GameRecycleContainer>("Normal_Grid"); m_normal_grid.EnsureSize <NormalItemView>(5); for (int i = 0; i < m_normal_grid.ChildCount; ++i) { m_normal_grid.GetChild <NormalItemView>(i).Refresh(i); } m_special_grid = Make <GameRecycleContainer>("Special_Grid"); //m_special_grid.EnsureSize<SpecialItemView>(5); //for (int i = 0; i < m_special_grid.ChildCount; ++i) //{ // m_special_grid.GetChild<SpecialItemView>(i).Refresh(i); //} //m_anchors_grid = Make<GameUIContainer>("Anchors_Grid"); m_details_grid = Make <GameRecycleContainer>("Detail_Grid"); m_details_grid.EnsureSize <ClueDetailView>(3); m_fly_icons_grid = Make <GameRecycleContainer>("FlyIcon_Grid"); m_fly_icons_grid.EnsureSize <FlyIconItemView>(3); m_fly_time_txt = Make <GameLabel>("Text (2)"); m_fly_time_tween_pos = m_fly_time_txt.GetComponent <TweenPosition>(); m_start_view = Make <ScanStartView>("Panel_start"); m_start_view_tween_pos = m_start_view.GetComponent <TweenPosition>(); }
public GameTexture GetPerlin(int width, int height, int octaves, float persistence) { CLFilter filter = _kernels["perlin"]; byte[] buffer = new byte[width * height * 4]; Random rnd = new Random(); for (int i = 0; i < buffer.Length; i++) { if (i % 4 == 0) { byte val = (byte)rnd.Next(0, 255); buffer[i] = buffer[i + 1] = buffer[i + 2] = val; buffer[i + 3] = 255; // Alpha } } MemoryBuffer mb = c.CreateBuffer(MemoryFlag.ReadWrite | MemoryFlag.CopyHostPointer, buffer); filter.SetArg(0, mb); int3 dims = new int3(width, height, 1); filter.SetArg(1, dims); filter.SetArg(2, 4); filter.SetArg(3, enablechannels); filter.SetArg(4, persistence); filter.SetArg(5, octaves); CommandQueue cq = CommandQueue.CreateCommandQueue(c, d); cq.EnqueueNDRangeKernel(filter.kernel, 1, buffer.Length); buffer = cq.EnqueueReadBuffer <byte>(mb, buffer.Length); return(GameTexture.Load(buffer, width, height)); }
/// <summary> /// Create a HeadsUpDisplayObject with the specified texture, position, direction, and depth. /// </summary> /// <param name="pipeline">Drawing pipeline in which to register the object</param> /// <param name="tex">GameTexture for this HeadsUpDisplayObject</param> /// <param name="pos">Position as a Vector relative to the top left corner</param> /// <param name="dir">Direction of the HeadsUpDisplayObject as a Vector</param> /// <param name="depth">Drawing depth of the object</param> public HeadsUpDisplayWeapon(List<DrawableObjectAbstract> pipeline, GameTexture tex, List<GameTexture> texList, Vector2 pos, Vector2 dir, float depth) : base(pipeline,tex,pos, dir, depth) { texList_ = texList; texIndex_ = 0; }
/// <summary> /// Loads an AnimationSet into the AnimationController. /// </summary> /// <param name="animSetPath">Asset path to the AnimationSet.</param> /// <param name="texturePath">Asset path to the image file to use.</param> public AnimationController(string animSetPath, string texturePath) { m_animSet = GlobalHelper.loadContent<AnimationSet>(animSetPath); // Build up a mapping of animation & sprite indices to image dimension idxs List<Rectangle> imageDimensionsList = new List<Rectangle>(); int counter = 0; m_sourceRectangleIdxs = new int[m_animSet.anims.Length][]; for (int i = 0; i < m_animSet.anims.Length; ++i) { m_sourceRectangleIdxs[i] = new int[m_animSet.anims[i].sprites.Length]; for (int j = 0; j < m_animSet.anims[i].sprites.Length; ++j) { imageDimensionsList.Add(m_animSet.anims[i].sprites[j].box); m_sourceRectangleIdxs[i][j] = counter; counter++; } } m_texture = new GameTexture(texturePath, imageDimensionsList.ToArray()); }
/// <summary> /// Create a HeadsUpDisplayObject with the specified texture, position, direction, and depth. /// </summary> /// <param name="pipeline">Drawing pipeline in which to register the object</param> /// <param name="tex">GameTexture for this HeadsUpDisplayObject</param> /// <param name="pos">Position as a Vector relative to the top left corner</param> /// <param name="dir">Direction of the HeadsUpDisplayObject as a Vector</param> /// <param name="depth">Drawing depth of the object</param> public HeadsUpDisplayObject(List<DrawableObjectAbstract> pipeline, GameTexture tex, Vector2 pos, Vector2 dir, float depth) : base(pipeline, tex, pos, dir, depth) { newValue_ = 100; }
public override void Draw() { WorldPos.Reset(); if (MapInstance.Get(CurrentMap) == null || !Globals.GridMaps.Contains(CurrentMap)) { return; } var map = MapInstance.Get(CurrentMap); var srcRectangle = new FloatRect(); var destRectangle = new FloatRect(); GameTexture srcTexture = null; var height = 0; var width = 0; var d = 0; switch (Graphic.Type) { case EventGraphicType.Sprite: //Sprite var entityTex = Globals.ContentManager.GetTexture( GameContentManager.TextureType.Entity, Graphic.Filename ); if (entityTex != null) { srcTexture = entityTex; height = srcTexture.GetHeight() / Options.Instance.Sprites.Directions; width = srcTexture.GetWidth() / Options.Instance.Sprites.NormalFrames; d = Graphic.Y; if (!DirectionFix) { switch (Dir) { case 0: d = 3; break; case 1: d = 0; break; case 2: d = 1; break; case 3: d = 2; break; } } var frame = Graphic.X; if (WalkingAnim) { frame = WalkFrame; } if (Options.AnimatedSprites.Contains(Graphic.Filename.ToLower())) { srcRectangle = new FloatRect( AnimationFrame * (int)entityTex.GetWidth() / Options.Instance.Sprites.NormalFrames, d * (int)entityTex.GetHeight() / Options.Instance.Sprites.Directions, (int)entityTex.GetWidth() / Options.Instance.Sprites.NormalFrames, (int)entityTex.GetHeight() / Options.Instance.Sprites.Directions ); } else { srcRectangle = new FloatRect( frame * (int)srcTexture.GetWidth() / Options.Instance.Sprites.NormalFrames, d * (int)srcTexture.GetHeight() / Options.Instance.Sprites.Directions, (int)srcTexture.GetWidth() / Options.Instance.Sprites.NormalFrames, (int)srcTexture.GetHeight() / Options.Instance.Sprites.Directions ); } } break; case EventGraphicType.Tileset: //Tile if (mCachedTilesetName != Graphic.Filename) { mCachedTilesetName = Graphic.Filename; mCachedTileset = Globals.ContentManager.GetTexture( GameContentManager.TextureType.Tileset, Graphic.Filename ); } var tileset = mCachedTileset; if (tileset != null) { srcTexture = tileset; width = (Graphic.Width + 1) * Options.TileWidth; height = (Graphic.Height + 1) * Options.TileHeight; srcRectangle = new FloatRect( Graphic.X * Options.TileWidth, Graphic.Y * Options.TileHeight, (Graphic.Width + 1) * Options.TileWidth, (Graphic.Height + 1) * Options.TileHeight ); } break; } destRectangle.X = map.GetX() + X * Options.TileWidth + OffsetX; if (height > Options.TileHeight) { destRectangle.Y = map.GetY() + Y * Options.TileHeight + OffsetY - (height - Options.TileHeight); } else { destRectangle.Y = map.GetY() + Y * Options.TileHeight + OffsetY; } if (width > Options.TileWidth) { destRectangle.X -= (width - Options.TileWidth) / 2; } destRectangle.X = (int)Math.Ceiling(destRectangle.X); destRectangle.Y = (int)Math.Ceiling(destRectangle.Y); destRectangle.Width = srcRectangle.Width; destRectangle.Height = srcRectangle.Height; // Set up our targetting rectangle. // If we're smaller than a tile, force the target size to a tile. WorldPos = destRectangle; WorldPos.Width = Math.Max(Options.TileWidth, srcRectangle.Width); WorldPos.Height = Math.Max(Options.TileHeight, srcRectangle.Height); if (srcTexture != null) { Graphics.DrawGameTexture(srcTexture, srcRectangle, destRectangle, Intersect.Color.White); } }
/// <summary> /// Create a LevelObject with the specified image, position, direction, and depth. /// </summary> /// <param name="pipeline">List of objects from which the object should be drawn.</param> /// <param name="image">GameTexture for this object.</param> /// <param name="position">Position of the object as a Vector relative to the top left corner</param> /// <param name="direction">Direction of the object as a Vector</param> /// <param name="depth">Drawing depth of the object</param> public LevelObjectAbstract(List<DrawableObjectAbstract> pipeline, GameTexture image, Vector2 position, Vector2 direction, float depth) : base(pipeline, position, direction, depth) { image_ = image; }
public override bool UpdateTile(GameTexture tex, float x, float y, int srcX, int srcY, int srcW, int srcH) { var key = new Tuple <float, float>(x, y); var vertexIndex = -1; if (verticeDict.ContainsKey(key)) { vertexIndex = verticeDict[key]; } if (vertexIndex == -1) { return(false); } var platformTex = tex?.GetTexture(); if (platformTex == null) { return(false); } if (tex == null) { return(false); } if (tex.GetTexture() != platformTex) { return(false); } if (vertexBuffer == null) { return(false); } var pack = tex.GetTexturePackFrame(); var rotated = false; if (pack != null) { if (pack.Rotated) { rotated = true; var z = srcX; srcX = pack.Rect.Right - srcY - srcH; srcY = pack.Rect.Top + z; z = srcW; srcW = srcH; srcH = z; } else { srcX += pack.Rect.X; srcY += pack.Rect.Y; } } var texture = (Texture2D)tex.GetTexture(); var textureSizeX = 1f / texture.Width; var textureSizeY = 1f / texture.Height; var left = srcX * textureSizeX; var right = (srcX + srcW) * textureSizeX; var bottom = (srcY + srcH) * textureSizeY; var top = srcY * textureSizeY; if (rotated) { vertices[vertexIndex++] = new VertexPositionTexture( new Vector3(x, y + srcH, 0), new Vector2(left, top) ); vertices[vertexIndex++] = new VertexPositionTexture(new Vector3(x, y, 0), new Vector2(right, top)); vertices[vertexIndex++] = new VertexPositionTexture( new Vector3(x + srcW, y + srcH, 0), new Vector2(left, bottom) ); vertices[vertexIndex] = new VertexPositionTexture( new Vector3(x + srcW, y, 0), new Vector2(right, bottom) ); } else { vertices[vertexIndex++] = new VertexPositionTexture( new Vector3(x, y + srcH, 0), new Vector2(left, bottom) ); vertices[vertexIndex++] = new VertexPositionTexture(new Vector3(x, y, 0), new Vector2(left, top)); vertices[vertexIndex++] = new VertexPositionTexture( new Vector3(x + srcW, y + srcH, 0), new Vector2(right, bottom) ); vertices[vertexIndex] = new VertexPositionTexture(new Vector3(x + srcW, y, 0), new Vector2(right, top)); } updatesPending = true; return(true); }
public EngineStateDialogue() : base(EngineManager.Engine) { m_baseImage = new GameTexture(@"Sprites/RPG/PopupScreen"); }
public GameTexture(GameTexture gameTexture) { this.width=gameTexture.width; this.height=gameTexture.height; this.texture=gameTexture.texture; }
public static void init() { // Load resource (texture) treasure = new GameTexture(0,0,(Texture2D)Resources.Load("Texture/treasure")); num=new GameTexture[8]; for(int i=0;i<8;i++){ num[i] = new GameTexture(0,0,(Texture2D)Resources.Load("Texture/"+(i+1))); } treasureBG=new GameTexture[3]; for(int i=0;i<3;i++){ treasureBG[i] = new GameTexture(0,0,(Texture2D)Resources.Load("Texture/treasureBG"+(i+1))); } treasureSelect = new GameTexture(0,0,(Texture2D)Resources.Load("Texture/treasureSelect")); treasureRemainBG = new GameTexture(151,73,(Texture2D)Resources.Load("Texture/treasureRemainBG")); up=new GameTexture(55,55,(Texture2D)Resources.Load("Texture/up")); down=new GameTexture(55,55,(Texture2D)Resources.Load("Texture/down")); left=new GameTexture(55,55,(Texture2D)Resources.Load("Texture/left")); right=new GameTexture(55,55,(Texture2D)Resources.Load("Texture/right")); yoursOthers=new GameTexture(86,100,(Texture2D)Resources.Load("Texture/yoursOthers")); yours=new GameTexture(86,50); others=new GameTexture(86,50); waitForYourTurn=new GameTexture(331,36,(Texture2D)Resources.Load("Texture/waitForYourTurn")); youWin=new GameTexture(222,47,(Texture2D)Resources.Load("Texture/youWin")); youLost=new GameTexture(232,42,(Texture2D)Resources.Load("Texture/youLost")); confirm=new GameTexture(114,32,(Texture2D)Resources.Load("Texture/confirm")); endConfirm=new GameTexture(confirm); startGame = new GameTexture(188,50,(Texture2D)Resources.Load("Texture/startGame")); endGame = new GameTexture(95,50,(Texture2D)Resources.Load("Texture/end")); back=new GameTexture(139,50,(Texture2D)Resources.Load("Texture/back")); checkingNetwork=new GameTexture(518,46,(Texture2D)Resources.Load("Texture/checkingNetwork")); pleaseWait=new GameTexture(400,41,(Texture2D)Resources.Load("Texture/pleaseWait")); practice=new GameTexture(224,50,(Texture2D)Resources.Load("Texture/practice")); vsComputer=new GameTexture(312,50,(Texture2D)Resources.Load("Texture/vsComputer")); vsPlayer=new GameTexture(262,50,(Texture2D)Resources.Load("Texture/vsPlayer")); local=new GameTexture(141,50,(Texture2D)Resources.Load("Texture/local")); createRoom=new GameTexture(264,50,(Texture2D)Resources.Load("Texture/createRoom")); joinGame=new GameTexture(236,50,(Texture2D)Resources.Load("Texture/joinGame")); yourIPAddress=new GameTexture(297,41,(Texture2D)Resources.Load("Texture/yourIPAddress")); ipAddress=new GameTexture(540,41); waitingForConnection=new GameTexture(405,42,(Texture2D)Resources.Load("Texture/waitingForConnection")); enterAnotherIP=new GameTexture(330,66,(Texture2D)Resources.Load("Texture/enterAnotherIP")); ipSpace=new GameTexture(519,138,(Texture2D)Resources.Load("Texture/ipSpace")); ipTextField=new GameTexture(346,92); connect=new GameTexture(181,50,(Texture2D)Resources.Load("Texture/connect")); synchronization=new GameTexture(452,37,(Texture2D)Resources.Load("Texture/synchronization")); easy=new GameTexture(122,50,(Texture2D)Resources.Load("Texture/easy")); normal=new GameTexture(144,50,(Texture2D)Resources.Load("Texture/normal")); hard=new GameTexture(133,50,(Texture2D)Resources.Load("Texture/hard")); commonBackGround = new GameTexture(0,0,(Texture2D)Resources.Load("Texture/commonBackGround")); firstPage = new GameTexture(0,0,(Texture2D)Resources.Load("Texture/firstPage")); playPage = new GameTexture(0,0,(Texture2D)Resources.Load("Texture/playPage")); backPage2=new GameTexture(back); backPage4=new GameTexture(back); backPage5=new GameTexture(back); backPage6=new GameTexture(back); backPage7=new GameTexture(back); backPage9=new GameTexture(back); backGame=new GameTexture(back); // set coordinate of each GUI element startGame.set(GameGUISettings.screenCenterX-startGame.width/2,GameGUISettings.screenCenterY+startGame.height*3,startGame.width,startGame.height); endGame.set(GameGUISettings.screenCenterX-endGame.width/2,GameGUISettings.screenCenterY+endGame.height*4+GameGUISettings.buttonMargin,endGame.width,endGame.height); practice.set(GameGUISettings.screenCenterX-practice.width/2,GameGUISettings.screenCenterY-(practice.height+GameGUISettings.buttonMargin)*2,practice.width,practice.height); vsComputer.set(GameGUISettings.screenCenterX-vsComputer.width/2,GameGUISettings.screenCenterY-(vsComputer.height+GameGUISettings.buttonMargin),vsComputer.width,vsComputer.height); vsPlayer.set(GameGUISettings.screenCenterX-vsPlayer.width/2,GameGUISettings.screenCenterY,vsPlayer.width,vsPlayer.height); backPage2.set(GameGUISettings.screenCenterX-back.width/2,GameGUISettings.screenCenterY+(back.height+GameGUISettings.buttonMargin),back.width,back.height); checkingNetwork.set(GameGUISettings.screenCenterX-checkingNetwork.width/2,GameGUISettings.screenCenterY-(checkingNetwork.height+GameGUISettings.buttonMargin),checkingNetwork.width,checkingNetwork.height); pleaseWait.set(GameGUISettings.screenCenterX-pleaseWait.width/2,GameGUISettings.screenCenterY,pleaseWait.width+GameGUISettings.buttonMargin,pleaseWait.height); local.set(GameGUISettings.screenCenterX-local.width/2,GameGUISettings.screenCenterY-(local.height+GameGUISettings.buttonMargin),local.width,local.height); backPage4.set(GameGUISettings.screenCenterX-back.width/2,GameGUISettings.screenCenterY+GameGUISettings.buttonMargin,back.width,back.height); createRoom.set(GameGUISettings.screenCenterX-createRoom.width/2,GameGUISettings.screenCenterY-(createRoom.height+GameGUISettings.buttonMargin)*3/2,createRoom.width,createRoom.height); joinGame.set(GameGUISettings.screenCenterX-joinGame.width/2,GameGUISettings.screenCenterY-(joinGame.height+GameGUISettings.buttonMargin)/2,joinGame.width,joinGame.height); backPage5.set(GameGUISettings.screenCenterX-back.width/2,GameGUISettings.screenCenterY+(back.height+GameGUISettings.buttonMargin)/2,back.width,back.height); yourIPAddress.set(GameGUISettings.screenCenterX-yourIPAddress.width/2,GameGUISettings.screenCenterY-(yourIPAddress.height+GameGUISettings.buttonMargin)*2,yourIPAddress.width,yourIPAddress.height); ipAddress.set(GameGUISettings.screenCenterX-ipAddress.width/2,GameGUISettings.screenCenterY-(ipAddress.height+GameGUISettings.buttonMargin),ipAddress.width,ipAddress.height); waitingForConnection.set(GameGUISettings.screenCenterX-waitingForConnection.width/2,GameGUISettings.screenCenterY,waitingForConnection.width,waitingForConnection.height); backPage6.set(GameGUISettings.screenCenterX-back.width/2,GameGUISettings.screenCenterY+(back.height+GameGUISettings.buttonMargin),back.width,back.height); enterAnotherIP.set(GameGUISettings.screenCenterX-enterAnotherIP.width/2,GameGUISettings.screenCenterY-(enterAnotherIP.height+GameGUISettings.buttonMargin)*2,enterAnotherIP.width,enterAnotherIP.height); ipSpace.set(GameGUISettings.screenCenterX-ipSpace.width/2,GameGUISettings.screenCenterY-(ipSpace.height+GameGUISettings.buttonMargin)/3*2,ipSpace.width,ipSpace.height); ipTextField.set(GameGUISettings.screenCenterX-ipTextField.width/2,GameGUISettings.screenCenterY-(ipTextField.height+GameGUISettings.buttonMargin)*3/4,ipTextField.width,ipTextField.height); connect.set(GameGUISettings.screenCenterX-connect.width/2,GameGUISettings.screenCenterY+(connect.height+GameGUISettings.buttonMargin)/2,connect.width,connect.height); backPage7.set(GameGUISettings.screenCenterX-back.width/2,GameGUISettings.screenCenterY+(back.height+GameGUISettings.buttonMargin)*3/2,back.width,back.height); synchronization.set(GameGUISettings.screenCenterX-synchronization.width/2,GameGUISettings.screenCenterY-synchronization.height/2,synchronization.width,synchronization.height); easy.set(GameGUISettings.screenCenterX-easy.width/2,GameGUISettings.screenCenterY-(easy.height+GameGUISettings.buttonMargin)*2,easy.width,easy.height); normal.set(GameGUISettings.screenCenterX-normal.width/2,GameGUISettings.screenCenterY-(normal.height+GameGUISettings.buttonMargin),normal.width,normal.height); hard.set(GameGUISettings.screenCenterX-hard.width/2,GameGUISettings.screenCenterY,hard.width,hard.height); backPage9.set(GameGUISettings.screenCenterX-back.width/2,GameGUISettings.screenCenterY+(back.height+GameGUISettings.buttonMargin),back.width,back.height); up.set(GameGUISettings.screenCenterX-up.width/2,GameGUISettings.buttonOffsetY+GameGUISettings.treasureMargin,up.width,up.height); down.set(GameGUISettings.screenCenterX-down.width/2,GameGUISettings.buttonOffsetY+GameGUISettings.treasureMargin+down.height*5/2,down.width,down.height); left.set(GameGUISettings.screenCenterX-left.width*15/8,GameGUISettings.buttonOffsetY+GameGUISettings.treasureMargin+left.height*5/4,left.width,left.height); right.set(GameGUISettings.screenCenterX+right.width*7/8,GameGUISettings.buttonOffsetY+GameGUISettings.treasureMargin+right.height*5/4,right.width,right.height); confirm.set(GameGUISettings.screenCenterX+confirm.width,GameGUISettings.buttonOffsetY+GameGUISettings.treasureMargin+confirm.height*5/2,confirm.width,confirm.height); treasureRemainBG.set(GameGUISettings.screenCenterX-treasureRemainBG.width*5/3,GameGUISettings.buttonOffsetY+GameGUISettings.treasureMargin+treasureRemainBG.height*4/5,treasureRemainBG.width,treasureRemainBG.height); yoursOthers.set(WindowSettings.startX+yoursOthers.width/5,WindowSettings.startY+yoursOthers.height/5,yoursOthers.width,yoursOthers.height); yours.set(WindowSettings.startX+yours.width*6/5,WindowSettings.startY+yoursOthers.height/5,yours.width,yours.height); others.set(WindowSettings.startX+others.width*6/5,WindowSettings.startY+yoursOthers.height/5+others.height,others.width,others.height); waitForYourTurn.set(GameGUISettings.screenCenterX-waitForYourTurn.width/2,GameGUISettings.buttonOffsetY+waitForYourTurn.height/2,waitForYourTurn.width,waitForYourTurn.height); youWin.set(GameGUISettings.screenCenterX-youWin.width/2,GameGUISettings.buttonOffsetY+youWin.height/2,youWin.width,youWin.height); youLost.set(GameGUISettings.screenCenterX-youLost.width/2,GameGUISettings.buttonOffsetY+youLost.height/2,youLost.width,youLost.height); endConfirm.set(GameGUISettings.screenCenterX-endConfirm.width/2,GameGUISettings.buttonOffsetY+youWin.height*3/2,endConfirm.width,endConfirm.height); backGame.set(WindowSettings.startX+WindowSettings.screenWidth-backGame.width*4/3,WindowSettings.startY+backGame.height,backGame.width,backGame.height); }
public static void GenerateRenderTargetTextures(GraphicsDevice MainGraphicsDevice) { Grid = new GameTexture(GenerateGridRenderTarget.GenerateGridTexture(MainGraphicsDevice), new Rectangle(0, 0, 32 * 8, 32 * 8)); }
/// <summary> /// Adds the texture. /// </summary> /// <param name="assetName">Name of the asset.</param> public void AddTexture(string assetName) { ITexture texture = new GameTexture(Game, assetName); texture.LoadContent(); _items.Add(assetName, texture); }
public abstract bool UpdateTile(GameTexture texture, float x, float y, int srcX, int srcY, int srcW, int srcH);
/// <summary> /// Textures the object using GLCore's GameTexture object. /// </summary> /// <param name="texture"></param> public void Texture(GameTexture texture) { this.Texture(texture.texture, texture.width, texture.height); }
public override bool AddTile(GameTexture tex, float x, float y, int srcX, int srcY, int srcW, int srcH) { var platformTex = tex?.GetTexture(); if (platformTex == null) { return(false); } if (Texture == null) { Texture = tex; } else if (Texture.GetTexture() != platformTex) { return(false); } if (vertexBuffer != null) { return(false); } var rotated = false; var pack = tex.GetTexturePackFrame(); if (pack != null) { if (pack.Rotated) { rotated = true; var z = srcX; srcX = pack.Rect.Right - srcY - srcH; srcY = pack.Rect.Top + z; z = srcW; srcW = srcH; srcH = z; } else { srcX += pack.Rect.X; srcY += pack.Rect.Y; } } var texture = (Texture2D)tex.GetTexture(); var textureSizeX = 1f / texture.Width; var textureSizeY = 1f / texture.Height; var left = srcX * textureSizeX; var right = (srcX + srcW) * textureSizeX; var bottom = (srcY + srcH) * textureSizeY; var top = srcY * textureSizeY; verticeDict.Add(new Tuple <float, float>(x, y), vertices.Count); if (rotated) { vertices.Add(new VertexPositionTexture(new Vector3(x, y + srcH, 0), new Vector2(left, top))); vertices.Add(new VertexPositionTexture(new Vector3(x, y, 0), new Vector2(right, top))); vertices.Add(new VertexPositionTexture(new Vector3(x + srcW, y + srcH, 0), new Vector2(left, bottom))); vertices.Add(new VertexPositionTexture(new Vector3(x + srcW, y, 0), new Vector2(right, bottom))); } else { vertices.Add(new VertexPositionTexture(new Vector3(x, y + srcH, 0), new Vector2(left, bottom))); vertices.Add(new VertexPositionTexture(new Vector3(x, y, 0), new Vector2(left, top))); vertices.Add(new VertexPositionTexture(new Vector3(x + srcW, y + srcH, 0), new Vector2(right, bottom))); vertices.Add(new VertexPositionTexture(new Vector3(x + srcW, y, 0), new Vector2(right, top))); } indices.Add((short)vertexCount); indices.Add((short)(vertexCount + 1)); indices.Add((short)(vertexCount + 2)); indices.Add((short)(vertexCount + 2)); indices.Add((short)(vertexCount + 1)); indices.Add((short)(vertexCount + 3)); vertexCount += 4; return(true); }
protected override void OnInit() { base.OnInit(); this.m_texture = Make <GameTexture>(gameObject); }
public static void init() { Engine e = GlobalHelper.getInstance().getEngine(); blank_ = new GameTexture(@"Sprites\blank"); }
public override void DrawName(Color textColor, Color borderColor, Color backgroundColor) { if (HideName || Name.Trim().Length == 0) { return; } if (!WorldPos.IntersectsWith(Graphics.Renderer.GetView())) { return; } if (MapInstance.Get(CurrentMap) == null || !Globals.GridMaps.Contains(CurrentMap)) { return; } var y = (int)Math.Ceiling(GetCenterPos().Y); var x = (int)Math.Ceiling(GetCenterPos().X); var height = Options.TileHeight; switch (Graphic.Type) { case EventGraphicType.Sprite: //Sprite var entityTex = Globals.ContentManager.GetTexture( GameContentManager.TextureType.Entity, Graphic.Filename ); if (entityTex != null) { height = entityTex.GetHeight(); } break; case EventGraphicType.Tileset: //Tile if (mCachedTilesetName != Graphic.Filename) { mCachedTilesetName = Graphic.Filename; mCachedTileset = Globals.ContentManager.GetTexture( GameContentManager.TextureType.Tileset, Graphic.Filename ); } if (mCachedTileset != null) { height = (Graphic.Height + 1) * Options.TileHeight; } break; } y = (int)GetTopPos(height) - 12; x = (int)Math.Ceiling(GetCenterPos().X); if (Graphic.Type == EventGraphicType.Tileset) { y -= 12; } var textSize = Graphics.Renderer.MeasureText(Name, Graphics.EntityNameFont, 1); if (CustomColors.Names.Events.Background != Color.Transparent) { Graphics.DrawGameTexture( Graphics.Renderer.GetWhiteTexture(), new FloatRect(0, 0, 1, 1), new FloatRect(x - textSize.X / 2f - 4, y, textSize.X + 8, textSize.Y), CustomColors.Names.Events.Background ); } Graphics.Renderer.DrawString( Name, Graphics.EntityNameFont, (int)(x - (int)Math.Ceiling(textSize.X / 2f)), (int)y, 1, Color.FromArgb(CustomColors.Names.Events.Name.ToArgb()), true, null, Color.FromArgb(CustomColors.Names.Events.Outline.ToArgb()) ); }
static MiniKraidController() { s_spikeTexture = new GameTexture(c_SpikeTexturePath); }
public static void init() { blank_ = TextureMap.getInstance().getTexture("blank"); }
/// <summary> /// Loads an AnimationSet into the AnimationController. /// </summary> /// <param name="animSetPath">Asset path to the AnimationSet.</param> /// <param name="texturePath">Asset path to the image file to use.</param> public AnimationController(string animSetPath, string texturePath, string initialAnim) { this.Color = Color.White; this.Scale = 1.0f; this.Rotation = 0.0f; this.DrawBottomCenter = true; m_animSet = GlobalHelper.loadContent<AnimationSet>(animSetPath); // Build up a mapping of animation & sprite indices to image dimension idxs List<Rectangle> imageDimensionsList = new List<Rectangle>(); int counter = 0; m_sourceRectangleIdxs = new int[m_animSet.anims.Length][]; for (int i = 0; i < m_animSet.anims.Length; ++i) { m_sourceRectangleIdxs[i] = new int[m_animSet.anims[i].sprites.Length]; for (int j = 0; j < m_animSet.anims[i].sprites.Length; ++j) { imageDimensionsList.Add(m_animSet.anims[i].sprites[j].box); m_sourceRectangleIdxs[i][j] = counter; counter++; } } Texture = new GameTexture(texturePath, imageDimensionsList.ToArray()); if (!String.IsNullOrEmpty(initialAnim)) { requestAnimation(initialAnim); } }
protected override void OnInit() { this.m_imgSceneThumb = Make <GameTexture>("RawImage"); this.m_lbSceneName = Make <GameLabel>("Text"); }
public static FloatRect GetSourceRect(GameTexture gameTexture) { return(gameTexture == null ? new FloatRect() : new FloatRect(0, 0, gameTexture.GetWidth(), gameTexture.GetHeight())); }
private void DrawAutoTile( int layerNum, float destX, float destY, int quarterNum, int x, int y, int forceFrame, GameTexture tileset, GameTileBuffer buffer, bool update = false ) { int yOffset = 0, xOffset = 0; // calculate the offset switch (Layers[layerNum].Tiles[x, y].Autotile) { case MapAutotiles.AUTOTILE_WATERFALL: yOffset = (forceFrame - 1) * Options.TileHeight; break; case MapAutotiles.AUTOTILE_ANIM: xOffset = forceFrame * Options.TileWidth * 2; break; case MapAutotiles.AUTOTILE_ANIM_XP: xOffset = forceFrame * Options.TileWidth * 3; break; case MapAutotiles.AUTOTILE_CLIFF: yOffset = -Options.TileHeight; break; } if (update) { if (!buffer.UpdateTile( tileset, destX, destY, (int)Autotiles.Autotile[x, y].Layer[layerNum].QuarterTile[quarterNum].X + xOffset, (int)Autotiles.Autotile[x, y].Layer[layerNum].QuarterTile[quarterNum].Y + yOffset, Options.TileWidth / 2, Options.TileHeight / 2 )) { throw new Exception("Failed to update tile to VBO!"); } } else { if (!buffer.AddTile( tileset, destX, destY, (int)Autotiles.Autotile[x, y].Layer[layerNum].QuarterTile[quarterNum].X + xOffset, (int)Autotiles.Autotile[x, y].Layer[layerNum].QuarterTile[quarterNum].Y + yOffset, Options.TileWidth / 2, Options.TileHeight / 2 )) { throw new Exception("Failed to add tile to VBO!"); } } }
public void setImage(GameTexture image) { image_ = image; }
public EngineStateSplash(Engine engine) { engine_ = engine; //splash_ = new GameTexture(@"Sprites\splash", engine.spriteBatch_, engine.GraphicsDevice, engine_.Content); splash_ = new GameTexture(@"Sprites\splash"); }
public TextureChanger(GameWindow window) { overlay = GameTexture.Load("overlay.png"); window.KeyPress += OnKeyPress; }
public EngineStateSplash(Engine engine) { m_engine = engine; m_splash = new GameTexture(@"Sprites\splash2"); }
public override void DrawTexture( GameTexture tex, float sx, float sy, float sw, float sh, float tx, float ty, float tw, float th, Color renderColor, GameRenderTexture renderTarget = null, GameBlendModes blendMode = GameBlendModes.None, GameShader shader = null, float rotationDegrees = 0, bool isUi = false, bool drawImmediate = false ) { var texture = tex?.GetTexture(); if (texture == null) { return; } var packRotated = false; var pack = tex.GetTexturePackFrame(); if (pack != null) { if (pack.Rotated) { rotationDegrees -= 90; var z = tw; tw = th; th = z; z = sx; sx = pack.Rect.Right - sy - sh; sy = pack.Rect.Top + z; z = sw; sw = sh; sh = z; packRotated = true; } else { sx += pack.Rect.X; sy += pack.Rect.Y; } } var origin = Vector2.Zero; if (Math.Abs(rotationDegrees) > 0.01) { rotationDegrees = (float)(Math.PI / 180 * rotationDegrees); origin = new Vector2(sw / 2f, sh / 2f); //TODO: Optimize in terms of memory AND performance. var pnt = new Pointf(0, 0); var pnt1 = new Pointf((float)tw, 0); var pnt2 = new Pointf(0, (float)th); var cntr = new Pointf((float)tw / 2, (float)th / 2); var pntMod = Rotate(pnt, cntr, rotationDegrees); var pntMod2 = Rotate(pnt1, cntr, rotationDegrees); var pntMod3 = Rotate(pnt2, cntr, rotationDegrees); var width = (int)Math.Round(GetDistance(pntMod.X, pntMod.Y, pntMod2.X, pntMod2.Y)); var height = (int)Math.Round(GetDistance(pntMod.X, pntMod.Y, pntMod3.X, pntMod3.Y)); if (packRotated) { var z = width; width = height; height = z; } tx += width / 2f; ty += height / 2f; } if (renderTarget == null) { if (isUi) { tx += mCurrentView.X; ty += mCurrentView.Y; } StartSpritebatch(mCurrentView, blendMode, shader, null, false, null, drawImmediate); mSpriteBatch.Draw( (Texture2D)texture, new Vector2(tx, ty), new XNARectangle((int)sx, (int)sy, (int)sw, (int)sh), ConvertColor(renderColor), rotationDegrees, origin, new Vector2(tw / sw, th / sh), SpriteEffects.None, 0 ); } else { StartSpritebatch( new FloatRect(0, 0, renderTarget.GetWidth(), renderTarget.GetHeight()), blendMode, shader, renderTarget, false, null, drawImmediate ); mSpriteBatch.Draw( (Texture2D)texture, new Vector2(tx, ty), new XNARectangle((int)sx, (int)sy, (int)sw, (int)sh), ConvertColor(renderColor), rotationDegrees, origin, new Vector2(tw / sw, th / sh), SpriteEffects.None, 0 ); } }
private void OnKeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 'r') { GL.DeleteTexture(owner.model.meshes[0].textures[0].textureID); owner.model.meshes[0].textures[0] = GameTexture.Load("runicfloor.png"); isDebuggingInterpreter = false; } else if (e.KeyChar == 'f' || isDebuggingInterpreter) { if (!isDebuggingInterpreter) { string filename = Console.ReadLine(); while (!File.Exists(filename)) { filename = Console.ReadLine(); } fli = FilterLangInterpreter.CreateWithEmptyInput(filename, 512, 512, 1, 4); } FilterLangInterpreter.InterpreterStepResult res = new FilterLangInterpreter.InterpreterStepResult(); if (isDebuggingInterpreter) { this.Log("Continuing Execution", DebugChannel.Log, 10); isDebuggingInterpreter = false; } byte[] buf = null; do { if (res.triggeredDebug) { this.Log("Triggered Debug.", DebugChannel.Log, 10); isDebuggingInterpreter = true; buf = CLFilterAPI.ReadBuffer <byte>(res.debugBuffer); break; } } while (!(res = fli.Step()).terminated); if (!isDebuggingInterpreter) { buf = fli.GetResult(); } else if (buf == null) { throw new InvalidOperationException("F**K"); } GameTexture.Update(owner.model.meshes[0].textures[0], buf, 512, 512); } else if (e.KeyChar == ' ') { CLFilterAPI.GetInstance().RunLightKernel(owner.model.meshes[0].textures[0]); } else if (e.KeyChar == 'o') { CLFilterAPI.GetInstance().RunOverlayKernel(owner.model.meshes[0].textures[0], overlay, 0.5f); } else if (e.KeyChar == 'c') { CLFilterAPI.GetInstance().RunCheckerBoardKernel(owner.model.meshes[0].textures[0], 5f); } else if (e.KeyChar == 'w') { CreateWorley(); } else if (e.KeyChar == 's') { CLFilterAPI.GetInstance().RunSmoothNoise(owner.model.meshes[0].textures[0], 4); } else if (e.KeyChar == 'p') { GL.DeleteTexture(owner.model.meshes[0].textures[0].textureID); owner.model.meshes[0].textures[0] = CLFilterAPI.GetInstance().GetPerlin(512, 512, 6, 0.9f); } else if (e.KeyChar == 't') { string[] filenames = Directory.GetFiles("filter/tests", "*.fl"); this.Log("Running tests...", DebugChannel.Log, 10); foreach (string filename in filenames) { fli = FilterLangInterpreter.CreateWithEmptyInput(filename, 512, 512, 1, 4); this.Log("Running Test File: " + filename, DebugChannel.Log, 10); FilterLangInterpreter.InterpreterStepResult res = new FilterLangInterpreter.InterpreterStepResult(); do { } while (!(res = fli.Step()).terminated); } this.Log("Finished Running Tests", DebugChannel.Log, 10); GL.DeleteTexture(owner.model.meshes[0].textures[0].textureID); owner.model.meshes[0].textures[0] = GameTexture.Load("runicfloor.png"); } }
public Bullet(GameTexture texture, List<DrawableObjectAbstract> pipeline, CollisionDetectorInterface detector, Vector2 position, Vector2 direction) : base(pipeline, texture, detector, new ConvexPolygon(BOUNDS_POINTS, Vector2.Zero), RADIUS, HEIGHT, direction * SPEED, position, direction, DEPTH) { damage_ = DAMAGE; }