/* * This method starts a new build for background objects * timeBeforeFinish: The time it takes to build the object (in seconds) * element: The object to build * */ public void startBuild(float timeBeforeFinish, BackgroundObject element) { Console.WriteLine("StartBuild"); timeBeforeBuildFinish.Add(timeBeforeFinish); counterForEachBuild.Add(0.0f); elementsToBuild.Add(element); }
public void onMouseHover(BackgroundObject backgroundObject) { Character player1 = SceneManager.getInstance.getPlayer1(); bool doAction = player1.getDoAction(); string name = backgroundObject.Name; hoveringOverThisFrame = true; if (name != null) { Vector2 playerPos = player1.Properties.getProperty <Vector2>("Position"); Vector2 staticObjectPos = backgroundObject.Properties.getProperty <Vector2>("Position"); Vector2 newVector = playerPos - staticObjectPos; float distance = newVector.Length(); if (distance <= backgroundObject.getInteractionDistance()) { if (name == "Field" || name == "FieldWithFood") // || name == "FieldFertilised" { backgroundObject.setMouseIsHovering(true); if (name == "Field") { if (SceneManager.getInstance.getPlayer1().hasShovel()) { foreach (KeyValuePair <string, Texture2D> texture in ResourceManager.getInstance.getRuntimeTextures()) { if (texture.Key == "Pickaxe") { Properties.updateProperty <Texture2D>("Texture2D", texture.Value); } } } } else if (name == "FieldWithFood") { foreach (KeyValuePair <string, Texture2D> texture in ResourceManager.getInstance.getRuntimeTextures()) { if (texture.Key == "Mouse") { Properties.updateProperty <Texture2D>("Texture2D", texture.Value); } } } if (doAction) { backgroundObject.onInteract(); } } else { } } } }
public void onMouseNotHover(BackgroundObject backgroundObject) { if (backgroundObject.isMouseHovering()) { foreach (KeyValuePair <string, Texture2D> texture in ResourceManager.getInstance.getRuntimeTextures()) { if (texture.Key == "Mouse") { Properties.updateProperty <Texture2D>("Texture2D", texture.Value); } } if (backgroundObject.Properties.getProperty <Color>("Color") != Color.White) { backgroundObject.Properties.updateProperty <Color>("Color", Color.White); } backgroundObject.setMouseIsHovering(false); } }
public void onMouseNotHover(BackgroundObject backgroundObject) { if (backgroundObject.isMouseHovering()) { foreach (KeyValuePair<string, Texture2D> texture in ResourceManager.getInstance.getRuntimeTextures()) { if (texture.Key == "Mouse") { Properties.updateProperty<Texture2D>("Texture2D", texture.Value); } } if (backgroundObject.Properties.getProperty<Color>("Color") != Color.White) { backgroundObject.Properties.updateProperty<Color>("Color", Color.White); } backgroundObject.setMouseIsHovering(false); } }
public void onMouseHover(BackgroundObject backgroundObject) { Character player1 = SceneManager.getInstance.getPlayer1(); bool doAction = player1.getDoAction(); string name = backgroundObject.Name; hoveringOverThisFrame = true; if (name != null) { Vector2 playerPos = player1.Properties.getProperty<Vector2>("Position"); Vector2 staticObjectPos = backgroundObject.Properties.getProperty<Vector2>("Position"); Vector2 newVector = playerPos - staticObjectPos; float distance = newVector.Length(); if (distance <= backgroundObject.getInteractionDistance()) { if (name == "Field" || name == "FieldWithFood") // || name == "FieldFertilised" { backgroundObject.setMouseIsHovering(true); if (name == "Field") { if (SceneManager.getInstance.getPlayer1().hasShovel()) { foreach (KeyValuePair<string, Texture2D> texture in ResourceManager.getInstance.getRuntimeTextures()) { if (texture.Key == "Pickaxe") { Properties.updateProperty<Texture2D>("Texture2D", texture.Value); } } } } else if (name == "FieldWithFood") { foreach (KeyValuePair<string, Texture2D> texture in ResourceManager.getInstance.getRuntimeTextures()) { if (texture.Key == "Mouse") { Properties.updateProperty<Texture2D>("Texture2D", texture.Value); } } } if (doAction) { backgroundObject.onInteract(); } } else { } } } }
public BuildBackground(bool active, int index, BackgroundObject backObject) { this.active = active; this.index = index; this.backObject = backObject; }
public void addElementToBuild(BackgroundObject backObject, int index) { objectsToBuild.Add(new BuildBackground(true, index, backObject)); }