示例#1
0
    void checkCollision(Entity e, DifficultyControllerComponent difficulty)
    {
        CollisionScript collision = e.gameObject.gameObject.GetComponent <CollisionScript>();
        Queue <string>  queue     = collision.queue;

        if (queue.Count == 0)
        {
            return;
        }

        HealthComponent health = e.health;
        int             damage = getDamageDone(collision.queue, health.health);

        if (!e.hasPlayer)
        {
            damage = damage * (difficulty.dmgBoostPercent + 100) / 100;
        }
        if (damage > 0)
        {
            e.AddDamage(damage);
        }
        else
        {
            //throw new Exception("Sth is f****d up, and is unnecessary calculating damage");
        }
    }
示例#2
0
    public void Execute()
    {
        DifficultyControllerComponent difficulty = _difficulty.GetSingleEntity().difficultyController;

        foreach (Entity e in _group.GetEntities())
        {
            checkCollision(e, difficulty);
        }
    }
示例#3
0
    public void Execute()
    {
        DifficultyControllerComponent difficulty = _difficulty.GetSingleEntity().difficultyController;
        Camera  camera         = _camera.GetSingleEntity().camera.camera;
        Vector3 cameraPosition = camera.transform.position;

        foreach (Entity e in _group.GetEntities())
        {
            spawnIfCan(e, cameraPosition, difficulty);
        }
    }
示例#4
0
    void checkCollision(Entity e, DifficultyControllerComponent difficulty)
    {
        CollisionScript collision = e.gameObject.gameObject.GetComponent<CollisionScript>();
        int damageTaken = collision.DamageTaken;
        if (damageTaken == 0) {
            return;
        }

        e.AddDamage(damageTaken);
        collision.DamageTaken = 0;
    }
示例#5
0
    void spawnIfCan(Entity e, Vector3 cameraPosition, DifficultyControllerComponent difficulty)
    {
        EnemySpawnerComponent enemySpawner = e.enemySpawner;
        XmlNode node = enemySpawner.node;

        if (enemySpawner.used && node != null)
        {
            enemySpawner.node = enemySpawner.node.NextSibling;
            node = enemySpawner.node;
        }
        if (node != null)
        {
            enemySpawner.used = false;
            XmlAttributeCollection attributes = node.Attributes;
            float spawnBarrier = (float)Convert.ToDouble(attributes[0].Value);
            if (spawnBarrier < cameraPosition.y)
            {
                XmlNode innerNode = node.FirstChild;
                while (innerNode != null)
                {
                    int     enemyCount = Convert.ToInt16(innerNode.Attributes[0].Value);
                    Vector2 position   = new Vector2((float)Convert.ToDouble(innerNode.Attributes[1].Value),
                                                     (float)Convert.ToDouble(innerNode.Attributes[2].Value));
                    Vector2 velocity = new Vector2((float)Convert.ToDouble(innerNode.Attributes[3].Value),
                                                   (float)Convert.ToDouble(innerNode.Attributes[4].Value));
                    int type   = Convert.ToInt16(innerNode.Attributes[5].Value);
                    int health = Convert.ToInt16(innerNode.Attributes[6].Value) * (difficulty.hpBoostPercent + 100) / 100;
                    while (enemyCount != 0)
                    {
                        _factory.createEnemyByType(type, position, velocity, health, difficulty.missileSpeedBoostPercent);
                        enemyCount--;
                    }
                    innerNode = innerNode.NextSibling;
                }

                enemySpawner.used = true;
            }
        }
        else
        {
            // all enemies spawned
        }
    }
示例#6
0
    void checkCollision(Entity e, DifficultyControllerComponent difficulty)
    {
        CollisionScript collision = e.gameObject.gameObject.GetComponent<CollisionScript>();
        Queue<string> queue = collision.queue;
        if (queue.Count == 0) {
            return;
        }

        HealthComponent health = e.health;
        int damage = getDamageDone(collision.queue, health.health);
        if (!e.hasPlayer) {
            damage = damage * (difficulty.dmgBoostPercent + 100) / 100;
        }
        if (damage > 0) {
            e.AddDamage(damage);
        }
        else {
            //throw new Exception("Sth is f****d up, and is unnecessary calculating damage");
        }
    }
示例#7
0
    void update(Group group, Entity entity, int index, IComponent previousComponent, IComponent nextComponent)
    {
        SettingsModelComponent        settings   = (SettingsModelComponent)nextComponent;
        DifficultyControllerComponent difficulty = _group.GetSingleEntity().difficultyController;

        if (settings.difficulty == difficulty.difficultyType)
        {
            return;
        }

        foreach (Entity e in _models.GetEntities())
        {
            DifficultyModelComponent model = e.difficultyModel;
            if (settings.difficulty == model.type)
            {
                difficulty.dmgBoostPercent          = model.dmgBoostPercent;
                difficulty.hpBoostPercent           = model.hpBoostPercent;
                difficulty.missileSpeedBoostPercent = model.missileSpeedBoostPercent;
            }
        }
    }
示例#8
0
    void spawnIfCan(Entity e, Vector3 cameraPosition, DifficultyControllerComponent difficulty)
    {
        EnemySpawnerComponent enemySpawner = e.enemySpawner;
        XmlNode node = enemySpawner.node;

        if (enemySpawner.used && node != null) {
            enemySpawner.node = enemySpawner.node.NextSibling;
            node = enemySpawner.node;
        }
        if (node != null) {
            enemySpawner.used = false;
            XmlAttributeCollection attributes = node.Attributes;
            float spawnBarrier = (float)Convert.ToDouble(attributes[0].Value);
            if (spawnBarrier < cameraPosition.y) {
                XmlNode innerNode = node.FirstChild;
                while(innerNode != null) {
                    int enemyCount = Convert.ToInt16(innerNode.Attributes[0].Value);
                    Vector2 position = new Vector2((float)Convert.ToDouble(innerNode.Attributes[1].Value),
                                                   (float)Convert.ToDouble(innerNode.Attributes[2].Value));
                    Vector2 velocity = new Vector2((float)Convert.ToDouble(innerNode.Attributes[3].Value),
                                                   (float)Convert.ToDouble(innerNode.Attributes[4].Value));
                    int type = Convert.ToInt16(innerNode.Attributes[5].Value);
                    int health = Convert.ToInt16(innerNode.Attributes[6].Value) * (difficulty.hpBoostPercent + 100) / 100;
                    while (enemyCount != 0) {
                        _factory.createEnemyByType(type, position, velocity, health, difficulty.missileSpeedBoostPercent);
                        enemyCount--;
                    }
                    innerNode = innerNode.NextSibling;
                }

                enemySpawner.used = true;
            }
        }
        else {
            // all enemies spawned
        }
    }
示例#9
0
 DifficultyControllerComponent getDifficultyController()
 {
     if (difficultyController == null)
     {
         difficultyController = difficulty.GetSingleEntity().difficultyController;
         enemyCreator.SetController(difficultyController);
         weaponProvider.SetController(difficultyController);
     }
     return difficultyController;
 }
示例#10
0
 public void SetController(DifficultyControllerComponent difficultyController)
 {
     this.difficultyController = difficultyController;
 }