Exemplo n.º 1
0
        public Entity(IClanInfo myClan, SpawnStats stats, IVisionSense visionSense)
        {
            ClanInfo   = myClan;
            Id         = stats.Id;
            Health     = stats.Health;
            _maxHealth = Health;
            Damage     = stats.Damage;
            Defence    = stats.Defence;

            _visionSense = visionSense;
        }
Exemplo n.º 2
0
 public Soldier(IClanInfo myClan, SpawnStats stats, IVisionSense visionSense) : base(myClan, stats, visionSense)
 {
     _willingnessToAttactk = _rnd.Next(Behaviour.SOLDIER_MINIMAL_WILLIGNESS_TO_ATTACK, 100);
 }
Exemplo n.º 3
0
 public Outpost(IClanInfo myClan, SpawnStats stats, IVisionSense visionSense, int spawnTreshold) : base(myClan, stats, visionSense, spawnTreshold)
 {
     // Empty
 }
Exemplo n.º 4
0
 public Headquarter(IClanInfo myClan, SpawnStats stats, IVisionSense visionSense, int spawnTreshold) : base(myClan, stats, visionSense)
 {
     _spawnTreshold = spawnTreshold;
     InitializePossibleSpawns();
 }
Exemplo n.º 5
0
 public Builder(IClanInfo myClan, SpawnStats stats, IVisionSense visionSense) : base(myClan, stats, visionSense)
 {
     // Empty
 }
Exemplo n.º 6
0
    void TryToSpawnEnemy(SpawnStats data)
    {
        if (data.DifficultyLevelToSpawn > GameManager.Difficulty)
        {
            Debug.Log("TryToSpawnEnemy - " + data.Type.ToString() + " cannot spawn this round, difficulty is too low: " + data.DifficultyLevelToSpawn.ToString() + " > " + GameManager.Difficulty.ToString());
            return;
        }

        var levelsAboveBaseDifficulty = (GameManager.Difficulty - data.DifficultyLevelToSpawn) + ActorStats.MapRotationCount;

        var extraSpawnChance = data.SpawnIncreasePerDifficultyLevel * levelsAboveBaseDifficulty;
        var extraSpawnTries  = Mathf.Floor(data.TimesToTrySpawnIncreasePerDifficultyLevel * levelsAboveBaseDifficulty);

        if (ActorStats.MapRotationCount > 1)
        {
            extraSpawnChance *= 2;
        }

        var spawnChance     = data.BaseSpawnChance + extraSpawnChance;
        var timesToTrySpawn = (data.BaseTimesToTryAndSpawn + extraSpawnTries);

        if (data.Type == EnemyType.Sweeper)
        {
            timesToTrySpawn += GameManager.InfectedCellsCount / 3;
        }

        if (data.Type == EnemyType.Neutral)
        {
            spawnChance /= ActorStats.MapRotationCount;
        }

        Debug.Log("TryToSpawnEnemy - " + data.Type.ToString() + " spawn chance: " + spawnChance.ToString() + "%, times to try: " + timesToTrySpawn.ToString());

        var autoSpawn = data.SpawnAtLeastOnce;

        for (var i = 0; i < timesToTrySpawn; i++)
        {
            var spawnChanceRandom = Random.Range(0.0f, 100.0f);

            if (spawnChanceRandom >= spawnChance && !autoSpawn)
            {
                Debug.Log("TryToSpawnEnemy - " + data.Type.ToString() + " try " + i.ToString() + " failed. Got: " + spawnChanceRandom.ToString() + " but chance was " + spawnChance.ToString());
                continue;
            }

            autoSpawn = false;


            Debug.Log("TryToSpawnEnemy - " + data.Type.ToString() + " try " + i.ToString() + " succeeded!");

            var tempEnemy = (GameObject)Instantiate(data.Prefab, _spawnerRef.GetSpawnPoint(), new Quaternion());

            var tempStats = tempEnemy.GetComponent <ActorStats>();
            if (tempStats)
            {
                DataController dataController = DataController.GetInstance();
                if (dataController)
                {
                    dataController.initActorFromType(tempStats, data.Type);
                }
                tempStats.SetupDifficulty(GameManager.Difficulty * ActorStats.MapRotationCount, DifficultyMod * ActorStats.MapRotationCount);
            }

            _currentEnemies.Add(tempEnemy);

            if (data.OnlySpawnOnce)
            {
                Debug.Log("TryToSpawnEnemy - " + data.Type.ToString() + " not spawning any more of these.");
                break;
            }
        }
    }