コード例 #1
0
 private void SpawnReplacers(Vector2 collisionPoint)//2
 {
     for (int i = 0; i < enemyScriptable.replacedByNames.Length; i++)
     {
         if (!string.IsNullOrEmpty(enemyScriptable.replacedByNames[i]))
         {
             EnemyToReplacersDTO enemyToReplacersDTO = new EnemyToReplacersDTO
             {
                 stats = stats,
                 destroyedEnemyPosition = this.transform.position,
                 collisionPoint         = collisionPoint,
                 numberOfObject         = i
             };
             ObjectPoolList.
             instance.GetPooledObjectWithData(enemyScriptable.replacedByNames[i], gameObject.transform.position,
                                              gameObject.transform.rotation, enemyToReplacersDTO, true, false);
         }
     }
 }
コード例 #2
0
    public override void ReceiveData(BaseDTO data)
    {
        EnemyToReplacersDTO incData            = data as EnemyToReplacersDTO;
        Vector2             collisionDirection = (incData.collisionPoint - (Vector2)(incData.destroyedEnemyPosition));
        Vector2             spawnPoint;

        if (incData.numberOfObject % 2 == 0)
        {
            spawnPoint = collisionDirection.GetRotated(MainCount.instance.FloatRandom(minAngle, 180 - minAngle));
        }
        else
        {
            spawnPoint = collisionDirection.GetRotated(MainCount.instance.FloatRandom(-180 + minAngle, -minAngle));
        }
        gameObject.transform.position = new Vector2(incData.destroyedEnemyPosition.x + spawnPoint.x, incData.destroyedEnemyPosition.y + spawnPoint.y);
        Vector2 moveDirection = spawnPoint.normalized;

        EnemyBaseEngine enemyBaseEngine = gameObject.GetComponent <EnemyBaseEngine>();

        enemyBaseEngine.incomeingData.xSpeed = moveDirection.x;
        enemyBaseEngine.incomeingData.ySpeed = moveDirection.y;
        enemyBaseEngine.incomeingData.isSecondGeneratedObject = true;
        gameObject.SetActive(true);
    }