private void OnTriggerStay2D(Collider2D c) { if (canAttack && !attackTarget) { attackTarget = c.GetComponentInParent <HumanCell>(); // if target is a human cell and not already targeted if (attackTarget && !attackTarget.targetedBy) { attackTarget.targetedBy = this; if (!instantKill) { attackTarget.GetComponent <OrganismMovement>().SetCanMove(false); } // Set new attackTarget to move towards it if (orgMovement) { orgMovement.SetTarget(attackTarget); } } else { attackTarget = null; } } }
public static Organism InstantiateHumanCell(Vector2 spawnPosition) { HumanCell humanCellToSpawn = HumanCellPool.Instance.Get(); humanCellToSpawn.ResetOrganismAtPosition(spawnPosition); humanCellToSpawn.OnObjectToSpawn(); return(humanCellToSpawn); }
private void SpawnHumanCell() { // Spawn some bacteria cells for (int i = 0; i < humanCellCount; i++) { // Get a valid position by using object size as parameter Vector2 validPos = GetAValidPos(humanCellSize); HumanCell.InstantiateHumanCell(validPos); } }
/***** POOL FUNCTIONS *****/ public virtual void OnObjectToSpawn() { detectionColl.radius = attackRadius; canAttack = false; attackTarget = null; targetLastPosition = Vector2.zero; // Cannot attack at spawn StartCoroutine(AttackRecall()); }
public void ResetTarget() { if (attackTarget) { attackTarget.targetedBy = null; attackTarget.GetComponent <OrganismMovement>().SetCanMove(true); attackTarget = null; if (orgMovement) { orgMovement.SetTarget(null); } } }
private void InstantAttack(HumanCell target) { if (target) { target.DamageOrganism(target.GetHealth()); if (target == attackTarget) { // Reset target attackTarget = null; if (orgMovement) { orgMovement.SetTarget(null); } // Start recall to prevent chain attack StartCoroutine(AttackRecall()); } } }
private void SpawnTutorialHumanCell(Vector2 spawnPos) { humanCell = HumanCell.InstantiateHumanCell(spawnPos); humanCell.GetComponent <OrganismDuplication>().enabled = false; }