void OnDragStart()
{
// Change cloned drag object sprite to spell target indicator
targetIndicator = UICamera.currentTouch.dragged.GetComponent<UISprite>();
targetIndicator.spriteName = "PitsOfDefence";
targetIndicator.width = 300;
targetIndicator.height = 300;
// Slow Time When Object Draging
Time.timeScale = 0.25f;
}
void OnDragEnd()
{
// Problem One : I need to disable dragging during the cooldown. but how? I tryed to disable BoxCollider, UIDragDropItem not working.
// gameObject.GetComponentInParent<BoxCollider>().enabled = false;
// gameObject.GetComponentInParent<UIDragDropItem>().enabled = false;
// Instantiating Spell Prefab to scene
Instantiate
(spellPrefab, Camera
.main.ScreenToWorldPoint(new Vector3
(Input
.mousePosition.x, Input
.mousePosition.y, 8
.5f
)), Quaternion
.identity);
// Normalize Time
Time.timeScale = 1f;
// Start Cooldown Indicator
cooldownSprite.fillAmount = 1; // Fill Cooldown
progressPerSecond = ((100f / (PitsofDefenceSpell.DamageDuration + 1f)) / 1000f);
InvokeRepeating("ShowCoolDown", 0, 0.1f); // ( *********** Problem Two : Its not working when fire InvokeRepeating. what is wrong? ************* )
}
void ShowCoolDown()
{
if (cooldownSprite.fillAmount <= 0)
{
CancelInvoke();
}
cooldownSprite.fillAmount -= progressPerSecond;
}