Esempio n. 1
0
    void OnTriggerStay2D(Collider2D coll)
    {
        attacker attacker = coll.gameObject.GetComponent <attacker>();

        if (attacker)
        {
            animator.SetTrigger("underAttackTrigger");
        }
    }
Esempio n. 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        attacker enemy = collision.GetComponent <attacker>();

        if (enemy != null)
        {
            collision.GetComponent <health>()._decrease_health(damage);
            Destroy(this.gameObject);
        }
    }
Esempio n. 3
0
    bool isTimeToSpawn(GameObject attacker)
    {
        attacker myAttacker = attacker.GetComponent <attacker>();
        // float spawnDelay = myAttacker.seenEverySeconds;
        //float spawnPerSec = 1 / spawnDelay;

        float spawnTreshhold = 1 / myAttacker.seenEverySeconds * Time.deltaTime / 5;

        return(Random.value < spawnTreshhold);
    }
Esempio n. 4
0
    public GameObject copyAttacker(GameObject original)
    {
        GameObject clone        = (GameObject)Instantiate(Resources.Load("attacker"));
        attacker   cloneAttr    = clone.GetComponent <attacker> ();
        attacker   originalAttr = original.GetComponent <attacker> ();

        copyGenericAttr(original, clone);
        cloneAttr.range = originalAttr.range;
        return(clone);
    }
Esempio n. 5
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        attacker attacker = collider.gameObject.GetComponent <attacker> ();
        Health   health   = collider.gameObject.GetComponent <Health> ();

        if (attacker && health)
        {
            health.DealDamage(damage);
            Destroy(gameObject);
        }
    }
Esempio n. 6
0
    bool isTimeToSpawn(GameObject attackerGameObject)
    {
        attacker attack          = attackerGameObject.GetComponent <attacker> ();
        float    meanSpawnDelay  = attack.seenEverySeconds;
        float    spawnsPerSecond = 1 / meanSpawnDelay;

        if (Time.deltaTime > meanSpawnDelay)
        {
            Debug.LogWarning("Spawnrate capped by frame rate");
        }

        float threashold = spawnsPerSecond * Time.deltaTime / 5;

        return(Random.value < threashold);
    }
Esempio n. 7
0
    IEnumerator Start()
    {
        lower_value  = Options._higher(lower_value);
        higher_value = Options._higher(higher_value);
        while (spawn)
        {
            float random_value = Random.Range(lower_value, higher_value);
            yield return(new WaitForSeconds(random_value));

            int      random_enemy  = Random.Range(0, enemies.Length);
            attacker lane_attacker = (attacker)Instantiate(enemies[random_enemy], transform.position, transform.rotation);
            lane_attacker.transform.parent = transform;
            if (!time_for_main && Time.timeSinceLevelLoad > 120)
            {
                attacker _lane_attacker = (attacker)Instantiate(Resources.Load <attacker>("Prefabs/Ghost"),
                                                                transform.position, transform.rotation);
                _lane_attacker.transform.parent = transform;
                time_for_main = true;
            }
        }
    }
Esempio n. 8
0
 public Form1()
 {
     InitializeComponent();
     this.textBox1.KeyPress     += onTextChanged;
     this.textBox2.KeyPress     += onTextChanged;
     this.textBox3.KeyPress     += onTextChanged;
     this.textBox4.KeyPress     += onTextChanged;
     this.textBox5.KeyPress     += onTextChanged;
     this.textBox6.KeyPress     += onTextChanged;
     this.textBox7.KeyPress     += onTextChanged;
     this.textBox8.KeyPress     += onTextChanged;
     this.textBox9.KeyPress     += onTextChanged;
     this.textBox10.KeyPress    += onTextChanged;
     this.textBox11.KeyPress    += onTextChanged;
     this.textBox12.KeyPress    += onTextChanged;
     this.textBox13.KeyPress    += onTextChanged;
     this.textBox14.KeyPress    += onTextChanged;
     this.textBox15.KeyPress    += onTextChanged;
     this.textBox16.KeyPress    += onTextChanged;
     this.textBox17.KeyPress    += onTextChanged;
     this.textBox18.KeyPress    += onTextChanged;
     this.textBox19.KeyPress    += onTextChanged;
     this.textBox20.KeyPress    += onTextChanged;
     this.textBox21.KeyPress    += onTextChanged;
     this.textBox22.KeyPress    += onTextChanged;
     this.textBox23.KeyPress    += onTextChanged;
     this.textBox24.KeyPress    += onTextChanged;
     this.textBox1.TextChanged  += fieldTextChanged;
     this.textBox2.TextChanged  += fieldTextChanged;
     this.textBox3.TextChanged  += fieldTextChanged;
     this.textBox4.TextChanged  += fieldTextChanged;
     this.textBox5.TextChanged  += fieldTextChanged;
     this.textBox6.TextChanged  += fieldTextChanged;
     this.textBox7.TextChanged  += fieldTextChanged;
     this.textBox8.TextChanged  += fieldTextChanged;
     this.textBox9.TextChanged  += fieldTextChanged;
     this.textBox10.TextChanged += fieldTextChanged;
     this.textBox11.TextChanged += fieldTextChanged;
     this.textBox12.TextChanged += fieldTextChanged;
     this.textBox13.TextChanged += fieldTextChanged;
     this.textBox14.TextChanged += fieldTextChanged;
     this.textBox15.TextChanged += fieldTextChanged;
     this.textBox16.TextChanged += fieldTextChanged;
     this.textBox17.TextChanged += fieldTextChanged;
     this.textBox18.TextChanged += fieldTextChanged;
     this.textBox19.TextChanged += fieldTextChanged;
     this.textBox20.TextChanged += fieldTextChanged;
     this.textBox21.TextChanged += fieldTextChanged;
     this.textBox22.TextChanged += fieldTextChanged;
     this.textBox23.TextChanged += fieldTextChanged;
     this.textBox24.TextChanged += fieldTextChanged;
     attackerInfo = new attacker();
     attackerInfo.attack_modifier  = 1;
     attackerInfo.defence_modifier = 1;
     attackerInfo.life_modifier    = 1;
     attackerInfo.troops           = new Int64[12];
     defenderInfo = new defender();
     defenderInfo.attack_modifier  = 1;
     defenderInfo.defence_modifier = 1;
     defenderInfo.life_modifier    = 1;
     defenderInfo.troops           = new Int64[12];
     result = new battleResult();
     result.attackerTroops = new Int64[12];
     result.defenderTroops = new Int64[12];
     result.result         = 0;
     result.fortification  = new Int64[5];
 }
Esempio n. 9
0
 // Use this for initialization
 void Start()
 {
     animator = GetComponent <Animator> ();
     att      = GetComponent <attacker> ();
 }