- Home /
Remove Upgrades upon click
Hello, I am currently working on a 2D roguelike in similar fashion to nuclear throne, enter the gungeon and such. I am trying to create an upgrade screen similar to nuclear throne's. Example of screen:
In the game, whenever you click on an upgrade, that upgrade is removed for the rest of the run and is displayed in the top right of the screen. I have tried to recreate that but only got so far as the upgrades will show up but all displayed will be removed.
My Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Upgrades : MonoBehaviour
{
public GameObject[] upgradeCards;
public static List<GameObject> deck = new List<GameObject>();
private List<GameObject> equipped = new List<GameObject>();
public GameObject canvas;
// Start is called before the first frame update
void Start()
{
deck.AddRange(upgradeCards);
DisplayThreeCards();
}
// Update is called once per frame
void Update()
{
}
public void DisplayThreeCards()
{
for (int i = 0; i < 3; i++)
{
int number = Random.Range(0, deck.Count);
GameObject card;
card = Instantiate(deck[number]);
card.transform.SetParent(canvas.transform);
card.GetComponent<RectTransform>().localRotation = Quaternion.identity;
equipped.Add(deck[number]);
deck.Remove(deck[number]);
}
}
}
Currently I am only looking for a solution to my upgrades all being removed from the pool, but if anyone also knows how to make that image appear in the top right with the code as well, I would be very happy. Thanks in advance.
Your answer
Follow this Question
Related Questions
Turn-type gameplay and wait until the end of actors movement\action 2 Answers
Roguelike turn movement and smooth step 1 Answer
Raycasting not working on my colliders 1 Answer
How to check if mouse is above or below player? 2 Answers
Modifying the 2D Roguelike Player Script to Expect Other Objects 0 Answers