private void TakeCraftedItemCommandsOn() { pressed[GameInput.Accept] = () => { if (aboutToTake) { this.logicalCrafter.Craft(crafted, this.Character); this.Character.GiveItem(this.logicalCrafter.CraftedItem); this.logicalCrafter.CraftedItem = null; this.crafted = null; CraftCommandsOn(); } }; }
public bool CanCraft(ICrafteable item) { return(item.Recipe.CanCraft(this.Inventory.AsIngredients())); }
private void StartCrafting(ICrafteable item) { crafted = item; this.cursor.Color = this.cursorDefaultColor; TakeCraftedItemCommandsOn(); }
private void MainRender() { cursor = arrow; if (crafted != null) { var item = Items.Crafter.Crafteables.Find(elem => elem == crafted); ShaderRepository.ShipAmbientShader.SetValue("lightPosition", new float[4] { 655, 1220, 504, 1 }); ShaderRepository.ShipAmbientShader.SetValue("perlinNoise", perlinNoise); ShaderRepository.ShipAmbientShader.SetValue("time", time); foreach (var mesh in crafted3DModel) { mesh.Effect = ShaderRepository.ShipAmbientShader; ShaderRepository.ShipAmbientShader.SetValue("rotation", Matrix.RotationX(mesh.Rotation.X) * Matrix.RotationY(mesh.Rotation.Y)); mesh.Technique = "CraftedItems"; mesh.RotateY(0.025f); D3DDevice.Instance.Device.RenderState.AlphaBlendEnable = true; mesh.Render(); } //laser1.Render(); //laser2.Render(); item.Icon.Scaling = item.DefaultScale * 4; item.Icon.Position = new TGCVector2( Screen.Width / 2 - item.Icon.Bitmap.Width * item.Icon.Scaling.X / 2, Screen.Height / 2 ); var cursorPos = System.Windows.Forms.Cursor.Position; if ( cursorPos.X > Screen.Width * 0.4f && cursorPos.X < Screen.Width * 0.6f && cursorPos.Y > Screen.Height * 0.3f && cursorPos.Y < Screen.Height * 0.8f ) { cursor = hand; aboutToTake = true; } else { aboutToTake = false; } drawer.BeginDrawSprite(); //drawer.DrawSprite(item.Icon); drawer.DrawSprite(cursor); drawer.EndDrawSprite(); return; } bool hovering = false; int i = 0; dialogBox.Clear(); foreach (var item in Items.Crafter.Crafteables) { item.Icon.Scaling = item.DefaultScale + this.GetScaleForSpriteByPixels(item.Icon, 10, 10); bubble.Position = new TGCVector2(bubbleInitialPos.X, bubbleInitialPos.Y + i++ *bubble.Bitmap.Height * bubble.Scaling.Y); CenterIconToCurrentBubble(item.Icon); if (cursorOverBubble()) { //bubble.Color = Color.Red; ItemHighlighted = item; hoveredItems[Items.Crafter.Crafteables.IndexOf(item)] = true; hovering = true; dialogBox.AddLineBig(item.Name + " ", this.Character.CanCraft(item) ? Color.FromArgb(255, 0, 255, 0) : Color.Red); dialogBox.AddLineSmall("(" + item.type.ToString() + ")", Color.Gray); dialogBox.AddLineSmall("____________________"); dialogBox.AddLineSmall(item.Description); dialogBox.AddLineSmall("____________________"); dialogBox.AddLineSmall("Recipe:"); foreach (var ingredient in item.Recipe.Ingredients) { bool fulfills = this.Character.Inventory.Items.Where(it => it.Name.Equals(ingredient.Item.Name)).Count() >= ingredient.Quantity; dialogBox.AddLineSmall(ingredient.Item.Name + ": " + ingredient.Quantity, fulfills ? Color.FromArgb(255, 0, 255, 0) : Color.Red); } } else { hoveredItems[Items.Crafter.Crafteables.IndexOf(item)] = false; } this.bubble.Color = this.Character.CanCraft(item) ? Color.White : Color.Black; drawer.BeginDrawSprite(); drawer.DrawSprite(bubble); drawer.DrawSprite(item.Icon); drawer.EndDrawSprite(); } if (hovering) { dialogBox.Render(); } this.cursor.Color = hovering ? Color.FromArgb(255, 0, 255, 0) : this.cursorDefaultColor; drawer.BeginDrawSprite(); drawer.DrawSprite(cursor); drawer.EndDrawSprite(); }
private void Render() { this.drawer.BeginDrawSprite(); //this.drawer.DrawSprite(this.PDA); this.drawer.DrawSprite(this.darknessCover); this.drawer.EndDrawSprite(); if (stateID == StateID.CRAFTER) { bool hovering = false; TGCVector2 baseVector = this.PDA.Position + new TGCVector2(100, 175); this.drawer.BeginDrawSprite(); byte xOffset = 110; byte yOffset = 110; byte maxItemsPerLine = 8; byte i = 0; this.itemHighlighted = null; foreach (var item in Items.Crafter.Crafteables) { int x = i % maxItemsPerLine; int y = i / maxItemsPerLine; //text.drawText("-" + i++ + ": " + item.Name + " | " + item.Description + " | " + item.type.ToString(), 500, 300 + 30 * i, Color.White); this.bubble.Position = baseVector + new TGCVector2(xOffset * x, yOffset * y); if (this.cursorOverBubble()) { this.bubble.Scaling = bubbleDefaultScale + this.GetScaleForSpriteByPixels(this.bubble, 10, 10); item.Icon.Scaling = item.DefaultScale + this.GetScaleForSpriteByPixels(item.Icon, 10, 10); hovering = true; this.itemHighlighted = item; } else { this.bubble.Scaling = bubbleDefaultScale; item.Icon.Scaling = item.DefaultScale; } item.Icon.Position = this.bubble.Position + new TGCVector2(7, 19); this.bubble.Color = this.Character.CanCraft(item) ? Color.White : Color.Black; this.drawer.DrawSprite(this.bubble); this.drawer.DrawSprite(item.Icon); ++i; } this.cursor.Color = hovering ? Color.Yellow : this.cursorDefaultColor; this.drawer.DrawSprite(this.cursor); this.drawer.EndDrawSprite(); } //if (stateID == StateID.INVENTORY) //{ // //text.drawText("count: " + count, 500, 270, Color.White); // drawer.BeginDrawSprite(); // //int i = 1; // foreach (var item in gameScene.Character.Inventory.Items) // { // //text.drawText("-" + i++ + ": " + item.Name + " | " + item.Description + " | " + item.type.ToString(), 500, 300 + 30 * i, Color.White); // drawer.DrawSprite(bubble); // } // drawer.DrawSprite(PDA); //} if (this.itemHighlighted != null) { this.drawText.drawText(this.itemHighlighted.Recipe.ToString(), 300, 300, this.Character.CanCraft(this.itemHighlighted) ? Color.Aquamarine : Color.Red); } }