public void Destinar() { if (control.puntero != null && control.puntero.entity.type == 4 && entity.gatherings.Contains((control.puntero.entity as ResourceSource).gathering) && !ocupado) { fuente = control.puntero; fuente.GetFronterizos(); if (fuente.fronterizos.Count > 0) { Nodo des = fuente.NearestFronterizo(transform.position); pathfinding.destiny = new Vector3(des.x, des.y, 0); pathfinding.pathfinding(); recolectando = true; } } else if (control.puntero != null && control.puntero.entity.type == 2 && entity.creatives.Contains(database.searchAbility("Build Town Center") as Creative)) { cimientos = control.puntero; cimientos.GetFronterizos(); if (cimientos.fronterizos.Count > 0) { Nodo des = cimientos.NearestFronterizo(transform.position); pathfinding.destiny = new Vector3(des.x, des.y, 0); pathfinding.pathfinding(); construyendo = true; } } else if (!ocupado) { pathfinding.destiny = myCamera.ScreenToWorldPoint(Input.mousePosition); pathfinding.pathfinding(); recolectando = false; construyendo = false; } }
public void SpendResources(Seleccionable selec) { for (int i = 0; i < resources.Count; i++) { selec.jugador.resources [resources [i].ID] -= amounts [i]; } }
public void Work(Seleccionable selec) { Token token = selec.entity as Token; if (selec.productionAmount < selec.maxProductionAmount - token.productionRate) { selec.productionAmount += token.productionRate; } else { selec.GetFronterizos(); if (selec.fronterizos.Count > 0) { Seleccionable sele = MonoBehaviour.Instantiate(unitGO, new Vector3(selec.fronterizos [0].x, selec.fronterizos [0].y, 0), Quaternion.identity).GetComponent <Seleccionable>(); sele.jugador = selec.jugador; selec.productionQueue.RemoveAt(0); selec.productionAmount = 0; if (selec.productionQueue.Count > 0) { selec.maxProductionAmount = (selec.productionQueue[0].entity as Token).productionTime; } selec.interfaz.UpdateProductionIcons(); } } }
public void Action(Seleccionable selec) { if (ResourcesRequeridos(selec.jugador)) { if (nombre [0] == "Build Town Center") { Projection projection = MonoBehaviour.Instantiate(projectionGO).GetComponent <Projection> (); projection.building = entity as Building; projection.selec = selec; projection.creative = this; projection.jugador = selec.jugador; selec.ocupado = true; projection.Actualizar(); } else if (nombre [0] == "Create Citizen") { selec.productionQueue.Add(this); selec.interfaz.CreateProductionPanels(); SpendResources(selec); if (selec.productionQueue.Count == 1) { selec.maxProductionAmount = (entity as Token).productionTime; } } } }
void ChangeMainSelection(Seleccionable se) { selecs [selecs.IndexOf(se)] = selecs [0]; selecs [0] = se; for (int i = 1; i < selecs.Count; i++) { selecs [i].Invoke("Deseleccion", 0.04f); } Invoke("UpdateSelection", 0.05f); }
void UpdateHealthBar(Image image, Seleccionable sel) { if (image != null) { if (selecs [0].entity.type == 1 || selecs [0].entity.type == 2) { image.rectTransform.anchorMax = new Vector2(sel.health / (sel.entity as Token).health, image.rectTransform.anchorMax.y); image.rectTransform.offsetMax = new Vector2(0, 0); } } }
// Update is called once per frame void Update() { transform.position = myCamera.ScreenToWorldPoint(Input.mousePosition); if (posible && !CheckPosition()) { mostrarImposible(); } else if (!posible && CheckPosition()) { mostrarPosible(); } else if (!posible && !CheckPosition()) { mostrarImposible(); } if (Input.GetMouseButtonUp(0) || Input.GetKey(KeyCode.Escape)) { selec.ocupado = false; Destroy(gameObject); } if (Input.GetMouseButtonUp(1) && posible) { selec.ocupado = false; GameObject edi = Instantiate(control.building, transform.position, Quaternion.identity); edi.GetComponent <Obstacle> ().entity = building; Seleccionable sel = edi.GetComponent <Seleccionable> (); sel.entity = building; sel.maxBuildAmount = building.productionTime; sel.construido = false; sel.jugador = jugador; sel.GetComponent <SpriteRenderer> ().sprite = building.sprites [1]; creative.SpendResources(selec); selec.Invoke("Destinar", 0.05f); Destroy(gameObject); } }
public void Action(Seleccionable selec) { if (nombre [0] == "Build") { if (selec.buildAmount < selec.maxBuildAmount - value) { selec.buildAmount += value; Building building = selec.entity as Building; selec.gameObject.GetComponent <SpriteRenderer> ().sprite = building.sprites [(int)(1 + (selec.buildAmount / selec.maxBuildAmount) * (building.sprites.Count - 1))]; } else { selec.buildAmount = selec.maxBuildAmount; selec.construido = true; Building building = selec.entity as Building; selec.gameObject.GetComponent <SpriteRenderer> ().sprite = building.sprites [0]; } } if (nombre [0] == "Create") { selec.productionAmount += value; } }
public void CreateSelectionPanels() { ClearButtons(); healthBars.Clear(); if (selecs.Count > 0) { float xMax = sizePanSelectionX; float xMin = margenXSelection; float yMax = margenYSelection; float yMin = margenYSelection - sizePanSelectionY; for (int i = 0; i < selecs.Count; i++) { Seleccionable sel = selecs [i]; GameObject panSelection = Instantiate(genPanSelection, PanelSelections); RectTransform rtrans = panSelection.transform as RectTransform; Entity entity = sel.entity; rtrans.anchorMax = new Vector2(xMax, yMax); rtrans.anchorMin = new Vector2(xMin, yMin); rtrans.offsetMax = new Vector2(0, 0); rtrans.offsetMin = new Vector2(0, 0); xMax += sizePanSelectionX; xMin += sizePanSelectionX; if (xMax > 1) { xMax = sizePanSelectionX; xMin = margenXSelection; yMax -= sizePanSelectionY; yMin -= sizePanSelectionY; } panSelection.GetComponentsInChildren <Image> () [1].sprite = entity.icono; healthBars.Add(rtrans.GetChild(1).GetChild(1).GetComponent <Image>()); panSelection.GetComponentInChildren <Button> ().onClick.AddListener(delegate { ChangeMainSelection(sel); }); } } }
void Awake() { seleccionable = gameObject.GetComponent <Seleccionable> (); }
public void Action(Seleccionable selec) { selec.jugador.resources [resource.ID] += Rate; }