/// <summary> /// Gets the unit detector currently active in the scene. /// </summary> /// <returns>Returns the UnitDetector object from the current scene.</returns> public static UnitDetector GetActiveUnitDetector() { GameObject controllerHub = GameObject.Find("Controller Hub"); UnitDetector unitDetector = controllerHub.GetComponent <UnitDetectorController>().unitDetector; return(unitDetector); }
/// <summary> /// Logic for ending an encounter and resuming overworld gameplay state. /// </summary> void CloseEncounter() { controllerReference.StopAllCoroutines(); encounterActive = false; currentRound = 0; fieldSize = null; UtilityFunctions.GetActiveUnitDetector().RemoveUnitSetup(); //playerController.inputsDisabled = false; //uiController.PushUI(UIScreens.GameScreen, true); UnitDetector unitDetector = UtilityFunctions.GetActiveUnitDetector(); unitDetector.SetAutomaticAIActivity(true); //UnitDetectorController.MapAggroRadiusToUnit(playerController.GetPlayerUnit()); //unitDetectorController.StartCoroutine(unitDetectorController.ReduceAggroRadius()); }
public void LoadGameState() { Debug.Log("gamestate loading"); Instance instance = new Instance(currentInstanceJSONFileName); Unit unit = new Unit(leadUnitJSONFileName, 1, TargetTypes.Ally); Geology geology = UtilityFunctions.GetActiveGeology(); geology.SetYear(year); geology.SetSeason(season); geology.SetDay(day); geology.SetTimeOfDay(time); geology.SetTimeSegment(timeSegment); geology.SetCurrentInstance(instance); UnitDetector unitDetector = UtilityFunctions.GetActiveUnitDetector(); unitDetector.LoadNewInstance(instance, playerPosition, unit); }
/// <summary> /// Sets the unit's animation to the one specified by the skill choreography, and places the hitboxes /// specified. /// </summary> /// <param name="skillChoreography">The skill choreography to run.</param> private void RunSkillChoreography(SkillChoreography skillChoreography) { Debug.Log("skillcho"); int framesGiven = skillChoreography.GetTotalFrames(); if (skillChoreography.GetIsAttackSpeedDependent()) { Debug.Log(framesGiven); Debug.Log(unit.attackSpeed); framesGiven = (int)Math.Round(framesGiven / unit.attackSpeed); } unit.SetAnimation(skillChoreography.GetAnimationPatternIndex(), framesGiven, false); UnitDetector unitDetector = UtilityFunctions.GetActiveUnitDetector(); foreach (List <Hitbox> hitboxGroup in skillChoreography.GetHitboxGroups()) { string hitboxGroupID = "id:" + unit.GetHashCode() + "_" + GetHashCode() + "_" + skillChoreographies.GetHashCode() + "_" + hitboxGroup.GetHashCode() + "_" + UtilityFunctions.UnixTimeNow(); foreach (Hitbox hitbox in hitboxGroup) { hitbox.SetHitboxGroupID(hitboxGroupID); hitbox.SetUnit(unit); hitbox.SetSkill(this); hitbox.AdjustPositionToUnit(); if (skillChoreography.GetIsAttackSpeedDependent()) { hitbox.AdjustToAttackSpeed(unit.attackSpeed); } unitDetector.PlaceHitbox(hitbox); } } }