示例#1
0
    protected void SetupGeneral()
    {
        Health healthScript = GetComponent <Health> ();

        if (!healthScript)
        {
            healthScript = gameObject.AddComponent <Health> ();
        }
        healthScript.SetHealth(health);

        EnemyPath pathScript = GetComponent <EnemyPath> ();

        if (!pathScript)
        {
            pathScript = gameObject.AddComponent <EnemyPath> ();
        }
        pathScript.SetDamageOnCollision(dommageOnCollision);
        if (!path)
        {
            GameObject temp = Instantiate(pathPrefab);
            StartCoroutine(DestroyFirstWhenSecondDestroyed(temp, gameObject));
            path = temp.GetComponent <BezierCurve> ();
        }
        pathScript.SetPath(path);
        if (duration <= 0)
        {
            Debug.LogWarning("The duration given wasn't stricly positive, a default duration of 15 secondes will be given instead");
            duration = 15;
        }
        pathScript.SetDuration(duration);
        if (onHitSound)
        {
            pathScript.SetHitSound(onHitSound);
        }
        pathScript.SetLoop(loop);
        pathScript.SetHitColorTime(onHitColorTime > 0 ? onHitColorTime : 1);
    }