コード例 #1
0
    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;
            }
        }
    }
コード例 #2
0
ファイル: HumanCell.cs プロジェクト: Lywiin/SeriousGameOUCRU
    public static Organism InstantiateHumanCell(Vector2 spawnPosition)
    {
        HumanCell humanCellToSpawn = HumanCellPool.Instance.Get();

        humanCellToSpawn.ResetOrganismAtPosition(spawnPosition);
        humanCellToSpawn.OnObjectToSpawn();

        return(humanCellToSpawn);
    }
コード例 #3
0
    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);
        }
    }
コード例 #4
0
    /***** POOL FUNCTIONS *****/

    public virtual void OnObjectToSpawn()
    {
        detectionColl.radius = attackRadius;

        canAttack    = false;
        attackTarget = null;

        targetLastPosition = Vector2.zero;

        // Cannot attack at spawn
        StartCoroutine(AttackRecall());
    }
コード例 #5
0
 public void ResetTarget()
 {
     if (attackTarget)
     {
         attackTarget.targetedBy = null;
         attackTarget.GetComponent <OrganismMovement>().SetCanMove(true);
         attackTarget = null;
         if (orgMovement)
         {
             orgMovement.SetTarget(null);
         }
     }
 }
コード例 #6
0
    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());
            }
        }
    }
コード例 #7
0
 private void SpawnTutorialHumanCell(Vector2 spawnPos)
 {
     humanCell = HumanCell.InstantiateHumanCell(spawnPos);
     humanCell.GetComponent <OrganismDuplication>().enabled = false;
 }