public void ActivateGemFromPooler(int gemIndex, Vector3 position) { if (goList != null) { foreach (GameObject go in goList) { if (go != null) { if (!go.activeSelf && go.name == Constants.Loot_Gems.GENERIC_GEM_NAME) { go.SetActive(true); LootPickupScript lps = go.GetComponent <LootPickupScript>(); Loot_GemScript lgs = go.GetComponent <Loot_GemScript>(); lps.ResetPickup(); lgs.SetSprite(gemIndex); Rigidbody2D rb = go.GetComponent <Rigidbody2D>(); var randomForceMult = Random.Range(0f, 2f); rb.velocity = Random.onUnitSphere * randomForceMult; go.transform.position = position; break; } } } } }
public void sellLoot(int i) { if (getLoot(i).Item2 != null) { LootPickupScript tempLoot = loot[i].GetComponent <LootPickupScript>(); removeLoot(-1, tempLoot.lootID); addMoney(tempLoot.lootValue); } }
public int checkHasLoot(string id) { for (int i = 0; i < loot.Count; i++) { LootPickupScript tempLoot = loot[i].GetComponent <LootPickupScript>(); if (tempLoot.lootID.Contains(id) || id.Contains(tempLoot.lootID)) { return(i); } } return(-1); }
public (int, string) getLoot(int i) { if (i < loot.Count) { LootPickupScript tempLoot = loot[i].GetComponent <LootPickupScript>(); return(tempLoot.lootValue, tempLoot.lootID); } else { return(0, null); } }
// Aktivoi poolerista halutun objektin, haluttuun paikkaan kentässä public void ActivateFromPooler(int whichLootIndex, Vector3 position) { if (goList != null) { foreach (GameObject go in goList) { if (go != null) { if (!go.activeSelf && go.name == GetLootsNameByIndex(whichLootIndex)) { LootPickupScript lps = go.GetComponent <LootPickupScript>(); lps.ResetPickup(); go.SetActive(true); go.transform.Translate(position); Debug.Log("Activating " + whichLootIndex + " @" + go.transform.position); break; } } } } }
// Update is called once per frame void Update() { if (flipSprite) { renderer.flipX = !renderer.flipX; flipSprite = false; } if (Input.GetKeyDown(KeyCode.A)) { if (dir == MoveDirection.right) { dir = MoveDirection.left; flipSprite = true; } } if (Input.GetKeyDown(KeyCode.W)) { if (isGrounded) { isGrounded = !isGrounded; } } if (Input.GetKeyDown(KeyCode.D)) { if (dir == MoveDirection.left) { dir = MoveDirection.right; flipSprite = true; } } //if (Input.GetKeyDown(KeyCode.S)) { if (Input.GetMouseButtonDown(0)) { //transform.position += (Vector3.down * speed); isMining = true; } //if (Input.GetKeyUp(KeyCode.S)) { if (Input.GetMouseButtonUp(0)) { //transform.position += (Vector3.down * speed); isMining = false; } // Loot pickup if (Input.GetKeyDown(KeyCode.E)) { LootPoolerScript lps = GameObject.FindGameObjectWithTag("LootPooler").GetComponent <LootPoolerScript>(); lps.FindLootsThatPlayerCanPickup(transform.position, 1); lootalbeList = new List <GameObject>(); var ret = lps.FindLootsThatPlayerCanPickup(transform.position, 1); foreach (GameObject go in ret) { LootPickupScript pickup = go.GetComponent <LootPickupScript>(); pickup.OnPickup(); } } }