public override void Initialize(List <Targetable> targets) { foreach (Targetable target in targets) { ActiveUnit unit = target as ActiveUnit; EffectActivator appliedEffect = null; foreach (EffectActivator effect in unit.appliedEffects) { if (effect.activeEffect.UID == activeEffect.UID) { appliedEffect = effect; } } if (appliedEffect != null) { appliedEffect.ActivateEffect(); } else { EffectActivator newEffect = Instantiate(activeEffect.effectActivator, target.transform.position, Quaternion.identity, target.transform); unit.appliedEffects.Add(newEffect); StacksEffectActivator effect = newEffect.gameObject.GetComponent <StacksEffectActivator>(); effect.targets = new List <Targetable> { target }; effect.ActivateEffect(); } } }
public void take_action(float action_cost) { current_unit.take_action(action_cost); to_back_queue_unit = current_unit; to_back_time_unit = 0f; panel.SetActive(false); }
/// <summary> /// 点击头像后进入用户个人专页 /// </summary> private void img_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { ActiveUnit a = ((sender as Image).DataContext as ActiveUnit); if (a != null) { Tool.ToUserPage(a.authorID); e.Handled = true; } }
/// <summary> /// 文字显示辅助处理 /// </summary> private void TextBlock_Loaded(object sender, RoutedEventArgs e) { TextBlock txt = sender as TextBlock; ActiveUnit a = txt.DataContext as ActiveUnit; if (a != null) { Tool.ProcessActiveUnit(a, txt); this.list_Activies.UpdateLayout( ); } }
void query_htecs() { if (!action_pending) { ActiveUnit unit = htecs.get_ready_unit(); if (unit != null) { action_pending = true; panel.SetActive(true); current_unit = unit; populate_panel(); highlight_map_tile(current_unit, true); } } }
public override void DoThings() { if (WaypointQueue.Count > 0) { // Do the movement stuff base.DoThings(); Thread.Sleep(100); return; } RefreshActiveUnit(); Me?.Update(); ActiveUnit?.Update(); if (Me == null || ActiveUnit == null) { return; } /*Vector3 posToMoveTo = ActiveUnit.pos; * posToMoveTo = CalculateMovementOffset( * posToMoveTo, * GetFollowAngle( * GetPartymemberCount(), * GetMyPartyPosition()), * AmeisenDataHolder.Settings.followDistance);*/ //AmeisenMovementEngine.MemberCount = GetPartymemberCount(); Vector4 targetPos = AmeisenMovementEngine.GetPosition( new Vector4(ActiveUnit.pos.X, ActiveUnit.pos.Y, ActiveUnit.pos.Z, ActiveUnit.Rotation), AmeisenDataHolder.Settings.followDistance / 10, GetMyPartyPosition()); Vector3 posToMoveTo = new Vector3(targetPos.X, targetPos.Y, targetPos.Z); // When we are far enough away, follow if (WaypointQueue.Count == 0) { if (Utils.GetDistance(Me.pos, ActiveUnit.pos) > AmeisenDataHolder.Settings.followDistance) { if (!WaypointQueue.Contains(posToMoveTo)) { WaypointQueue.Enqueue(posToMoveTo); } } } }
public ActiveUnit get_ready_unit() { if (readies.Count == 0) { in_combat = true; increment_time(); return(null); } else { float key = readies.Keys[0]; ActiveUnit au = readies[key]; //readies.Remove(key); return(au); } }
private void CreateUnitRosterDependencies() { foreach (Unit ActiveUnit in TeamUnits.ListAll) { foreach (KeyValuePair <string, UnitStats.UnitLinkTypes> UnitLink in ActiveUnit.UnitStat.DicUnitLink) { foreach (Unit ActiveLinkUnit in TeamUnits.ListAll) { if (ActiveLinkUnit.TeamEventID == UnitLink.Key) { ActiveUnit.ShareStats(ActiveLinkUnit, UnitLink.Value); break; } } } } }
private void OnTurnStart() { ActiveUnit.Activate(); ActiveUnitStartCoordinates = ActiveUnit.GetCoordinates(); SetInputMode(InputMode.Movement); if (ActiveUnit.HasAI) { ActiveUnit.AttachedAI.FindTarget(); StartCoroutine(ActiveUnit.AttachedAI.CommitActions()); } else { UpdateSkillBar(); } }
/* * 动弹的唯一图像加载 * 因为动弹很多都不带图像,如果没有图像 则删除此Image控件以节约性能 */ private void imgTweet_Loaded(object sender, RoutedEventArgs e) { Image img = sender as Image; ActiveUnit a = img.DataContext as ActiveUnit; if (a != null && a.tweetImage.IsNotNullOrWhitespace()) { } else { Panel panel = img.Parent as Panel; if (panel != null) { panel.Children.Remove(img); } } }
public override void ExecuteTrigger(int Index) { if (!IsActive && !IsEnded) { foreach (Unit ActiveUnit in Map.PlayerRoster.TeamUnits.GetAll()) { if (ActiveUnit.TeamEventID == _EventID) { UnitSpawner.LeaderToSpawn = new ScriptUnit(Map); UnitSpawner.LeaderToSpawn.OverrideUnit(ActiveUnit); ActiveUnit.ReloadSkills(Map.DicUnitType[ActiveUnit.UnitTypeName], Map.DicRequirement, Map.DicEffect, Map.DicAutomaticSkillTarget, Map.DicManualSkillTarget); break; } } IsActive = true; } }
// Highlights all units according to their allegiance to the currently active unit private void SetUnitHighlight() { List <Unit> units = Grid.ActiveGrid.GetAllUnits(); foreach (var unit in units) { if (unit == ActiveUnit && CurrentPhase == GamePhase.Combat) { continue; } Grid.ActiveGrid.HighlightTile(unit.GetCoordinates(), unit.enemy ? GridTile.TileHighlights.Foe : GridTile.TileHighlights.Friend); } if (CurrentPhase == GamePhase.Combat) { Grid.ActiveGrid.HighlightTile(ActiveUnit.GetCoordinates(), GridTile.TileHighlights.ActiveUnit); } }
public void ApplyEffect(Targetable target) { Dictionary <Modifier, ParameterModiferValue> effectParameters = GetEffectValue(activeEffect, target); foreach (KeyValuePair <Modifier, ParameterModiferValue> parameter in effectParameters) { if (parameter.Key == Modifier.Damage) { target.TakeDamage(parameter.Value.value, target.transform.position, LevelManager.instance.playerAlignment.GetInterface()); } else { ActiveUnit activeUnit = target as ActiveUnit; ParameterModifier param = new ParameterModifier(parameter.Value.value, parameter.Value.modType); activeUnit.parameters.UpdateParameter(parameter.Key, param, this.gameObject); } } }
public override void Initialize(List<Targetable> targets) { foreach (Targetable target in targets) { ActiveUnit unit = target as ActiveUnit; EffectActivator appliedEffect = null; foreach (EffectActivator effect in unit.appliedEffects) { if (effect.activeEffect.UID == activeEffect.UID) { appliedEffect = effect; } } if (appliedEffect != null) { // Do the check if effect got reapplied, do different things !!! if (onEffectDuplication == OnEffectDuplication.IncreaseDuration) { DurationalEffectActivator durationalEffectActivator = appliedEffect as DurationalEffectActivator; durationalEffectActivator.IncreaseDuration(bonusDuration); } if (onEffectDuplication == OnEffectDuplication.IncreaseEffect) { /* foreach (var item in ParameterModiferValue) { durationEffect.values += bonusValue; } */ } } else { EffectActivator newEffect = Instantiate(activeEffect.effectActivator, target.transform.position, Quaternion.identity, target.transform); unit.appliedEffects.Add(newEffect); DurationalEffectActivator durationalEffect = newEffect.gameObject.GetComponent<DurationalEffectActivator>(); durationalEffect.targets = new List<Targetable> { target }; durationalEffect.ActivateEffect(); } } }
void update_to_back_queue_unit() { if (to_back_queue_unit != null) { float nextpos = to_back_queue_unit.compute_marker_position(); float xlerp = Mathf.Lerp(300f, nextpos, to_back_time_unit); Vector3 current_position = to_back_queue_unit.timeline_marker_transform.anchoredPosition3D; to_back_queue_unit.timeline_marker_transform.anchoredPosition3D = new Vector3(xlerp, current_position.y, current_position.z); to_back_time_unit += (Time.deltaTime * 4); if (to_back_time_unit > 1f) { highlight_map_tile(to_back_queue_unit, false); action_pending = false; to_back_queue_unit = null; htecs.clear_first_ready(); to_back_time_unit = 0f; } } }
/// <summary> /// 点击后进入文章详情页 /// </summary> private void list_Activies_SelectionChanged(object sender, SelectionChangedEventArgs e) { ActiveUnit a = this.list_Activies.SelectedItem as ActiveUnit; this.list_Activies.SelectedItem = null; if (a != null) { if (a.url.IsNullOrWhitespace( )) { if (a.catalog <= 0 || a.catalog >= 5) { return; } switch (a.catalog) { case 1: Tool.ToDetailPage(a.objID.ToString( ), DetailType.News); break; case 2: Tool.ToDetailPage(a.objID.ToString( ), DetailType.Post); break; case 3: Tool.ToDetailPage(a.objID.ToString( ), DetailType.Tweet); break; case 4: Tool.ToDetailPage(a.objID.ToString( ), DetailType.Blog); break; } } else { Tool.ProcessAppLink(a.url); } } }
public void DeactivateEffect(Targetable target) { ActiveUnit activeUnit = target as ActiveUnit; activeUnit.parameters.ClearParameters(this.gameObject); }
public HexCell Patrol(HexCell hexCell, int radius) { HexCell target = null; List <HexUnit> units = hexGrid.GetUnitsInRange(hexCell, radius); foreach (HexUnit unit in units) { if (unit.HexUnitType == HexUnit.UnitType.COMBAT) { if (unit.GetComponent <Unit>().CityState&& unit.GetComponent <Unit>().CityState.CityStateID != ActiveUnit.GetComponent <Unit>().CityState.CityStateID) { hexGrid.FindPath(ActiveUnit.HexUnit.Location, unit.Location, ActiveUnit.HexUnit, true, false); target = GetFirstCellFromPath(); if (target) { return(target); } } } } if (hexCell.coordinates.DistanceTo(unit.HexUnit.Location.coordinates) > radius) { hexGrid.FindPath(unit.HexUnit.Location, hexCell, unit.HexUnit); return(GetFirstCellFromPath()); } List <HexDirection> directions = Enum.GetValues(typeof(HexDirection)).Cast <HexDirection>().ToList(); while (directions.Count > 0 && !target) { HexDirection direction = directions[UnityEngine.Random.Range(0, directions.Count)]; directions.Remove(direction); HexCell neighbour = unit.HexUnit.Location.GetNeighbor(direction); if (hexCell.coordinates.DistanceTo(neighbour.coordinates) <= radius && unit.HexUnit.IsValidDestination(neighbour, true)) { target = neighbour; } } return(target); }
public HexCell Defend(City city) { HexCell target = null; List <HexUnit> units = hexGrid.GetUnitsInRange(city.GetHexCell(), 2); foreach (HexUnit unit in units) { if (unit.HexUnitType == HexUnit.UnitType.COMBAT) { if (unit.GetComponent <Unit>().CityState&& unit.GetComponent <Unit>().CityState.CityStateID != ActiveUnit.GetComponent <Unit>().CityState.CityStateID) { hexGrid.FindPath(ActiveUnit.HexUnit.Location, unit.Location, ActiveUnit.HexUnit, true, false); target = GetFirstCellFromPath(); if (target) { return(target); } } } } if (city.GetHexCell().CanUnitMoveToCell(ActiveUnit.HexUnit)) { hexGrid.FindPath(ActiveUnit.HexUnit.Location, city.GetHexCell(), ActiveUnit.HexUnit, true, false); target = GetFirstCellFromPath(); if (target) { return(target); } } foreach (HexCell cell in PathFindingUtilities.GetCellsInRange(city.GetHexCell(), 1)) { if (cell.CanUnitMoveToCell(ActiveUnit.HexUnit)) { hexGrid.FindPath(ActiveUnit.HexUnit.Location, city.GetHexCell(), ActiveUnit.HexUnit, true, false); target = GetFirstCellFromPath(); if (target) { return(target); } } } return(target); }
void highlight_map_tile(ActiveUnit w, bool val) { w.map_marker.GetComponentInParent <TacticalGrid>().highlight(val); }
private void OnTurnEnd() { ActiveUnit.Deactivate(); ResetSkillBar(); }