Commit ce8f9ea5 authored by Rugeon's avatar Rugeon
Browse files

Early fun basic bot working, chases and shoots if player stays still

parent df34330b
......@@ -23,9 +23,9 @@ namespace Complete
case 3:
return FunBehaviour();
default:
return new Root (new Action(()=> Turn(0.1f)));
return new Root(new Action(() => Turn(0.1f)));
}
}
......@@ -36,7 +36,12 @@ namespace Complete
}
private Node RandomFire() {
return new Action(() => Fire(UnityEngine.Random.Range(0.0f, 1.0f)));
return new Action(() => Fire(UnityEngine.Random.Range(0.0f, 0.5f)));
}
private Node StopMoving()
{
return new Action(() => Move(0));
}
//
......@@ -62,7 +67,7 @@ namespace Complete
Stops.IMMEDIATE_RESTART,
// Stop turning and fire
new Sequence(StopTurning(),
//new Wait(2f),
new Wait(2f),
RandomFire())),
new BlackboardCondition("targetOnRight",
Operator.IS_EQUAL, true,
......@@ -80,23 +85,65 @@ namespace Complete
{
return new Root(
new Service(0.2f, UpdatePerception,
new Selector(
new BlackboardCondition("targetInFront",
Operator.IS_EQUAL, true,
Stops.IMMEDIATE_RESTART,
// Go forwards
new Action(() => Move(0.6f))),
new BlackboardCondition("targetInFront",
Operator.IS_EQUAL, false,
Stops.IMMEDIATE_RESTART,
// Go forwards
new Action(() => Move(-0.6f)))
new Sequence(//Sequence allows behaviour to rotate and move at same time
new Selector(
new BlackboardCondition("targetOffCentre",
Operator.IS_SMALLER_OR_EQUAL, 0.1f,
Stops.IMMEDIATE_RESTART,
// Stop turning and fire
new Sequence(StopTurning(),
new Wait(0.8f),
RandomFire())
),
new BlackboardCondition("targetOnRight",
Operator.IS_EQUAL, true,
Stops.IMMEDIATE_RESTART,
// Turn right toward target
new Action(() => Turn(1.0f))),
// Turn left toward target
new Action(() => Turn(-1.0f))
),
new Selector(//Go forwards or backwards at the same time as other actions
new BlackboardCondition("targetInFront",
Operator.IS_EQUAL, true,
Stops.IMMEDIATE_RESTART,
// Go forwards
new Sequence(
new Wait(0.1f),
new Action(() => Move(0.6f)))
),
new BlackboardCondition("targetInFront",
Operator.IS_EQUAL, false,
Stops.IMMEDIATE_RESTART,
// Go backwards
new Sequence(
new Wait(0.1f),
new Action(() => Move(-0.6f)))
)
),
new BlackboardCondition("targetDistance",
Operator.IS_SMALLER_OR_EQUAL, 20.0f,
Stops.IMMEDIATE_RESTART,
// Stop Moving
//new Sequence(StopTurning(),
//new Wait(0.1f),
StopMoving()
//new Action(() => Move(0.0f)))
)
)
)
);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment