Ejemplo n.º 1
0
 private void SpawnResourceDrops()
 {
     for (int i = 0; i < resourceDropCount; i++)
     {
         ResourceDrop drop     = Instantiate(resourceDropPrefab, transform.position, Quaternion.identity);
         Vector2      popForce = Random.insideUnitCircle * resourceDropMaxPopForce;
         drop.GetComponent <Rigidbody2D>().AddForce(popForce, ForceMode2D.Impulse);
     }
 }
Ejemplo n.º 2
0
    private void InteractWithMine(ResourceMine mine)
    {
        HideInstructionsSprite();
        //SFX: pickaxe swing
        int amountmountOfDrop = mine.Amount;

        if (mine.BigMine)
        {
            amountmountOfDrop *= 2;
        }
        for (int i = 0; i < amountmountOfDrop; i++)
        {
            int          randomNumber    = Random.Range(-3, 4);
            Vector3      positionToSpawn = new Vector3(mine.transform.position.x + randomNumber, mine.transform.position.y + randomNumber, mine.transform.position.z);
            ResourceDrop ResourceDrop    = Instantiate(ResourceDropPrefab, positionToSpawn, Quaternion.identity).GetComponent <ResourceDrop>();

            ResourceDrop.Type = mine.Type;
            if (ResourceDrop.Type == Resource.ResourceType.Wood || ResourceDrop.Type == Resource.ResourceType.Leaf)
            {
                ResourceDrop.CanBeSetOnFire = true;
            }
            ResourceDrop.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Sprites/" + mine.Type.ToString());
            ResourceDrop.Consubamle = mine.ConsumableDrop;
            if (ResourceDrop.Consubamle)
            {
                ResourceDrop.EffectOnPlayer = mine.EffectOnPlayer;
            }
        }
        _firstInstruction  = true;
        NearbyResourceMine = null;
        if (mine.WillBeDestroyed)
        {
            Destroy(mine.gameObject);
        }
        else if (mine.WillChangeSprite)
        {
            mine.GetComponent <SpriteRenderer>().sprite = mine.SpriteToChangeTo;
            mine.CanBeCollected = false;
        }
        if (mine.Type2 != Resource.ResourceType.None)
        {
            for (int i = 0; i < amountmountOfDrop; i++)
            {
                int          randomNumber    = Random.Range(-1, 2);
                Vector3      positionToSpawn = new Vector3(mine.transform.position.x + randomNumber, mine.transform.position.y + randomNumber, mine.transform.position.z);
                ResourceDrop ResourceDrop    = Instantiate(ResourceDropPrefab, positionToSpawn, Quaternion.identity).GetComponent <ResourceDrop>();

                ResourceDrop.Type = mine.Type2;
                if (ResourceDrop.Type == Resource.ResourceType.Wood || ResourceDrop.Type == Resource.ResourceType.Leaf)
                {
                    ResourceDrop.CanBeSetOnFire = true;
                }
                ResourceDrop.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Sprites/" + mine.Type.ToString());
                ResourceDrop.Consubamle = mine.ConsumableDrop;
                if (ResourceDrop.Consubamle)
                {
                    ResourceDrop.EffectOnPlayer = mine.EffectOnPlayer;
                }
            }
            if (mine.WillBeDestroyed)
            {
                Destroy(mine.gameObject);
            }
            else if (mine.WillChangeSprite)
            {
                mine.GetComponent <SpriteRenderer>().sprite = mine.SpriteToChangeTo;
                mine.CanBeCollected = false;
            }
        }
    }