Exemple #1
0
    IEnumerator bossWake()
    {
        float      verExtent     = Camera.main.camera.orthographicSize;
        float      horExtent     = verExtent * Screen.width / Screen.height;
        BossMotion bmScript      = GetComponentInParent <BossMotion>();
        Transform  bossTransform = GetComponentInParent <Transform> ();

        CameraMove cmScript = Camera.main.camera.GetComponent <CameraMove>();

        cmScript.freeze(bossTransform.position.x);


        GameObject leftBorder = Instantiate(borderPrefab) as GameObject;

        leftBorder.transform.position = new Vector2(bossTransform.position.x - horExtent, 0.5f);

        GameObject bossMusic = Resources.Load(Globals.SEdir + "BossMusic") as GameObject;

        if (Application.loadedLevelName == "Custom_01")
        {
            bossMusic = Resources.Load(Globals.SEdir + "BossCus") as GameObject;
        }
        Instantiate(bossMusic, transform.position, Quaternion.identity);

//		GameObject rightBorder = Instantiate (borderPrefab) as GameObject;
//		rightBorder.transform.position = new Vector2(bossTransform.position.x + horExtent, 0.5f);

        yield return(new WaitForSeconds(3.0f));

        bmScript.wakeUp();
    }
    // Use this for initialization
    void Start()
    {
        image   = GetComponent <Image> ();
        healths = new Sprite[17];
        for (int i = 0; i <= 16; i++)
        {
            string assetname_prefix = "gui/enemy-health/health-";
            string number           = i.ToString("D2");
            healths[i] = Resources.Load(assetname_prefix + number, typeof(Sprite)) as Sprite;
            if (!healths[i])
            {
                Debug.LogError("RESOURCE: player health information init failed");
            }
        }

        GameObject boss = GameObject.FindGameObjectWithTag("Boss");

        if (boss)
        {
            Debug.Log("Boss found");
            bossStatus = boss.GetComponent <BossMotion>();
            if (!bossStatus)
            {
                Debug.LogError("Boss scripts not found");
            }
        }
        bossHealth   = Globals.maxBossHealth;
        image.sprite = healths [bossHealth];
    }