// Returns current animation for this gamestate (and the next can be implied from there). public void doRobotAI(IntVec2 pos, GameState gs, ref IntVec2 animD, ref TileUnit.Animation animT) { animD = new IntVec2(0, 0); animT = Animation.IDLE; IntVec2 r = findResource(pos, gs); if (r == null) { animT = Animation.IDLE; } if (r != null) { var list = getPath(pos, r, gs); if (list != null) { // 1 means we didnt go anywhere. Debug.Assert(list.Count > 1); animD = list[1] - pos; if (list.Count == 2) { animT = Animation.HARVEST; } else { animT = Animation.MOVE; } } } }
public override void doAI(IntVec2 pos, GameState gs, ref IntVec2 animD, ref TileUnit.Animation animT) { animD = new IntVec2(0, 0); animT = Animation.IDLE; IntVec2 iv = find(pos, gs, validTarget); if (iv == null) { return; } Debug.Assert(pos != null); if (Vector2.Distance(new Vector2(iv.x, iv.y), new Vector2(pos.x, pos.y)) < 7f) { int accmod = UnityEngine.Random.Range(-5, 5); shootProjectile(pos, Projectile.ProjectileType.Bullet, iv, 3, 4, accmod, false); } if (iv != null) { var r = getPath(pos, iv, gs); if (r != null) { // 1 means we didnt go anywhere. Debug.Assert(r.Count > 1); animD = r[1] - pos; animT = Animation.MOVE; } } }
// Returns current animation for this gamestate (and the next can be implied from there). public void doRobotAI(IntVec2 pos, GameState gs, ref IntVec2 animD, ref TileUnit.Animation animT) { animT = Animation.IDLE; animD = new IntVec2(0, 0); if (amount < MAX_AMOUNT) { IntVec2 r = find(pos, gs, collectable); if (r == null) { animT = Animation.IDLE; } if (r != null) { var list = getPath(pos, r, gs); if (list != null) { // 1 means we didnt go anywhere. Debug.Assert(list.Count > 1); animD = list[1] - pos; if (list.Count == 2) { animT = Animation.COLLECT; } else { animT = Animation.MOVE; } } } } //drop off. else { IntVec2 r = find(pos, gs, dropoffable); if (r == null) { animT = Animation.IDLE; } if (r != null) { var list = getPath(pos, r, gs); if (list != null) { // 1 means we didnt go anywhere. Debug.Assert(list.Count > 1); animD = list[1] - pos; if (list.Count == 2) { animT = Animation.STORE; } else { animT = Animation.MOVE; } } } } }
// Breaks coupling, but no other way to handle bullets? public abstract void doAI(IntVec2 pos, GameState gs, ref IntVec2 animD, ref TileUnit.Animation anim);