wangguan
2020-12-03 ad376c4760e5e0c2183c51d21d044fd4d03f9721
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Core.Extensions;
#if UNITY_EDITOR
using UnityEngine;
#endif
 
namespace TowerDefense.Nodes
{
    /// <summary>
    /// Deterministically selects a node in the order it appears on the list
    /// </summary>
    public class FixedNodeSelector : NodeSelector
    {
        /// <summary>
        /// Index to keep track of what node should be selected next
        /// </summary>
        protected int m_NodeIndex;
 
        /// <summary>
        /// Selects the next node using <see cref="m_NodeIndex" />
        /// </summary>
        /// <returns>The next selected node, or null if there are no valid nodes</returns>
        public override Node GetNextNode()
        {
            if (linkedNodes.Next(ref m_NodeIndex, true))
            {
                return linkedNodes[m_NodeIndex];
            }
            return null;
        }
 
#if UNITY_EDITOR
        protected override void OnDrawGizmos()
        {
            Gizmos.color = Color.yellow;
            base.OnDrawGizmos();
        }
#endif
    }
}