public void cs_step(string directionName) { context.RunRoutineFromLua(mapEvent.GetComponent <MapEvent>().StepRoutine(EightDirExtensions.Parse(directionName))); }
public void cs_walk(string directionName, int count) { context.RunRoutineFromLua(mapEvent.GetComponent <MapEvent>().StepMultiRoutine(EightDirExtensions.Parse(directionName), count)); }
public EightDir DirectionTo(Vector2Int location) { return(EightDirExtensions.DirectionOf(location - this.location)); }
public EightDir DirectionTo(MapEvent other) { return(EightDirExtensions.DirectionOf(other.location - location)); }
public IEnumerator TakeTurnAction() { if (pc.IsDead() || unit.IsDead()) { return(null); } int intel = (int)unit.Get(StatTag.INTELLIGENCE); Result <bool> result = new Result <bool>(); if (HasLeader()) { leaderAI.seenMap[battler.location.x, battler.location.y] += 1; } else { seenMap[battler.location.x, battler.location.y] += 1; } turnsHunting -= 1; // hunt down the hero if we've recently seen them if (battler.CanSeeLocation(battle.map.terrain, pc.location)) { turnsHunting = intel; foreach (SkillData data in unit.unit.innateSkills) { Skill skill = new Skill(data); IEnumerator aiTry = skill.TryAIUse(this); if (aiTry != null) { return(aiTry); } } } if (turnsHunting > 0 || (HasLeader() && leaderAI.turnsHunting > 0)) { List <Vector2Int> path = battle.map.FindPath(battler.GetComponent <MapEvent>(), pc.location, intel); if (path != null && path.Count > 0) { battler.StepOrAttack(battler.GetComponent <MapEvent>().DirectionTo(path[0]), result); return(null); } else { battler.StepOrAttack(battler.GetComponent <MapEvent>().DirectionTo(pc.location), result); return(null); } } // wander randomly EightDir bestDir = EightDirExtensions.RandomDir(); if (HasLeader() && Vector2Int.Distance(unit.location, leader.location) > 2) { bestDir = unit.battler.GetComponent <MapEvent>().DirectionTo(leader.GetComponent <MapEvent>()); } else { if (intel > WanderCutoffInt) { short lowestSeen = short.MaxValue; foreach (EightDir dir in EightDirExtensions.RandomOrder()) { Vector2Int target = battler.location + dir.XY(); if (target.x < 0 || target.x >= battle.map.size.x || target.y < 0 || target.y >= battle.map.size.y) { continue; } int val; if (HasLeader()) { val = leaderAI.seenMap[target.x, target.y]; } else { val = seenMap[target.x, target.y]; } if (val < lowestSeen && battler.GetComponent <MapEvent>().CanPassAt(target)) { lowestSeen = seenMap[target.x, target.y]; bestDir = dir; } } } } battler.StepOrAttack(bestDir, result); return(null); }