public override bool TryGetNext(out DialogueItem item) { item = new DialogueItem(); switch (this.items.Length) { case 0: this.lastIndex = -1; return(false); case 1: if (this.lastIndex == -1) { this.SetText(ref item, 0); return(true); } this.lastIndex = -1; return(false); default: int index = this.lastIndex; do { index = Random.Range(0, this.items.Length); } while (index == this.lastIndex); this.SetText(ref item, index); return(true); } }
public override bool TryGetNext(out DialogueItem item) { if (this.lastIndex < this.items.Length - 1) { item = this.items[++this.lastIndex]; return(true); } item = new DialogueItem(); return(false); }
private void SetText(ref DialogueItem item, int index) { item = this.items[index]; this.lastIndex = index; }
public abstract bool TryGetNext(out DialogueItem text);