//加载窗口时 private void SelectByLocation_Load(object sender, EventArgs e) { TargetLayer.Items.Clear(); string layerName; for (int i = 0; i < currentMap.LayerCount; i++) { if (currentMap.get_Layer(i) is IFeatureLayer) { if (currentMap.get_Layer(i) is GroupLayer) { ICompositeLayer pCompositeLayer = currentMap.get_Layer(i) as ICompositeLayer; for (int j = 0; j < pCompositeLayer.Count; j++) { layerName = pCompositeLayer.get_Layer(i).Name; TargetLayer.Items.Add(layerName); TargetLayer.Refresh(); SourceLayerSelect.Items.Add(layerName); } } else { layerName = currentMap.get_Layer(i).Name; TargetLayer.Items.Add(layerName); TargetLayer.Refresh(); SourceLayerSelect.Items.Add(layerName); } } } SourceLayerSelect.SelectedIndex = 0; MethodSelect.SelectedIndex = 0; }
//勾选可见图层时 private void VisiableOnly_CheckedChanged(object sender, EventArgs e) { TargetLayer.Items.Clear(); string layerName; //当勾选时 if (VisiableOnly.CheckState == CheckState.Checked) { for (int i = 0; i < currentMap.LayerCount; i++) { if (currentMap.get_Layer(i) is IFeatureLayer && currentMap.get_Layer(i).Visible == true) { if (currentMap.get_Layer(i) is GroupLayer) { ICompositeLayer pCompositeLayer = currentMap.get_Layer(i) as ICompositeLayer; for (int j = 0; j < pCompositeLayer.Count; j++) { layerName = pCompositeLayer.get_Layer(i).Name; TargetLayer.Items.Add(layerName); TargetLayer.Refresh(); } } else { layerName = currentMap.get_Layer(i).Name; TargetLayer.Items.Add(layerName); TargetLayer.Refresh(); } } } } //未勾选时 if (VisiableOnly.CheckState == CheckState.Unchecked) { for (int i = 0; i < currentMap.LayerCount; i++) { if (currentMap.get_Layer(i) is IFeatureLayer) { if (currentMap.get_Layer(i) is GroupLayer) { ICompositeLayer pCompositeLayer = currentMap.get_Layer(i) as ICompositeLayer; for (int j = 0; j < pCompositeLayer.Count; j++) { layerName = pCompositeLayer.get_Layer(i).Name; TargetLayer.Items.Add(layerName); TargetLayer.Refresh(); } } else { layerName = currentMap.get_Layer(i).Name; TargetLayer.Items.Add(layerName); TargetLayer.Refresh(); } } } } SourceLayerSelect.SelectedIndex = 0; }
public Ability(Effect[] e, int level, int cost, int usesPerTurn, bool canTarget, LayerMask targetMask, TargetLayer TLayer = TargetLayer.none) { this.effects = e; this.levelRequired = level; this.cost = cost; this.numberOfUsesPerTurn = usesPerTurn; this.targetable = canTarget; this.targetableMask = targetMask; this.targetLayer = TLayer; }
/// <summary> /// Returns all the valid targets base on the layer that is targeted. /// the fieldPosition value of unit.info is used to determine this. /// The positions on the field are has follow from left to right. (When a unit dies all units will have their fieldPosition recalculated.) /// 1 - 2 - 3 - 4 /// </summary> /// <param name="targetedLayer"></param> /// <returns></returns> public ITargetable[] GetValidTargets(TargetLayer targetedLayer) { List <ITargetable> targets = new List <ITargetable>(); switch (targetedLayer) { case TargetLayer.none: Debug.Log("No Targets. Ability must be invalid."); break; case TargetLayer.player_selected: break; case TargetLayer.self: targets.Add(this); break; case TargetLayer.all: foreach (ITargetable t in BattleManager.instance.P1_Units) { targets.Add(t); } foreach (ITargetable t in BattleManager.instance.P2_Units) { targets.Add(t); } break; case TargetLayer.all_ennemies: if (info.owningPlayer == 1) { foreach (ITargetable t in BattleManager.instance.P2_Units) { targets.Add(t); } } else if (info.owningPlayer == 2) { foreach (ITargetable t in BattleManager.instance.P1_Units) { targets.Add(t); } } break; case TargetLayer.all_allies: if (info.owningPlayer == 1) { foreach (ITargetable t in BattleManager.instance.P1_Units) { targets.Add(t); } } else if (info.owningPlayer == 2) { foreach (ITargetable t in BattleManager.instance.P2_Units) { targets.Add(t); } } break; case TargetLayer.adjacent: if (info.owningPlayer == 1) { int numberofUnits = BattleManager.instance.P1_Units.Count; switch (numberofUnits) { case 1: Debug.LogError("Error trying to target adjancent but not allies are around."); break; case 2: //Only need to add the other unit. foreach (Unit t in BattleManager.instance.P1_Units) { if (t != this) { targets.Add(t); } } break; case 3: case 4: foreach (Unit t in BattleManager.instance.P1_Units) { if (t != this) { //If the unit is no further than 1 in field position. Add(). if (Mathf.Abs(t.info.fieldPosition - this.info.fieldPosition) == 1) { targets.Add(t); } } } break; } } else if (info.owningPlayer == 2) { int numberofUnits = BattleManager.instance.P2_Units.Count; switch (numberofUnits) { case 1: Debug.LogError("Error trying to target adjancent but not allies are around."); break; case 2: //Only need to add the other unit. foreach (Unit t in BattleManager.instance.P2_Units) { if (t != this) { targets.Add(t); } } break; case 3: case 4: foreach (Unit t in BattleManager.instance.P2_Units) { if (t != this) { //If the unit is no further than 1 in field position. Add(). if (Mathf.Abs(t.info.fieldPosition - this.info.fieldPosition) == 1) { targets.Add(t); } } } break; } } break; case TargetLayer.first_left: if (info.owningPlayer == 1) { foreach (Unit t in BattleManager.instance.P1_Units) { if (t.info.fieldPosition - this.info.fieldPosition == 1) { targets.Add(t); break; } } } else if (info.owningPlayer == 2) { foreach (Unit t in BattleManager.instance.P2_Units) { if (t.info.fieldPosition - this.info.fieldPosition == 1) { targets.Add(t); break; } } } break; case TargetLayer.first_right: if (info.owningPlayer == 1) { foreach (Unit t in BattleManager.instance.P1_Units) { if (t.info.fieldPosition - this.info.fieldPosition == -1) { targets.Add(t); break; } } } else if (info.owningPlayer == 2) { foreach (Unit t in BattleManager.instance.P2_Units) { if (t.info.fieldPosition - this.info.fieldPosition == -1) { targets.Add(t); break; } } } break; case TargetLayer.all_left: if (info.owningPlayer == 1) { foreach (Unit t in BattleManager.instance.P1_Units) { if (t.info.fieldPosition - this.info.fieldPosition <= -1) { targets.Add(t); } } } else if (info.owningPlayer == 2) { foreach (Unit t in BattleManager.instance.P2_Units) { if (t.info.fieldPosition - this.info.fieldPosition <= -1) { targets.Add(t); } } } break; case TargetLayer.all_right: if (info.owningPlayer == 1) { foreach (Unit t in BattleManager.instance.P1_Units) { if (t.info.fieldPosition - this.info.fieldPosition >= 1) { targets.Add(t); } } } else if (info.owningPlayer == 2) { foreach (Unit t in BattleManager.instance.P2_Units) { if (t.info.fieldPosition - this.info.fieldPosition >= 1) { targets.Add(t); } } } break; case TargetLayer.front: //Not sure this will be used break; default: break; } return(targets.ToArray()); }