Esempio n. 1
0
    void Start()
    {
        animator       = GetComponent <Animator>         ();
        whipAttManager = GetComponent <WhipAttackManager>();
        collManager    = GetComponent <CollisionManager> ();
        hurtManager    = GetComponent <HurtManager>      ();

        collManager.ExitGround += handleOnExitGround;
        Flip();
    }
    // Use this for initialization
    void Start()
    {
        // init input manager
        initInputEventHandler();
        animator         = GetComponent <Animator> ();
        whipAttManager   = GetComponent <WhipAttackManager> ();
        stairManager     = GetComponent <StairManager> ();
        collManager      = GetComponent <CollisionManager> ();
        subWeaponManager = GetComponent <SubWeaponManager> ();
        hurtManager      = GetComponent <HurtManager> ();

        collManager.ExitGround += handleOnExitGround;
        Flip();          // since the raw sprite face left
    }
Esempio n. 3
0
    IEnumerator revealItemAndDestroy()
    {
        hitted = true;
        GameObject deathEffect = Resources.Load("Prefab/death") as GameObject;

        Instantiate(deathEffect, collider2D.bounds.center, Quaternion.identity);

        randItems = Resources.LoadAll <GameObject>("Prefab/RandItem");
        GameObject hitSE = Resources.Load(Globals.SEdir + "hitSE") as GameObject;

        Instantiate(hitSE, transform.position, Quaternion.identity);

        GameObject pObj = GameObject.FindGameObjectWithTag(Globals.playerTag);

        if (pObj)
        {
            StatusManager smScript =
                pObj.GetComponent <StatusManager> ();
            if (smScript)
            {
                smScript.score += 100;
            }
        }



        if (!fixedItem)
        {
            int randId = Random.Range(0, randItems.Length);
            itemPrefab = randItems[randId];
            if (itemPrefab.name == "WhipUp")
            {
                WhipAttackManager wamScript =
                    GameObject.FindGameObjectWithTag(Globals.playerTag).GetComponent <WhipAttackManager>();

                if (wamScript.whipLevel == 3)
                {
                    itemPrefab = randItems[1];
                }
            }
        }

        Instantiate(itemPrefab, transform.position, Quaternion.identity);
        Destroy(this.gameObject);
        yield return(null);
    }
    void itemPickedUp(GameObject plObj)
    {
        smScript   = plObj.GetComponent <StatusManager> ();
        attManager = plObj.GetComponent <WhipAttackManager> ();
        wepManager = plObj.GetComponent <SubWeaponManager> ();

        switch (itemName)
        {
        case Globals.ItemName.Money_S:
        case Globals.ItemName.Money_M:
        case Globals.ItemName.Money_L:
            GameObject moneySE = Resources.Load(Globals.SEdir + "moneySE") as GameObject;
            Instantiate(moneySE, transform.position, Quaternion.identity);
            break;

        case Globals.ItemName.SmallHeart:
        case Globals.ItemName.LargeHeart:
            GameObject heartSE = Resources.Load(Globals.SEdir + "heartSE") as GameObject;
            Instantiate(heartSE, transform.position, Quaternion.identity);
            break;

        case Globals.ItemName.WhipUp:

        case Globals.ItemName.Dagger:

        case Globals.ItemName.Axe:

        case Globals.ItemName.HolyWater:

        case Globals.ItemName.StopWatch:
            GameObject upgradeSE = Resources.Load(Globals.SEdir + "upgradeSE") as GameObject;
            Instantiate(upgradeSE, transform.position, Quaternion.identity);
            break;


        case Globals.ItemName.Rosary:
            GameObject rosarySE = Resources.Load(Globals.SEdir + "rosarySE") as GameObject;
            Instantiate(rosarySE, transform.position, Quaternion.identity);
            break;

        case Globals.ItemName.BossHeart:

            GameObject deathSE = Resources.Load(Globals.SEdir + "WinMusic") as GameObject;
            Instantiate(deathSE, transform.position, Quaternion.identity);

            break;

        default:
            GameObject defaultSE = Resources.Load(Globals.SEdir + "heartSE") as GameObject;
            Instantiate(defaultSE, transform.position, Quaternion.identity);
            break;
        }

        switch (itemName)
        {
        case Globals.ItemName.Money_S:
            smScript.score += 100;
            Debug.Log("fetched small money");
            break;

        case Globals.ItemName.Money_M:
            smScript.score += 400;
            Debug.Log("fetched medium money");
            break;

        case Globals.ItemName.Money_L:
            smScript.score += 700;
            Debug.Log("fetched large money");
            break;

        case Globals.ItemName.SmallHeart:
            smScript.heartNum += 1;
            Debug.Log("fetched heart");
            break;

        case Globals.ItemName.LargeHeart:
            smScript.heartNum += 5;
            Debug.Log("fetched heart");
            break;

        case Globals.ItemName.WhipUp:
            if (attManager.whipLevel < 3)
            {
                attManager.UpgradWhip();
            }
            Debug.Log("fetched Morning Star, whip powered up");
            break;

        case Globals.ItemName.Rosary:

            Debug.Log("fetched Rosery, clear stage");


            GameObject[] allEnemy = GameObject.FindGameObjectsWithTag(Globals.EnemyTag);
            foreach (GameObject enemy in allEnemy)
            {
                OnWhipEvent whipScript = enemy.GetComponent <OnWhipEvent>();

                if (whipScript != null)
                {
                    whipScript.onWhipEnter();
                }
            }
            break;

        case Globals.ItemName.Dagger:
            wepManager.weaponPickedUp(Globals.SubWeapon.Dagger);
            break;

        case Globals.ItemName.Axe:
            wepManager.weaponPickedUp(Globals.SubWeapon.Axe);
            break;

        case Globals.ItemName.HolyWater:
            wepManager.weaponPickedUp(Globals.SubWeapon.HolyWater);
            break;

        case Globals.ItemName.StopWatch:
            wepManager.weaponPickedUp(Globals.SubWeapon.StopWatch);
            break;

        case Globals.ItemName.BossHeart:
            getBossHeart();
            break;

        case Globals.ItemName.ChickenLeg:
            smScript.playerHealth += 6;
            Mathf.Clamp(smScript.playerHealth, 0, Globals.maxBossHealth);
            break;

        default:
            break;
        }

        Debug.Log("Player picked Up");
        if (audio)
        {
            audio.Play();
        }
        Destroy(this.gameObject);
    }
Esempio n. 5
0
    void itemPickedUp(GameObject plObj)
    {
        smScript   = plObj.GetComponent <StatusManager> ();
        attManager = plObj.GetComponent <WhipAttackManager> ();

        switch (itemName)
        {
        case Globals.ItemName.Money_S:
        case Globals.ItemName.Money_M:
        case Globals.ItemName.Money_L:
            GameObject moneySE = Resources.Load(Globals.SEdir + "moneySE") as GameObject;
            Instantiate(moneySE, transform.position, Quaternion.identity);
            break;

        case Globals.ItemName.SmallHeart:
        case Globals.ItemName.LargeHeart:
            GameObject heartSE = Resources.Load(Globals.SEdir + "heartSE") as GameObject;
            Instantiate(heartSE, transform.position, Quaternion.identity);
            break;

        case Globals.ItemName.WhipUp:
        default:
            GameObject defaultSE = Resources.Load(Globals.SEdir + "heartSE") as GameObject;
            Instantiate(defaultSE, transform.position, Quaternion.identity);
            break;
        }

        switch (itemName)
        {
        case Globals.ItemName.Money_S:
            smScript.score += 100;
            break;

        case Globals.ItemName.Money_M:
            smScript.score += 400;
            break;

        case Globals.ItemName.Money_L:
            smScript.score += 700;
            break;

        case Globals.ItemName.SmallHeart:
            smScript.heart += 1;
            break;

        case Globals.ItemName.LargeHeart:
            smScript.heart += 5;
            break;

        case Globals.ItemName.ChickenLeg:
            smScript.playerHealth += 6;
            Mathf.Clamp(smScript.playerHealth, 0, Globals.maxBossHealth);
            break;

        default:
            break;
        }

        if (GetComponent <AudioSource>())
        {
            GetComponent <AudioSource>().Play();
        }
        Destroy(this.gameObject);
    }