public FocusLeaf(BasicBot _bot, float _timerMax) : base() { timerMax = _timerMax; timer = UnityEngine.Random.Range(0.4f, timerMax); bot = _bot; body = bot.body; }
public CavalryTree(BasicBot bot) { priorityBuckets = new List <Node>() { new Selector("priority 0", new List <Node>() { }), new Selector("priority 1", new List <Node>() { //Wounded node here }), new Selector("priority 2", new List <Node>() { new Sequencer("Cavalry Charge", new List <Node>() { new CavalryChargeLeaf(bot), new CavalryRecenterLeaf(bot) }) }), new Selector("priority 3", new List <Node>() { }), new Selector("priority 4", new List <Node>() { //Idle node here }) }; rootNode = new Selector("root", (priorityBuckets)); }
void Start() { flag = GetComponentInChildren <Flag>(); interval = 0.5f; time = interval; foreach (Transform t in transform) { foreach (Transform t2 in t) { BasicBot b = t2.GetComponent <BasicBot>(); if (b) { minions.Add(b); b.squad = this; b.body.team = team; b.body.SetColors(); b.body.ApplyColors(); officer = (t.CompareTag("Officer") && !officer) ? b : officer; medic = (t.CompareTag("Medic") && !medic) ? b : medic; } } } if (!officer) { officer = minions[Random.Range(0, minions.Count)]; } flag.carrier = officer; SetDefaultBehavior(squadType); flag.Setup(); }
public void TargetCommand(GameObject target, BasicBot bot = null, float timeLeft = -1, int priority = 3) { timeLeft = (timeLeft < 0) ? interval : timeLeft; foreach (BasicBot b in minions) { if (bot) { if (b != bot) { continue; } } b.Command(new Command( new Sequencer("MoveTarget", new List <Node>() { new Gate(delegate() { return((target && Vector2.Distance(target.transform.position, b.transform.position) > Mathf.Min(closeness, b.squad.SquadRadius)) ?NodeState.Success :NodeState.Failure); }, "MoveTarget Gate"), new MoveTargetLeaf(b, target) }), timeLeft), priority); } }
public VolleyLeaf(BasicBot _bot, Vector2 _target) : base() { bot = _bot; aimTarget = _target; shoottimer = Vector2.Distance(bot.transform.position, aimTarget) + Random.Range(0.5f, 1.2f); started = false; }
public MaintainLeaf(BasicBot _bot, float _timerMax = 1.5f, int _prefDist = 2, int _leeway = 8) : base() { timerMax = _timerMax; timer = timerMax; bot = _bot; pos = bot.transform; //target = bot.attackTarget.transform; prefDist = _prefDist; leeway = _leeway; }
public WiggleLeaf(BasicBot _bot, float _timerMax = 2, float _maxWig = 0.4f, float _randoDist = 2) : base() { timerMax = _timerMax; timer = timerMax; bot = _bot; //target = bot.attackTarget.transform; randoDist = _randoDist; maxWig = _maxWig; swingMax = Random.Range(0.2f, _maxWig); swingTimer = swingMax; }
public AimLeaf(BasicBot _bot, float _scaleFactor = 0.1f) : base() { scaleFactor = _scaleFactor; bot = _bot; if (bot.attackTarget != null) { shoottimer = Vector2.Distance(bot.transform.position, bot.attackTarget.transform.position) * scaleFactor; shoottimer = Mathf.Clamp(shoottimer, 2, 7) + Random.Range(0.5f, 1.2f); aimTarget = (Vector2)bot.attackTarget.transform.position;// + Random.insideUnitCircle * Mathf.Tan (0.5f); } }
public void TakeTurn_EmptyBoard_PlaysInColumn0Row0() { // arrange BasicBot player = new BasicBot(); FakeBoard emptyBoard = new FakeBoard(); // act var positionPlayed = player.TakeTurn(emptyBoard); // assert Assert.That(positionPlayed.Column, Is.EqualTo(0)); Assert.That(positionPlayed.Row, Is.EqualTo(0)); }
public SwordTree(BasicBot bot) { priorityBuckets = new List <Node>() { new Selector("priority 0", new List <Node>() { }), new Selector("priority 1", new List <Node>() { new Sequencer("wounded", new List <Node>() { new Gate(delegate() { return(NodeState.Failure); }, "Wounded Gate"), new RandomSelector("Wounded Action", new List <Node>() { new FleeLeaf(bot), new MedicLeaf(bot) }) }) }), new Selector("priority 2", new List <Node>() { new Sequencer("fight", new List <Node>() { new Gate(delegate() { return((bot.attackTarget == null) ? NodeState.Failure : NodeState.Success); }), new RandomSelector("Fight", new List <Node>() { new WiggleLeaf(bot), new Sequencer("Prepare", new List <Node>() { new MaintainLeaf(bot), new ChargeLeaf(bot) }) }, new List <int>() { 1, 0 }) }) }), new Selector("priority 3", new List <Node>() { }), new Selector("priority 4", new List <Node>() { //Idle node here }) }; rootNode = new Selector("root", (priorityBuckets)); }
public void TakeTurn_Column0Row0AlreadyHasPiece_PlaysInColumn0Row0Anyway() { // arrange BasicBot player = new BasicBot(); FakeBoard partiallyFullBoard = new FakeBoard(); partiallyFullBoard.SetToken(0, 0, PlayerToken.Opponent); // act var positionPlayed = player.TakeTurn(partiallyFullBoard); // assert Assert.That(positionPlayed.Column, Is.EqualTo(0)); Assert.That(positionPlayed.Row, Is.EqualTo(0)); }
public ArquebusTree(BasicBot bot) { priorityBuckets = new List <Node> () { new Selector("priority 0", new List <Node>() { }), new Selector("priority 1", new List <Node>() { new Sequencer("wounded", new List <Node>() { new Gate(delegate() { return(NodeState.Failure); }, "Wounded Gate"), new RandomSelector("Wounded Action", new List <Node>() { new FleeLeaf(bot), new MedicLeaf(bot) }) }) }), new Selector("priority 2", new List <Node>() { new Sequencer("fight!", new List <Node>() { new Gate(delegate() { // Debug.Log("Acting: " + (bot.attackTarget != null && Vector2.Distance(bot.transform.position, bot.attackTarget.position) < 100)); return((bot.attackTarget && Vector2.Distance(bot.transform.position, bot.attackTarget.transform.position) < 100) ? NodeState.Success: NodeState.Failure); }, "Fight Gate"), //new IntervalGate(5), new AimLeaf(bot) }) }), new Selector("priority 3", new List <Node>() { }), new Selector("priority 4", new List <Node>() { }) }; rootNode = new Selector("root", (priorityBuckets)); }
public void AttackSquad(Squad targetSquad, BasicBot bot = null, float timeLeft = -1, int priority = 3) { SetDefaultBehavior(SquadType.Hold); timeLeft = (timeLeft < 0) ? interval : timeLeft; foreach (BasicBot b in minions) { if (bot) { if (b != bot) { continue; } } if (enemies.Count > 0) { b.attackTarget = enemies[Random.Range(0, enemies.Count)]; } } }
private void OnTriggerExit2D(Collider2D collider) { squad.enemies.Remove(collider.gameObject); if (collider.CompareTag("Body")) { Body colliderBody = collider.GetComponent <Body>(); if (colliderBody.team == squad.team && colliderBody.untargetable == false) { if (collider.GetComponent <BasicBot>() != null) { BasicBot bot = collider.GetComponent <BasicBot>(); if (squad.squadType != SquadType.TargetFollow) { squad.Command = delegate() { squad.TargetCommand(squad.flag.gameObject, bot); } } ; } } } } }
public bool UpdateMinions() { if (minions.Count < 1) { return(false); } if (!flag.carrier) { officer = minions[Random.Range(0, minions.Count)]; flag.carrier = officer; } for (int i = 0; i < minions.Count; i++) { BasicBot b = minions[i]; if (!b || b.Ded) { minions.Remove(b); } } return(true); }
public void TakeTurn_BoardHasAFewPieces_PlaysInColumn0Row0() { // arrange BasicBot player = new BasicBot(); FakeBoard partiallyFullBoard = new FakeBoard(); partiallyFullBoard.SetBoard( new PlayerToken[, ] { { PlayerToken.Me, PlayerToken.Me, PlayerToken.None }, // Row 0, { PlayerToken.None, PlayerToken.None, PlayerToken.None }, // Row 1, { PlayerToken.None, PlayerToken.Opponent, PlayerToken.Opponent } }); // Row 2 // Column 0, Column 1, Column 2 // act var positionPlayed = player.TakeTurn(partiallyFullBoard); // assert Assert.That(positionPlayed.Column, Is.EqualTo(0)); Assert.That(positionPlayed.Row, Is.EqualTo(0)); }
private void OnCollisionEnter2D(Collision2D collision) { Collider2D collider = collision.collider; if (collider.CompareTag("Player")) { Physics2D.IgnoreCollision(coll, collider); } if (collider.CompareTag("Body")) { if (collider.GetComponent <BasicBot>()) { BasicBot bot = collider.GetComponent <BasicBot>(); int direction = (bot.squad) ? bot.squad.direction : 1; bot.Command(new Command(new Sequencer("Move Sequence", new List <Node>() { new MoveLeaf(bot, transform.position + new Vector3(10 * Random.Range(-1, 1), 5 * (-direction), 0)) }), 3), 2); } } }
int recenterDist = 40; //TODO Determine whether this is good public CavalryRecenterLeaf(BasicBot _bot) { bot = _bot; timerMax = 2; timer = timerMax; }
public CavalryChargeLeaf(BasicBot _bot) : base() { bot = _bot; timerMax = 2; timer = timerMax; }
public FleeLeaf(BasicBot _bot) : base() { bot = _bot; }
public MoveLeaf(BasicBot _bot, Vector2 _target) : base() { bot = _bot; target = _target; }
public MoveTargetLeaf(BasicBot _bot, GameObject _target) : base() { bot = _bot; target = (_target == null) ? null : _target.transform; }
public MedicLeaf(BasicBot _bot) : base() { bot = _bot; target = null; pos = bot.transform; }
public ShootLeaf(BasicBot bot) : base() { weapon = (RangedWeapon)bot.body.weapon; }
public ChargeLeaf(BasicBot _bot, float _timerMax = 1.5f) : base() { timerMax = _timerMax; timer = timerMax; bot = _bot; }