Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");
        rb     = GetComponent <Rigidbody2D>();
        bc     = GetComponent <BoxCollider2D>();

        knife              = new BasicKnife("Advanced Dagger", 100, .6f, "dagger 2");
        inHands            = knife;
        weaponSlot         = transform.GetChild(0).gameObject;
        weaponSlotLocation = weaponSlot.transform.localPosition;
        weaponSlot.GetComponent <SpriteRenderer>().sprite            = inHands.icon;
        weaponSlot.GetComponent <SpriteRenderer> ().sortingLayerName = "Weapons";
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        float randomRange = Random.Range(0.0f, 1.0f);

        //constructor for new items (nameOf, damage, attackSpeed, spriteName)
        basicPistol    = new BasicPistol();
        basicKnife     = new BasicKnife();
        advancedKnife  = new BasicKnife("Advanced Dagger", 100, .6f, "dagger 2");
        shitAxe        = new BasicKnife("Shitty Axe", 35, .3f, "ShitAxe");
        advancedPistol = new BasicPistol("Advanced Pistol", 200, .1f, 1000f, 20, "gun 2");
        pickupAudio    = Resources.Load <AudioClip>("Audio/Basic Reload");

        if (spawnKnife && spawnGun)
        {
            if (randomRange < 0.5f)
            {
                spawnedWeapon = basicPistol;
            }
            else if (randomRange >= .5f)
            {
                spawnedWeapon = advancedKnife;
            }
            //this will rotate guns appropriately every time
            if (spawnedWeapon.type == 1)
            {
                gameObject.transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, -90);
            }
        }
        else if (spawnKnife)
        {
            spawnedWeapon = advancedKnife;
        }
        else if (spawnGun)
        {
            spawnedWeapon = advancedPistol;
        }
        else
        {
            if (randomRange < 0.25f)
            {
                spawnedWeapon = basicPistol;
            }
            else if (randomRange >= 0.25f && randomRange < .5f)
            {
                spawnedWeapon = advancedKnife;
            }
            else if (randomRange >= 0.5f && randomRange < .75f)
            {
                spawnedWeapon = advancedPistol;
            }
            else if (randomRange >= .75f && randomRange < 1f)
            {
                spawnedWeapon = basicKnife;
            }
            //this will rotate guns appropriately every time
        }
        // flip sprite if gun because of the way they are
        if (spawnedWeapon.type == 1)
        {
            gameObject.transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, -90);
        }
        //this will ensure the sprite is changed every time
        gameObject.GetComponent <SpriteRenderer>().sprite           = spawnedWeapon.icon;
        gameObject.GetComponent <SpriteRenderer>().sortingLayerName = "Weapons";
    }