// LASERS SHOULD HAVE THEIR OWN TAGS AND NOT BE DESTROYED ON BLOCK private void OnTriggerEnter2D(Collider2D collision) { bool triggerCounter = false; for (int i = 0; i < tags.Length; i++) { if (collision.gameObject.tag == tags[i]) { Destroy(collision.gameObject); if (variation == 2) { triggerCounter = true; } else if (variation == 1) { reference.AddMana(Mathf.CeilToInt(reference.GetMaxMana() * 0.03f)); } numHits--; if (numHits <= 0) { enabled = false; } } } if (triggerCounter) { // Enemy...might need to change to incorporate boss or even players later allTargets = GameObject.FindGameObjectsWithTag("Enemy"); for (int i = 0; i < allTargets.Length; i++) { // Take into account stats of the CHARACTER THIS SHIELD IS ATTACHED TO if (Mathf.Pow(gameObject.transform.position.x - allTargets[i].transform.position.x, 2) + Mathf.Pow(gameObject.transform.position.y - allTargets[i].transform.position.y, 2) < 400) { DamageCalculations.ApplyCalculation(allTargets[i], gameObject, gameObject.GetComponent <CharacterStats>().GetCurrentStat(0) * 0.7f); } } } }
public override void Activate() { reference.AddMana(Mathf.CeilToInt(reference.GetMaxMana() * 0.2f)); return; }
public void ActivateSkill(GameObject activatedBlock) { // Find the clicked block and its chain number int blockIndex = blockList.IndexOf(activatedBlock.GetComponent <Block>()); int blocksRemoved = activatedBlock.GetComponent <Block>().GetChainNumber(); while ((blockIndex + 1 < blockList.Count) && (blockList[blockIndex].GetChainNumber() < blockList[blockIndex + 1].GetChainNumber())) { blockIndex++; blocksRemoved++; } // First activate the block skill and chain number if (reqBlocks <= blocksRemoved + 1) { // Remove if statement later if (blockSkills[activatedBlock.GetComponent <Block>().GetBlockType()] != null) { print(blockSkills[activatedBlock.GetComponent <Block>().GetBlockType()].SkillDescription()); blockSkills[activatedBlock.GetComponent <Block>().GetBlockType()].Activate(); } } // Assuming parent != null if (parent.GetMana() > blockSkills[activatedBlock.GetComponent <Block>().GetBlockType()].GetManaCost() * (reqBlocks - blocksRemoved - 1)) { parent.AddMana(-blockSkills[activatedBlock.GetComponent <Block>().GetBlockType()].GetManaCost() * (reqBlocks - blocksRemoved - 1)); // Shift all other blocks down by a fixed amount * chain number of clicked block for (int counter = blockIndex; counter < blockList.Count; counter++) { blockList[counter].SetDestination((blocksRemoved + 1) * totalDistance); } // Connect the blocks before and after the removed blocks if ((blockIndex - blocksRemoved > 0) && (blockIndex < blockList.Count - 1) && (!blockList[blockIndex - blocksRemoved - 1].GetCompleteChain())) { int currentBlock = blockIndex + 1; // If the block before the clicked chain is the same type as the block after the activated chain if (blockList[currentBlock].GetBlockType() == blockList[blockIndex - blocksRemoved - 1].GetBlockType()) { blockList[currentBlock].SetChainNumber(blockList[blockIndex - blocksRemoved - 1].GetChainNumber() + 1); blockList[currentBlock].SetCompleteChain(blockList[currentBlock].GetChainNumber() == 2); // If successfully connected, then redo all the connections that the block before the clicked chain had while ((currentBlock + 1 < blockList.Count) && (blockList[currentBlock].GetBlockType() == blockList[currentBlock + 1].GetBlockType()) && ((blockList[currentBlock].GetChainNumber() + 1) % 3 != blockList[currentBlock + 1].GetChainNumber())) { blockList[currentBlock + 1].SetChainNumber((blockList[currentBlock].GetChainNumber() + 1) % 3); blockList[currentBlock + 1].SetCompleteChain(blockList[currentBlock + 1].GetChainNumber() == 2); currentBlock++; } } } // Removed the clicked blocks for (int counter = blockIndex; counter > blockIndex - blocksRemoved - 1; counter--) { Destroy(blockList[counter].gameObject); blockList.Remove(blockList[counter]); } blockCount -= (blocksRemoved + 1); } return; }