コード例 #1
0
    /*!
     * Event handler for when arrow hits an object with a collider
     * @param col is the other object
     */
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Enemy")
        {
            enemy = col.gameObject.GetComponent <MobHealth> ();

            switch (arrowDmgType)
            {
            case arrowDmgTypes.basic:
                enemy.DoDamage(player.arrowDmg);
                break;

            case arrowDmgTypes.fire:
                enemy.StartBurn(player.arrowDmg / 2f, player.burnAmount);
                break;

            case arrowDmgTypes.ice:
                enemy.ApplyFreeze(player.arrowDmg, player.freezeTime);
                break;

            case arrowDmgTypes.slow:
                enemy.ApplySlow(player.arrowDmg, player.slowMult);
                break;
            }

            DestroySelf();
        }
        else if (col.gameObject.tag == "World")
        {
            DestroySelf();
        }
    }
コード例 #2
0
 private void Start()
 {
     player             = GameObject.FindGameObjectWithTag("Player");
     gameManager        = FindObjectOfType <GameManager>();
     mobHealth          = GetComponent <MobHealth>();
     baseFireRate      *= PlayerPrefs.GetFloat("difficulty");
     fireRate           = baseFireRate;
     healthBar          = GameObject.FindGameObjectWithTag("HealthBar");
     healthBarTransform = healthBar.GetComponent <RectTransform>();
     canFire            = true;
     canBurst           = true;
 }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (active && Time.time > nextSpawn)
        {
            nextSpawn = Time.time + spawnRate;

            if (currentMobs < maxMobs)
            {
                currentMobs++;
                MobHealth mh = (MobHealth)Instantiate(mob, transform.position, Quaternion.identity);
                mh.SetSpawner(gameObject.GetComponent <SpawnerController>());
            }
        }
    }
コード例 #4
0
 private void Start()
 {
     mobHealth = GetComponent <MobHealth>();
     StartCoroutine(Extinguish());
 }
コード例 #5
0
 //frames
 private void Awake()
 {
     myAnimator    = GetComponent <Animator>();
     myRigidbody2D = GetComponent <Rigidbody2D>();
     healthScript  = GetComponent <MobHealth>();
 }