public void SpawnShip(StatVaisseau ship) { vaisseau.GetComponent <Stats>().ship = ship; vaisseau.GetComponent <Stats>().moved = true; vaisseau.GetComponent <Stats>().attacked = true; Instantiate(vaisseau, walkableTilemap.GetCellCenterWorld(clickPos), Quaternion.identity); GetComponent <AudioSource>().clip = buySound; GetComponent <AudioSource>().Play(); money = money - price; stationUI.SetActive(false); ResetTilemap(); spawn = false; chosen.GetComponent <StationState>().spawned = true; }
public void Spawning(StatVaisseau ship) { actualShip = ship; price = ship.prix; if (money >= price) { spawn = true; ResetTilemap(); startTile = walkableTilemap.WorldToCell(chosen.transform.position); selectable = GetWalkableTiles(1, startTile); ColorWalkable(); } else { GetComponent <AudioSource>().clip = wrongSound; GetComponent <AudioSource>().Play(); cdActif = true; feedback.gameObject.SetActive(true); feedback.text = "Not Enough Mineral"; } stationUI.SetActive(false); }
void Update() { if (cdActif == true) { cd = cd - Time.deltaTime; } if (cd <= 0) { feedback.gameObject.SetActive(false); cdActif = false; cd = 5.0f; } textM.text = money.ToString(); allyStation = allyStation.Union(GameObject.FindGameObjectsWithTag(TagFilterAlly)).ToList(); allyStation = allyStation.Union(GameObject.FindGameObjectsWithTag(TagFilterCoreStation)).ToList(); allShips = selection.allShips; allyShips = selection.allyShips; ActualiseShipPos(); nbStation = allyStation.Count; textIncome.text = "(+" + (((allyStation.Count - 1) * 500) + 2000) + ")"; limit = baseCount + allyStation.Count; if (allyShips.Count < limit) { usable = true; } else { usable = false; } textLimit.text = "Max : " + allyShips.Count.ToString() + "/" + limit; if (Input.GetMouseButtonDown(0) && turn == true && usable == true && selection.selected == false) { if (spawn == false) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, Mathf.Infinity, mask); if (hit.collider != null) { if (hit.collider.tag == TagFilterAlly || hit.collider.tag == TagFilterCoreStation) { if (hit.collider.gameObject.GetComponent <StationState>().spawned == false) { chosen = hit.collider.gameObject; stationUI.SetActive(true); } } } } else { Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); clickPos = walkableTilemap.WorldToCell(mouseWorldPos); for (int i = 0; i < selectable.Count; i++) { if (clickPos == selectable[i]) { for (int j = 0; j < allShipsPos.Count; j++) { if (clickPos != allShipsPos[j]) { SpawnShip(actualShip); actualShip = null; chosen = null; break; } } } } actualShip = null; ResetTilemap(); chosen = null; spawn = false; } } }
public void InfoShip2(StatVaisseau ship) { Image.GetComponent<Image>().sprite = ship.sprite2; text.text = "Price : " + ship.prix + "\n" + "HP : " + ship.health + "\n" + "Range : " + ship.portée + "\n" + "Movement : " + ship.mvt + "\n" + "Damage : " + ship.dmgMin + " to " + ship.dmgMax; }