public AIChaseNode() { // move closer AITargetDecisionNode leftTargetNode = new AITargetDecisionNode(-1, 0, 1000000); // if the user is on the left, go left double[] v = new double[2]; v[0] = -10000; v[1] = 0; AISetVelocityNode goLeftNode1 = new AISetVelocityNode(v); leftTargetNode.setLeftChild(goLeftNode1); // else // if the user is on the left, go right v = new double[2]; v[0] = 10000; v[1] = 0; AISetVelocityNode goRightNode1 = new AISetVelocityNode(v); leftTargetNode.setRightChild(goRightNode1); // since we're not in range, switch to a new weapon if it's been out of range for a while AITickDecisionNode weaponSwitchCounter = new AITickDecisionNode(1); goLeftNode1.setNextNode(weaponSwitchCounter); goRightNode1.setNextNode(weaponSwitchCounter); AISelectWeaponNode selectWeaponNode1 = new AISelectWeaponNode(); weaponSwitchCounter.setLeftChild(selectWeaponNode1); this.setFirstNode(leftTargetNode); }
public AISmartSwitchNode() { // check whether the current weapon has any ammo AIAmmoDecisionNode ammoNode1 = new AIAmmoDecisionNode(); // if we do have ammo, check whether we can save some cooldown time by switching weapons now AIFreeSwitchDecisionNode switchNode1 = new AIFreeSwitchDecisionNode(); ammoNode1.setLeftChild(switchNode1); // if either event happens, then switch weapons AISelectWeaponNode selectWeaponNode2 = new AISelectWeaponNode(); ammoNode1.setRightChild(selectWeaponNode2); switchNode1.setLeftChild(selectWeaponNode2); // else, if we don't want to switch // remember the first node this.setFirstNode(ammoNode1); }