1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public enum LootType { SC = 0, HC = 1, Energy = 2, Level = 3 }
- public class LootScript : Clickable
- {
- public LootType Type;
- public int Value;
- public Sprite[] Sprites;
- // Use this for initialization
- void Start()
- {
- GetComponent<SpriteRenderer>().sprite = Sprites[(int)Type];
- Vector2 dir = new Vector2(-Random.Range(0.1f, 0.9f),
- Random.Range(0.1f, 0.9f)).normalized;
- float power = Random.Range(100, 200);
- GetComponent<Rigidbody2D>().AddForce(dir * power);
- Invoke("Collect", 6);
- }
- // Update is called once per frame
- void Update()
- {
- }
- public override void DoSomething()
- {
- base.DoSomething();
- Collect();
- }
- public void Collect()
- {
- switch (Type)
- {
- case LootType.SC:
- GameManager.Instance.AddSoftCurrency(Value);
- break;
- case LootType.HC:
- GameManager.Instance.AddHardCurrency(Value);
- break;
- case LootType.Energy:
- GameManager.Instance.IncrementMotivation(Value,false);
- break;
- case LootType.Level:
- GameManager.Instance.IncrementExperience(Value);
- break;
- default:
- break;
- }
- Destroy(gameObject);
- }
- }
|