Пример #1
0
	public void aiAct() {

		//Perform decision making based off of decision parameters decided by overarching AI.
		System.Random random = new System.Random();
		//Check if idle behavior instead of non-idle.
		if(random.NextDouble() < moveIdle) {
			moveDirB = MoveDirBehavior.IDLE;
		} else {
			//Check if offensive movement behavior instead of defensive.
			if(random.NextDouble() < moveDir)
				moveDirB = MoveDirBehavior.TOWARD;
			else
				moveDirB = MoveDirBehavior.AWAY;
		}
		//Check if global movement behavior instead of non-global.
		if(random.NextDouble() > moveGlobalScope) {
			moveScopeB = MoveScopeBehavior.GLOBAL;
		} else {
			//Check if macro movement behavior instead of micro.
			if(random.NextDouble() > moveScope)
				moveScopeB = MoveScopeBehavior.MACRO;
			else
				moveScopeB = MoveScopeBehavior.MICRO;
		}
		//Check if head target behavior instead of body.
		if(random.NextDouble() > moveTarget)
			moveTargetB = MoveTargetBehavior.HEAD;
		else
			moveTargetB = MoveTargetBehavior.BODY;
		//Check if ally target behavior instead of enemy.
		if(random.NextDouble() > moveTeam)
			moveTeamB = MoveTeamBehavior.ALLY;
		else
			moveTeamB = MoveTeamBehavior.ENEMY;
		//Check if macro behavior instead of micro.
		if(random.NextDouble() > attack)
			attackB = AttackBehavior.MACRO;
		else
			attackB = AttackBehavior.MICRO;

		//Possible blocks to attack.
		LinkedList<GridBlock> attackBlocks = getAttackBlocks();
		//Choose the block to attack from attack block list.
		GridBlock attackBlock = chooseAttackBlock(attackBlocks);

		//Check if there's nowhere to attack or enemy is stronger, then move or attack.
		if(attackBlocks.Count == 0 || attackBlock.unitInstalled.getHealthPercentage() > unit.getHealthPercentage()) {
			//Get the list of blocks to move to.
			LinkedList<GridBlock> moveBlockList = getMoveBlockList();

			foreach(GridBlock b in moveBlockList) {
				MoveScript ms = new MoveScript(unit, b);
			}
		} else {
			AttackScript ms = new AttackScript(unit, attackBlock);
		}
	}
Пример #2
0
	public UnitAI(UnitScript unit) {
		this.unit = unit;

		moveDir = 0.5;
		moveIdle = 0;
		moveScope = 0.5;
		moveGlobalScope = 0.5;
		moveTarget = 0.5;
		moveTeam = 0.5;
		attack = 0.5;

		moveDirB = MoveDirBehavior.IDLE;
		moveScopeB = MoveScopeBehavior.MICRO;
		moveTargetB = MoveTargetBehavior.HEAD;
		moveTeamB = MoveTeamBehavior.ENEMY;
		attackB = AttackBehavior.MICRO;
	}