// Use this for initialization void Start() { ManagerGame = Manager.GetComponent("GameManager") as GameManager; //PlayerItens = GetComponent<PlayerItens>(); HandlerItem = GetComponent <ItemHandler>(); ouro = new Coletavel(); prata = new Coletavel(); bronze = new Coletavel(); diamante = new Coletavel(); ferro = new Coletavel(); fuel = 100; HP = 100; timerAux = 10; colorz = new List <Color>(); //cor_Inicial = renderer.material.color; cubez = transform.GetComponentsInChildren <SkinnedMeshRenderer>(); for (int i = 0; i < cubez.Length; i++) { Material[] matz = cubez[i].materials; foreach (Material mat in matz) { colorz.Add(mat.color); } } TargetXp = (level * level) + (level * 200); Vector2 initialPosition = new Vector2(9.5f, 1f); PlacesToGo.Add(initialPosition); }
void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent <Coletavel>()) { Coletavel coletavel = other.GetComponent <Coletavel>(); ColletableItem(coletavel); Destroy(coletavel.gameObject); } }
public void DropItens(Itens item) { GameObject tmpDrop = Instantiate(item.itemDrop, localDrop.position, Quaternion.identity) as GameObject; Coletavel tmpClt = tmpDrop.GetComponent <Coletavel>(); tmpClt.nomeItem = item.nomes; tmpClt.amount = item.amount; if (item.type == Type.RECURSO || item.type == Type.CONSUMIVEL) { listItens.Add(item); } }
private void Collect(Coletavel coletavel) { if (coletavel.Collect()) { if (coletavel is Comida) { comida++; } if (coletavel is Lixo) { comida++; } } { } }
public void ColletableItem(Coletavel coletavel) { for (int l = 0; l < listItens.Count; l++) { foreach (var i in inv.inventairo) { if (listItens[l].nomes == i.nomes) { listItens.Remove(listItens[l]); break; } } } foreach (Itens item in inv.inventairo) { if (coletavel.nomeItem == item.nomes) { if (item.type == Type.RECURSO || item.type == Type.CONSUMIVEL) { item.amount += coletavel.amount; Destroy(coletavel.gameObject); } } } for (int i = 0; i < listItens.Count; i++) { if (coletavel.nomeItem == listItens[i].nomes) { inv.AddItens(coletavel.nomeItem, coletavel.amount); Destroy(coletavel.gameObject); if (listItens[i].type == Type.RECURSO || listItens[i].type == Type.CONSUMIVEL) { listItens.Remove(listItens[i]); } break; } } }