private GameObject FoundRodent(GameObject _TMPlastClicked) { _lastRodent = _TMPlastClicked.transform.parent.GetComponent <Rodent>(); if (_printStatements) { Debug.Log("Clicked a Rodent"); } if (_lastRodent.getTeam() == 0) { _lastRodent.imClicked(); _recruitDummy = true; } else if (_lastRodent.getTeam() == 1) { _lastRodent.imClicked(); _recruitDummy = true; } return(_lastRodent.gameObject); }
private GameObject FoundSpawnVolume(GameObject _TMPlastClicked) { _lastRodent = _TMPlastClicked.GetComponent <Rodent>(); if (_printStatements) { Debug.Log("Clicked a Rodent through spawn volume"); } if (_lastRodent.getTeam() == 0) { _lastRodent.imClicked(); _recruitDummy = true; } else if (_lastRodent.getTeam() == 1) { _lastRodent.imClicked(); _recruitDummy = true; } return(_lastRodent.gameObject); }
void OnTriggerEnter2D(Collider2D hitInfo) { // Put proper hit detection code here if (hitInfo.transform.parent) { Rodent unknownRodent = hitInfo.transform.parent.gameObject.GetComponent <Rodent>(); PlayerStats king = hitInfo.transform.parent.gameObject.GetComponent <PlayerStats>(); BuildableObject unknownBuilding = hitInfo.transform.parent.gameObject.GetComponent <BuildableObject>(); if (unknownRodent) { if (unknownRodent.getTeam() == enemyTeam) { unknownRodent.Damage(attackDamage); Destroy(gameObject); } } else if (unknownBuilding) { if (unknownBuilding.getTeam() == enemyTeam && unknownBuilding.getType() != BuildableObject.BuildingType.TownCenter && unknownBuilding.getType() != BuildableObject.BuildingType.WoodPile && unknownBuilding.getType() != BuildableObject.BuildingType.StonePile && unknownBuilding.getType() != BuildableObject.BuildingType.GarbageCan) { unknownBuilding.Damage(attackDamage); Destroy(gameObject); } } else if (king) { if (enemyTeam == 1) { king.Damage(attackDamage); Destroy(gameObject); } } } }
public void AgroRadiusTrigger(Collider2D collision) { // Add a target to the list based on collisions //Debug.Log("Collided with " + collision.gameObject.ToString()); //check that it HAS a parent if (collision.transform.parent) { Rodent unknownRodent = collision.transform.parent.gameObject.GetComponent <Rodent>(); PlayerStats king = collision.transform.parent.gameObject.GetComponent <PlayerStats>(); BuildableObject unknownBuilding = collision.transform.parent.gameObject.GetComponent <BuildableObject>(); if (unknownRodent) { // Debug.LogWarning("Found Rodent" + unknownRodent.getName() + " on team: " + unknownRodent.getTeam()); // Rodent case if (unknownRodent.getTeam() == getEnemyTeam()) { _inRange.Add(unknownRodent.gameObject); //Debug.Log("Rodent added to targets in range " + unknownRodent.getName() + unknownRodent.getTeam()); // print("called from AgroRadiusTrigger"); if (_inRange.Count == 1 && royalGuard) { print("Newest target added to queue: " + unknownRodent.gameObject); currentTarget = unknownRodent.gameObject; } } } else if (unknownBuilding) { if (unknownBuilding.getTeam() == getEnemyTeam()) { // Ensure this isn't a natural resource if (unknownBuilding.getType() != BuildableObject.BuildingType.WoodPile && unknownBuilding.getType() != BuildableObject.BuildingType.StonePile && unknownBuilding.getType() != BuildableObject.BuildingType.GarbageCan) { _inRange.Add(unknownBuilding.gameObject); if (_inRange.Count == 1 && royalGuard) { print("Newest target added to queue: " + currentTarget.ToString()); currentTarget = unknownBuilding.gameObject; } } } } // Special case: Finding King as an attack target else if (team == 2 && king) { _inRange.Add(king.gameObject); if (_inRange.Count == 1) { print("Newest target added to queue: " + king.gameObject); currentTarget = king.gameObject; //Should probably update state to stop moving, and start attacking MovingInIdle = false; } } } }
//Collect Pickups and search and attack things public void OnTriggerEnter2D(Collider2D collision) { //Debug.Log("Enter Trigger with" + collision.transform.gameObject); if (_wantToAttack && _AttackTarget != null) { if (collision.gameObject.transform.parent) { print("ATTACK$44?"); if (collision.gameObject.transform.parent.gameObject == _AttackTarget) { Attack(); } } } else if (_MoveLocation == collision.gameObject) { _horizontalMove = 0; } if (collision.transform.GetComponent <DiggableTile>()) { // Debug.Log("Collider w diggable tile"); if (!_InGround) // only keep track of top soil tiles { _CurrentSoilTile = collision.transform.GetComponent <DiggableTile>(); } } else if (collision.transform.parent) { // handle if collider is agro range or base range if (collision.transform.GetComponent <BaseHitBox>()) { //print("Collided with a base hitbox"); if (collision.transform.parent.GetComponent <BuildableObject>()) { // print("collded with a buildng hitbox"); //Add to our list of interactable things in range _InRange.Add(collision.transform.parent.gameObject); //print("Added: " + collision.transform.parent.gameObject); //Can we search it? if (collision.transform.parent.GetComponent <Searchable>()) { Searchable s = collision.transform.parent.GetComponent <Searchable>(); { s.setActive(true); // Debug.LogWarning("Players in range"); } } } else if (collision.transform.parent.GetComponent <Rodent>()) { //Add to our list of interactable things in range Rodent r = collision.transform.parent.GetComponent <Rodent>(); if (r.getTeam() == 2 && _InRange.Contains(collision.transform.parent.gameObject) == false) { _InRange.Add(collision.transform.parent.gameObject); } } } } ///Old Game Jam code, could be reused for pickups else if (collision.transform.GetComponent <CoinResource>()) { // if (collision.transform.GetComponent<CoinResource>().isActive()) { ResourceManagerScript.Instance.incrementResource(ResourceManagerScript.ResourceType.Trash, 1); Destroy(collision.gameObject); } } }