public static DOutput move_backwards(ResourceFightDNCreature p_cre) { return((float p_input) => { p_cre.m_actions.add("MOVE", p_input, () => { p_cre.move(-p_cre.m_forward * 5f); }); }); }
public static DOutput flee_from_nearest_creature(ResourceFightDNCreature p_cre) { return((float p_input) => { GameObject creature = p_cre.senseClosest("CREATURE"); if (creature) { float angle = Vector2Calc.getAngle(p_cre.m_forward, creature.transform.position - p_cre.transform.position); p_cre.m_actions.add("ROTATE", p_input, () => { p_cre.transform.Rotate(0, 0, -2 * Mathf.Sign(angle)); }); p_cre.m_actions.add("MOVE", p_input, () => { p_cre.move(p_cre.m_forward * -1f); }); } else { return; } }); }
public static DOutput search_resource(ResourceFightDNCreature p_cre) { return((float p_input) => { GameObject resource = p_cre.senseClosest("RESOURCE"); if (resource) { float angle = Vector2Calc.getAngle(p_cre.m_forward, resource.transform.position - p_cre.transform.position); p_cre.m_actions.add("ROTATE", p_input, () => { p_cre.transform.Rotate(0, 0, -2 * Mathf.Sign(angle)); }); if (angle < 10f) { p_cre.m_actions.add("MOVE", p_input, () => { p_cre.move(p_cre.m_forward); }); } } else { p_cre.m_actions.add("ROTATE", p_input, () => { p_cre.transform.Rotate(0, 0, 1); }); } }); }