Пример #1
0
    public void SpawnNewMeteor(int levelIndex, GameObject prefabToSpawn, float hardnessFactor)
    {
        Vector2 randomCirclePos = Random.insideUnitCircle.normalized;
        Vector3 pos             = new Vector3(randomCirclePos.x * circleFactor, randomCirclePos.y * circleFactor, GameManager.instance.objectsDepthOffset);

        CalculateHealthSizeFactor();

        float meteorSize   = Random.Range(meteorSpawnMinSize, meteorSpawnMaxSize) * currentSpawnSizeFactor;
        float meteorHealth = GetMeteorHealthFromSize(meteorSize);

        //Debug.Log("SpawnNewMeteor | SizeFactor [" + currentSpawnSizeFactor + "] | Size [" + meteorSize + "] | Health [" + meteorHealth + "] | Hardness [" + hardnessFactor + "]");

        // Instantiate Meteor Prefab
        GameObject instantiatedMeteor = Instantiate(prefabToSpawn, pos, Quaternion.Euler(Random.Range(0f, 360f), Random.Range(0f, 360f), Random.Range(0f, 360f)));

        instantiatedMeteor.transform.SetParent(transform);
        instantiatedMeteor.transform.localScale = new Vector3(meteorSize, meteorSize, meteorSize);

        //Debug.Log("Spawning a meteor with size: " + meteorSize + " and health: " + meteorHealth);

        Meteor meteor = instantiatedMeteor.GetComponent <Meteor>();

        meteor.belongsToLevelIndex = levelIndex;
        meteor.SetRandomSpeeds();
        meteor.originalSize   = meteorSize;
        meteor.size           = meteorSize;
        meteor.healthPoints   = meteorHealth;
        meteor.willLetDebris  = LogicFunctions.RandomTrueFalse();
        meteor.hardnessFactor = hardnessFactor;

        // Add meteor to list
        meteorsList.Add(instantiatedMeteor);

        // TODO : Remove
        instantiatedMeteor.GetComponent <Meteor>().TestMeteorFunction();
    }
 public void TestGetMaxterms(int function, int variables, params int[] expected)
 {
     int[] result = LogicFunctions.GetMaxterms(function, variables).ToArray();
     Assert.AreEqual(expected, result);
 }