public NodeSelector Create <T>() where T : class { NodeSelector next = null; if (_nextFactory != null) { next = _nextFactory.Create <Token <T, TProperty> >(); } if (typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(Token <,>)) { var arguments = typeof(T).GetGenericArguments(); Type tokenType = typeof(PropertyNodeSelector <, ,>).MakeGenericType(arguments[0], arguments[1], typeof(TProperty)); var tokenSelector = (NodeSelector)Activator.CreateInstance(tokenType, next, _configurator, _propertyInfo); return(tokenSelector); } Type type = typeof(PropertyNodeSelector <,>).MakeGenericType(typeof(T), typeof(TProperty)); var selector = (NodeSelector)Activator.CreateInstance(type, next, _configurator, _propertyInfo); return(selector); }
public NodeSelector Create <T>() where T : class { NodeSelector next = null; if (_nextFactory != null) { next = _nextFactory.Create <T>(); } if (typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(Token <,>)) { Type[] arguments = typeof(T).GetGenericArguments(); if (arguments[1] != typeof(TValue)) { throw new ArgumentException("Value type does not match token type"); } Type nodeType = typeof(NotNullNodeSelector <,>).MakeGenericType(arguments); var selector = (NodeSelector)Activator.CreateInstance(nodeType, next, _configurator); return(selector); } throw new ArgumentException("Type was not a token type: " + typeof(T).FullName); }
public PropertyNodeSelector(NodeSelector next, RuntimeConfigurator configurator, PropertyInfo property) { _next = next; _configurator = configurator; Property = property; }
//准备释放魔法 public void PrepareMagic(Hero _hero, Magic _magic) { //判定魔法学派,根据英雄的相应学派等级释放不同效果 int magicLevel = _magic.GetMagicLevel(_hero); MagicType type = _magic.type; if (type == MagicType.Battle) { } currentMagic = _magic; //隐藏节点 NodeSelector.HideActionNodes(); //目标类型:无目标直接释放 int targetType = Mathf.Min(_magic.targetType.Length - 1, magicLevel); //int effect = Mathf.Min(_magic.effects.Length - 1, magicLevel); if (_magic.targetType[targetType] == MagicTargetType.Null) { CastMagic(); } else { //是需要选择目标的技能 MagicTargetFliter fliter = _magic.targetFliter[Mathf.Min(_magic.targetFliter.Length - 1, magicLevel)]; NodeSelector.GetSpellableNodes(fliter); } }
void Start() { ani = GetComponent <Animator>(); sprite = GetComponent <SpriteRenderer>(); List <Node> rootChildren = new List <Node>(); List <Node> animationChildren = new List <Node>(); Npeaceful = new NodeAction(WithoutOpponent); Nattack1 = new NodeAction(OneOpponent); Nattack2 = new NodeAction(TwoOpponent); NattackAndDefend = new NodeAction(OneOpponentPlusOne); Nreversal = new NodeAction(Reversal); Ndrawray = new NodeAction(DrawRay); ani.SetInteger("searchStatus", 0); animationChildren.Add(Nreversal); animationChildren.Add(Npeaceful); animationChildren.Add(Nattack1); animationChildren.Add(Nattack2); animationChildren.Add(NattackAndDefend); Nanimation = new NodeSelector(animationChildren); rootChildren.Add(Ndrawray); rootChildren.Add(Nanimation); Nroot = new NodeSequence(rootChildren); }
/// <inheritdoc /> public override Selector VisitSelector(CommonTree selectorTree, string selectorType) { Selector selector; switch (selectorType) { case MapCssStrings.NodeSelector: selector = new NodeSelector(); break; case MapCssStrings.WaySelector: selector = new WaySelector(); break; case MapCssStrings.AreaSelector: selector = new AreaSelector(); break; case MapCssStrings.CanvasSelector: selector = new CanvasSelector(); break; default: throw new MapCssFormatException(selectorTree, String.Format(Strings.MapCssUnknownSelectorType, selectorType)); } var operation = selectorTree.Children[0].Text; ParseOperation(selectorTree, selector, operation); return(selector); }
public static void ConsoleWriteLine(this NodeSelector selector) { Console.WriteLine("Selector: {0}", selector); while (selector.Next != null) { Console.WriteLine("Next: {0}", selector.Next); selector = selector.Next; } }
public CompareNodeSelector(NodeSelector next, RuntimeConfigurator configurator, Comparator <TProperty, TProperty> comparator, Value <TProperty> value) { _value = value; _next = next; _configurator = configurator; _comparator = comparator; }
public override Tuple <int, int> ChooseMove() { CurrentBoard = new Board(Board); Node root = NodeSelector.ChooseNode(this); Stopwatch stopwatch = Stopwatch.StartNew(); Tuple <int, int> chosenMove = Algorithm.ChoiceBestMove(root).PositionOnBoard; stopwatch.Stop(); Times.Add(stopwatch.ElapsedMilliseconds); return(chosenMove); }
public override void Init(PipelineContext ctx, XmlNode node) { base.Init(ctx, node); dumpReader = node.ReadBool("@debug", false); XmlNode x = node.SelectSingleNode("select"); if (x != null) { selector = NodeSelector.Parse(x); } }
private void Awake() { if (m_instance) { Destroy(gameObject); } else { m_instance = this; DontDestroyOnLoad(gameObject); } }
public void Should_access_no_level_property() { Expression <Func <A, A> > propertyExpression = (A a) => a; PropertyExpressionVisitor visitor = new PropertyExpressionVisitor <A>(null); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf <TypeNodeSelector <A> >(selector); Assert.IsNull(selector.Next); }
public NodeSelector Create <T>() where T : class { NodeSelector next = null; if (_nextFactory != null) { next = _nextFactory.Create <T>(); } var selector = new TypeNodeSelector <T>(next, _configurator); return(selector); }
public void Should_access_first_level_property() { Expression <Func <A, B> > propertyExpression = (A a) => a.TheB; PropertyExpressionVisitor visitor = new PropertyExpressionVisitor <A>(_configurator); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf <TypeNodeSelector <A> >(selector); Assert.IsInstanceOf <PropertyNodeSelector <A, B, B> >(selector.Next); Assert.IsNull(selector.Next.Next); }
public void Should_get_list_getters() { Expression <Func <A, double> > propertyExpression = (A a) => a.Amounts[1]; var visitor = new PropertyExpressionVisitor <A>(null); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf <TypeNodeSelector <A> >(selector); Assert.IsInstanceOf <PropertyNodeSelector <A, IList <double> > >(selector.Next); Assert.IsInstanceOf <ListNodeSelector <Token <A, IList <double> >, double> >(selector.Next.Next); Assert.IsNull(selector.Next.Next.Next); }
public NodeSelector Create <T>() where T : class { NodeSelector next = null; if (_nextFactory != null) { next = _nextFactory.Create <Token <T, TElement> >(); } Type type = typeof(ListNodeSelector <,>).MakeGenericType(typeof(T), typeof(TElement)); var selector = (NodeSelector)Activator.CreateInstance(type, next, _index); return(selector); }
public void Should_get_indexers() { Expression <Func <A, int> > propertyExpression = (A a) => a.TheB.Values[1]; var visitor = new PropertyExpressionVisitor <A>(null); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf <TypeNodeSelector <A> >(selector); Assert.IsInstanceOf <PropertyNodeSelector <A, B> >(selector.Next); Assert.IsInstanceOf <PropertyNodeSelector <A, B, int[]> >(selector.Next.Next); Assert.IsInstanceOf <ArrayNodeSelector <Token <Token <A, B>, int[]>, int> >(selector.Next.Next.Next); Assert.IsNull(selector.Next.Next.Next.Next); }
public void Should_access_third_level_property() { Expression <Func <A, string> > propertyExpression = (A a) => a.TheB.TheC.Value; var visitor = new PropertyExpressionVisitor <A>(null); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf <TypeNodeSelector <A> >(selector); Assert.IsInstanceOf <PropertyNodeSelector <A, B> >(selector.Next); Assert.IsInstanceOf <PropertyNodeSelector <A, B, C> >(selector.Next.Next); Assert.IsInstanceOf <PropertyNodeSelector <Token <A, B>, C, string> >(selector.Next.Next.Next); Assert.IsNull(selector.Next.Next.Next.Next); }
//单位行动开始,显示移动范围,可攻击目标 public void PlayerActionStart(Unit _unit) { GameManager.gameState = GameState.playerControl; //获取并高亮单位可行动的节点 NodeSelector.GetUnitActionNodes(_unit); NodeSelector.HighlightUnitActionNodes(); //将当前鼠标高亮节点,触发高亮事件 MapManager_Battle map = BattleManager.instance.map; if (BattleNodeMgr.instance.playerHovered != null) { map.OnNodeHovered(BattleNodeMgr.instance.playerHovered); } }
IEnumerator ActionStartCor(Unit _unit) { UnitHaloMgr.instance.HaloFlashStart(_unit, "action"); //测试:永远是玩家控制 //PlayerActionStart(_unit); if (!GameManager.instance.players[BattleManager.players[_unit.side]].isAI) { PlayerActionStart(_unit); } else { AIActionMgr.instance.AIActionStart(_unit); } //在下令前暂停 while (order == null) { yield return(null); } //发出指令后,开始执行命令 UnitHaloMgr.instance.HaloFlashStop(_unit); //重置所有可行动节点 if (!GameManager.instance.players[BattleManager.players[_unit.side]].isAI) { NodeSelector.HideActionNodes(); } //执行指令 InvokeOrder(); GameManager.gameState = GameState.canNotControl; //在指令完成前暂停 while (order != null) { yield return(null); } //命令执行完毕 yield return(new WaitForSeconds(.5f)); ActionEnd(); }
public IDisposableNodeViewProvider Create(NodeSelector selector) { var(nodeType, path) = selector; switch (nodeType) { case NodeType.Total: return(Create(new TotalValue(_stat))); case NodeType.Subtotal: return(Create(new SubtotalValue(_stat))); case NodeType.UncappedSubtotal: return(Create(new UncappedSubtotalValue(_stat))); case NodeType.PathTotal: return(Create(new PathTotalValue(_stat, path))); case NodeType.Base when path.ConversionStats.Any(): return(Create(new ConvertedBaseValue(path))); case NodeType.Base: return(Create(new BaseValue(_stat, path))); case NodeType.BaseOverride: return(Create(new FormAggregatingValue(_stat, Form.BaseOverride, path, CalculateOverride))); case NodeType.BaseSet: return(Create(new FormAggregatingValue(_stat, Form.BaseSet, path, CalculateBaseAdd))); case NodeType.BaseAdd: return(Create(new FormAggregatingValue(_stat, Form.BaseAdd, path, CalculateBaseAdd))); case NodeType.Increase: return(Create(new MultiPathFormAggregatingValue(_stat, Form.Increase, path, CalculateIncrease))); case NodeType.More: return(Create(new MultiPathFormAggregatingValue(_stat, Form.More, path, CalculateMore))); case NodeType.TotalOverride: return(Create(new FormAggregatingValue(_stat, Form.TotalOverride, path, CalculateOverride))); default: throw new ArgumentOutOfRangeException(nameof(selector), nodeType, null); } }
public void Should_access_fourth_level_property() { Expression <Func <A, int> > propertyExpression = (A a) => a.TheB.TheC.Value.Length; var visitor = new PropertyExpressionVisitor <A>(_configurator); NodeSelector selector = visitor.CreateSelector(propertyExpression.Body); selector.ConsoleWriteLine(); Assert.IsInstanceOf <TypeNodeSelector <A> >(selector); Assert.IsInstanceOf <PropertyNodeSelector <A, B, B> >(selector.Next); Assert.IsInstanceOf <PropertyNodeSelector <A, B, C, C> >(selector.Next.Next); Assert.IsInstanceOf <PropertyNodeSelector <Token <A, B>, C, string, string> >(selector.Next.Next.Next); Assert.IsInstanceOf <PropertyNodeSelector <Token <Token <A, B>, C>, string, int, int> >( selector.Next.Next.Next.Next); Assert.IsNull(selector.Next.Next.Next.Next.Next); }
void Start() { if (_laserHitSphere == null) { _laserHitSphere = this.transform.GetChild(0).gameObject; } if (_laserHitSphere) { _laserHitSphereMaterial = _laserHitSphere.GetComponent <Renderer>().material; } _nodeSelector = NodeSelector.Instance; if (_nodeSelector == null) { Debug.LogError("NodeHitTester not found in scene"); } _lineRenderer = GetComponent <LineRenderer>(); _lineMaterial = GetComponent <Renderer>().material; }
public NodeSelector Create <T>() where T : class { NodeSelector next = null; if (_nextFactory != null) { next = _nextFactory.Create <Token <T, Tuple <TElement, int> > >(); } if (typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(Token <,>)) { Type[] arguments = typeof(T).GetGenericArguments(); if (arguments[1] != typeof(TValue)) { throw new ArgumentException("Value type does not match token type"); } if (typeof(IList <TElement>).IsAssignableFrom(typeof(TValue))) { Type elementType = typeof(TValue).GetGenericArguments()[0]; if (elementType != typeof(TElement)) { throw new ArgumentException("Element type does not match list element type"); } Type nodeType = typeof(ListEachNodeSelector <, ,>).MakeGenericType(arguments[0], arguments[1], elementType); var selector = (NodeSelector)Activator.CreateInstance(nodeType, next, _configurator); return(selector); } throw new ArgumentException("Unknown enumerable type: " + typeof(T).GetShortName()); } throw new ArgumentException("Type was not a token type: " + typeof(T).FullName); }
public override void Start() { base.Start(); EntityType type = EntityType.Companion; AddType(type); blackboard.treeData.Add("companion", this); NodeSelector root = new NodeSelector(new BTNode[] { new ActionCheckBuff(), new NodeCounter( new ActionToggleBuff(), player.buffTime * 3 ), new ActionChangeColour() }); brain = new AIBrain(root, blackboard); brain.Start(); fixedRotation = transform.rotation; light = transform.GetChild(0).gameObject; }
public TypeNodeSelector(NodeSelector next, RuntimeConfigurator configurator) { _next = next; _configurator = configurator; }
/// <summary>Register a listener which forward node notifications via the driver</summary> /// <param name="jmx">holds the connection to the driver's JMX server</param> /// <param name="selector">specifies the nodes from which notifications are forwarded</param> /// <param name="mbeanName">the name of the node MBean for which notifications are forwarded</param> /// <param name="listener">the listener to register</param> /// <param name="handback">an arbitrary object provided when the listerner was registered</param> /// <returns>A unique id under which the listener is registered</returns> public static string RegisterFowrwardingNotificationListener(this JMXDriverConnectionWrapper jmx, NodeSelector selector, string mbeanName, BaseDotnetNotificationListener listener, object handback) { NotificationListener javaListener = new DotnetNotificationListenerWrapper(new DotnetNotificationDispatcher(listener, handback)); String id = jmx.registerForwardingNotificationListener(selector, mbeanName, javaListener, null, null); //Console.WriteLine("added forwarding notification listener " + listener + " to " + jmx + " with id=" + id); return(id); }
public override void Init(PipelineContext ctx, XmlNode node) { base.Init(ctx, node); selector = NodeSelector.Parse(node.SelectMandatoryNode("select")); }
public ListEachNodeSelector(NodeSelector next, RuntimeConfigurator configurator) : base(next, configurator) { }
public NotEqualNodeSelector(NodeSelector next, RuntimeConfigurator configurator, TProperty value) { _value = value; _next = next; _configurator = configurator; }