public bool containsDataControl(ElementReferenceDataControl dataControl) { foreach (ElementContainer container in allReferencesDataControl) { if (!container.isPlayer() && container.getErdc() == dataControl) { return(true); } } return(false); }
/** * Constructor. * * @param sceneDataControl * Link to the parent scene controller * @param itemReferencesList * List of item references */ public ReferencesListDataControl(string playerImagePath, SceneDataControl sceneDataControl, List <ElementReference> itemReferencesList, List <ElementReference> atrezzoReferencesList, List <ElementReference> npcReferencesList) { this.playerImagePath = playerImagePath; this.sceneDataControl = sceneDataControl; this.itemReferencesList = itemReferencesList; this.atrezzoReferencesList = atrezzoReferencesList; this.npcReferencesList = npcReferencesList; this.allReferencesDataControl = new List <ElementContainer>(); this.lastElementContainer = null; this.playerPositionInAllReferences = NO_PLAYER; this.imagePathHasChanged = false; // Check if one of references has layer -1: if it is true, it means that element references has no layer. // Create subcontrollers bool hasLayerV = hasLayer(); foreach (ElementReference itemReference in itemReferencesList) { int counter = count(itemReference); ElementReferenceDataControl erdc = new ElementReferenceDataControl(sceneDataControl, itemReference, Controller.ITEM_REFERENCE, counter); insertInOrder(new ElementContainer(erdc, -1, null), hasLayerV); } foreach (ElementReference atrezzoReference in atrezzoReferencesList) { int counter = count(atrezzoReference); ElementReferenceDataControl erdc = new ElementReferenceDataControl(sceneDataControl, atrezzoReference, Controller.ATREZZO_REFERENCE, counter); insertInOrder(new ElementContainer(erdc, -1, null), hasLayerV); } foreach (ElementReference npcReference in npcReferencesList) { int counter = count(npcReference); ElementReferenceDataControl erdc = new ElementReferenceDataControl(sceneDataControl, npcReference, Controller.NPC_REFERENCE, counter); insertInOrder(new ElementContainer(erdc, -1, null), hasLayerV); } // insert player // by default, if player don´t have layer, we give it to him. if (playerImagePath != null && (!Controller.getInstance().isPlayTransparent()) && sceneDataControl.isForcedPlayerLayer()) { int layer; if (sceneDataControl.getPlayerLayer() == Scene.PLAYER_WITHOUT_LAYER) { layer = 0; } else { layer = sceneDataControl.getPlayerLayer(); } reassignLayerAllReferencesDataControl(insertInOrder(new ElementContainer(null, layer, AssetsController.getImage(this.playerImagePath)), true)); } }
/** * Constructor. When erdc has value, takes the element reference data * control for references to atrezzo, items or non-player characters, * putting player layer with its non-valid value. Takes playerLayer for * player, when erdc is null. * * @param erdc * the element reference data control * @param playerLayer * the layer to show the player in the correct position * @param image * the image of the player */ public ElementContainer(ElementReferenceDataControl erdc, int playerLayer, Sprite image) { if (erdc != null) { this.erdc = erdc; this.playerLayer = -1; this.image = null; } else { this.playerLayer = playerLayer; this.image = image; } }
public override bool addElement(int type, string id) { bool elementAdded = false; string selectedItem = id; if (type == Controller.ITEM_REFERENCE) { // Take the list of the items string[] items = controller.getIdentifierSummary().getItemIds(); // If the list has elements, show the dialog with the options if (items.Length > 0) { // If some value was selected if (selectedItem != null) { ElementReference newElementReference = new ElementReference(selectedItem, 50, 50); int counter = count(newElementReference); ElementReferenceDataControl erdc = new ElementReferenceDataControl(sceneDataControl, newElementReference, type, counter); itemReferencesList.Add(newElementReference); ElementContainer ec = new ElementContainer(erdc, -1, null); lastElementContainer = ec; reassignLayerAllReferencesDataControl(insertInOrder(ec, false)); elementAdded = true; } } else { controller.showErrorDialog(TC.get("Operation.AddItemReferenceTitle"), TC.get("Operation.AddItemReferenceErrorNoItems")); } } if (type == Controller.ATREZZO_REFERENCE) { string[] items = controller.getIdentifierSummary().getAtrezzoIds(); // If the list has elements, show the dialog with the options if (items.Length > 0) { if (selectedItem != null) { ElementReference newElementReference = new ElementReference(selectedItem, 50, 50); int counter = count(newElementReference); ElementReferenceDataControl erdc = new ElementReferenceDataControl(sceneDataControl, newElementReference, type, counter); atrezzoReferencesList.Add(newElementReference); ElementContainer ec = new ElementContainer(erdc, -1, null); lastElementContainer = ec; reassignLayerAllReferencesDataControl(insertInOrder(ec, false)); elementAdded = true; } } else { controller.showErrorDialog(TC.get("Operation.AddAtrezzoReferenceTitle"), TC.get("Operation.AddReferenceErrorNoAtrezzo")); } } if (type == Controller.NPC_REFERENCE) { string[] items = controller.getIdentifierSummary().getNPCIds(); if (items.Length > 0) { if (selectedItem != null) { ElementReference newElementReference = new ElementReference(selectedItem, 50, 50); int counter = count(newElementReference); ElementReferenceDataControl erdc = new ElementReferenceDataControl(sceneDataControl, newElementReference, type, counter); npcReferencesList.Add(newElementReference); ElementContainer ec = new ElementContainer(erdc, -1, null); lastElementContainer = ec; reassignLayerAllReferencesDataControl(insertInOrder(ec, false)); elementAdded = true; } } else { controller.showErrorDialog(TC.get("Operation.AddNPCReferenceTitle"), TC.get("Operation.AddReferenceErrorNoNPC")); } } return(elementAdded); }