protected virtual void OnUnitEdit(UnitEventArgs e) { if (UnitEdit != null) { UnitEdit(this, e); } }
private void OnUnitAdd(object sender, UnitEventArgs unitEventArgs) { var unit = unitEventArgs.Unit; if (unit.IsIllusion || unit.Team != manager.MyHero.Team || !unit.IsControllable || controllables.Any(x => x.Handle == unit.Handle)) { return; } switch (unit.Name) { case "npc_dota_lone_druid_bear1": case "npc_dota_lone_druid_bear2": case "npc_dota_lone_druid_bear3": case "npc_dota_lone_druid_bear4": { controllables.Add(new SpiritBear(unit)); break; } case "npc_dota_hero_meepo": { controllables.Add(new MeepoClone(unit)); break; } } }
private void UnitEventHappened(object sender, UnitEventArgs e) { switch (e.EventType) { // Unit movement animation event was raised //case UnitEventType.MoveCommand: // { // unitPanel.Invalidate(); // break; // } case UnitEventType.StatusUpdate: { unitPanel.Invalidate(); break; } case UnitEventType.NewUnitActivated: { unitPanel.Invalidate(); break; } default: break; } }
protected virtual void OnUnitDelete(UnitEventArgs e) { if (UnitDelete != null) { UnitDelete(this, e); } }
protected virtual void OnUnitMakeInactive(UnitEventArgs e) { if (UnitMakeInactive != null) { UnitMakeInactive(this, e); } }
private void UnitEventHappened(object sender, UnitEventArgs e) { switch (e.EventType) { // Unit movement animation event was raised case UnitEventType.MoveCommand: { AnimationCount = Game.ActiveUnit.MovementCounter; if (AnimationCount == 0) { StartAnimation(AnimationType.UnitMoving); } //DrawAnimation(); break; } case UnitEventType.StatusUpdate: { StartAnimation(AnimationType.UnitWaiting); break; } case UnitEventType.NewUnitActivated: { ReturnCoordsAtMapViewChange(Game.ActiveXY); StartAnimation(AnimationType.UnitWaiting); break; } } }
private void UnitEventHappened(object sender, UnitEventArgs e) { switch (e.EventType) { //Unit movement animation event was raised case UnitEventType.MoveCommand: { break; } case UnitEventType.StatusUpdate: { UnitPanel.Refresh(); break; } case UnitEventType.NewUnitActivated: { UnitPanel.Refresh(); break; } default: break; } }
private void UnitEventHappened(object sender, UnitEventArgs e) { switch (e.EventType) { case UnitEventType.MoveCommand: this.PlaySound(location + Path.DirectorySeparatorChar + "Sound" + Path.DirectorySeparatorChar + "MOVPIECE.WAV"); break; case UnitEventType.Attack: switch (e.Attacker.Type) { case UnitType.Catapult: this.PlaySound(location + Path.DirectorySeparatorChar + "Sound" + Path.DirectorySeparatorChar + "CATAPULT.WAV"); break; case UnitType.Elephant: this.PlaySound(location + Path.DirectorySeparatorChar + "Sound" + Path.DirectorySeparatorChar + "ELEPHANT.WAV"); break; default: this.PlaySound(location + Path.DirectorySeparatorChar + "Sound" + Path.DirectorySeparatorChar + "SWORDFGT.WAV"); break; } break; } }
private void OnUnitRemove(object sender, UnitEventArgs unitEventArgs) { var controllable = controllables.FirstOrDefault(x => x.Handle == unitEventArgs.Unit.Handle); if (controllable != null) { controllables.Remove(controllable); } }
private void OnUnitAdd(object sender, UnitEventArgs unitEventArgs) { var courier = unitEventArgs.Unit as Courier; if (courier != null && courier.Team == manager.MyHero.Team) { couriers.Add(courier); } }
/// <summary> /// The value_ unit added. /// </summary> /// <param name="args"> /// The args. /// </param> private void Value_UnitAdded(UnitEventArgs args) { foreach (var heroMenu in this.HeroMenus) { heroMenu.Value.ConnectToUnit(args.AbilityUnit); } foreach (var unitMenu in this.UnitMenus) { unitMenu.Value.ConnectToUnit(args.AbilityUnit); } }
private void UnitEventHappened(object sender, UnitEventArgs e) { switch (e.EventType) { // Unit movement animation event was raised case UnitEventType.MoveCommand: { //if (IsActiveUnitOutsideMapView) // Update map view if unit is outside visible map //{ // ReturnCoordsAtMapViewChange(new int[] { Game.ActiveUnit.X, Game.ActiveUnit.Y }); // drawPanel.Update(new Rectangle(0, 0, drawPanel.Width, drawPanel.Height)); //} StartAnimation(AnimationType.UnitMoving); break; } case UnitEventType.Attack: { animationFrames = GetAnimationFrames.UnitAttack(e); StartAnimation(AnimationType.Attack); break; } case UnitEventType.StatusUpdate: { if (IsActiveUnitOutsideMapView) { ReturnCoordsAtMapViewChange(new int[] { Game.GetActiveUnit.X, Game.GetActiveUnit.Y }); // Update map view if unit is outside visible map } else { StartAnimation(AnimationType.Waiting); } break; } case UnitEventType.NewUnitActivated: { if (IsActiveUnitOutsideMapView) { MapViewChange(new int[] { Game.GetActiveUnit.X, Game.GetActiveUnit.Y }); } else { StartAnimation(AnimationType.Waiting); } break; } } }
protected override void Awake() { base.Awake(); PatternGroup = new List <Pattern>(); ReservationActionList = new LinkedList <Action <UnitEventArgs>[]>(); _params = new UnitEventArgs(); _ignoreFocusTime = .0f; ReturnToCasterRadius *= ReturnToCasterRadius; RestrictReturnToCasterRadius *= RestrictReturnToCasterRadius; AttackRange *= AttackRange; AttackInnerRange = AttackRange * InnerAttackRangeRate * InnerAttackRangeRate; _navMeshAgent.speed = MovementSpeed; // set the maximum speed of navMeshAgent _maxFrequency = 0; Delay = 0; }
private void OnUnitAdd(object sender, UnitEventArgs unitEventArgs) { var hero = unitEventArgs.Unit as Hero; if (hero != null && (hero.HeroId == HeroId.npc_dota_hero_techies && hero.Team != manager.MyHero.Team || hero.HeroId == HeroId.npc_dota_hero_rubick && manager.Units.OfType <Hero>() .Any( x => x.IsValid && x.HeroId == HeroId.npc_dota_hero_techies && x.Team == manager.MyHero.Team))) { manager.OnUnitAdd -= OnUnitAdd; UpdateManager.Subscribe(OnUpdate); Player.OnExecuteOrder += OnExecuteOrder; } }
private void OnUnitAdd(object sender, UnitEventArgs unitEventArgs) { var hero = unitEventArgs.Unit as Hero; if (hero != null && (hero.HeroId == HeroId.npc_dota_hero_techies && hero.Team != manager.MyHero.Team || hero.HeroId == HeroId.npc_dota_hero_rubick && EntityManager <Hero> .Entities.Any( x => x.IsValid && x.HeroId == HeroId.npc_dota_hero_techies && x.Team == manager.MyHero.Team))) { manager.OnUnitAdd -= OnUnitAdd; updateHandler = UpdateManager.Subscribe(OnUpdate, menu.UpdateRate, menu.IsEnabled); if (menu.IsEnabled) { Player.OnExecuteOrder += OnExecuteOrder; } } }
private void OnUnitAdd(object sender, UnitEventArgs unitEventArgs) { var unit = unitEventArgs.Unit; if (unit.IsIllusion || !unit.IsControllable || controllables.Any(x => x.Handle == unit.Handle)) { return; } switch (unit.ClassId) { case ClassId.CDOTA_Unit_SpiritBear: { controllables.Add(new SpiritBear(unit)); break; } case ClassId.CDOTA_Unit_Hero_Meepo: { controllables.Add(new MeepoClone(unit)); break; } } }
/// <summary> /// Обработчик события "Смерть персонажа". /// </summary> /// <param name="unit">Вызывающий персонаж.</param> /// <param name="unitEventArgs">Информация о событии.</param> private void OnUnitEliminated(Unit unit, UnitEventArgs unitEventArgs) { print($"Unit {unit.name} has been eliminated."); CurrentUnits.Remove(unit); bool endgame = true; foreach (var u in CurrentUnits) { if (u.Team == unit.Team) { endgame = false; break; } } Destroy(unit.gameObject); _turnManager.RemoveEliminated(unit); if (endgame) { EndGame(); } }
protected static void DefaultReset(UnitEventArgs eventArgs) { var caster = (Champion)eventArgs.Caster; caster.OnCastAnimationCleanUp(); }
private void Unit_UnitAdded(object sender, UnitEventArgs e) { Packet pOut = new Packet((int)PacketHeader.UnitAdded, e.Unit); server.SendDataToAll(pOut); }
private void uc_OnError(object sender, UnitEventArgs e) { lstOutput.Items.Add(e.Message); }
private static void UnitEventHappened(object sender, UnitEventArgs e) { //if (e.EventType == UnitEventType.MoveCommand && e.Counter == 0) MOVPIECE.Play(); }
void OnUndo(object sender, UnitEventArgs <string> e) { ExecutionCount--; e.UnitResult = UnitResult.Completed; }
// Get attack animation frames public static List <Bitmap> UnitAttack(UnitEventArgs e) { List <Bitmap> animationFrames = new List <Bitmap>(); // Which squares are to be drawn List <int[]> coordsOffsetsToBeDrawn = new List <int[]> { new int[] { -2, -4 }, new int[] { 0, -4 }, new int[] { 2, -4 }, new int[] { -3, -3 }, new int[] { -1, -3 }, new int[] { 1, -3 }, new int[] { 3, -3 }, new int[] { -2, -2 }, new int[] { 0, -2 }, new int[] { 2, -2 }, new int[] { -3, -1 }, new int[] { -1, -1 }, new int[] { 1, -1 }, new int[] { 3, -1 }, new int[] { -2, 0 }, new int[] { 0, 0 }, new int[] { 2, 0 }, new int[] { -3, 1 }, new int[] { -1, 1 }, new int[] { 1, 1 }, new int[] { 3, 1 }, new int[] { -2, 2 }, new int[] { 0, 2 }, new int[] { 2, 2 }, new int[] { -3, 3 }, new int[] { -1, 3 }, new int[] { 1, 3 }, new int[] { 3, 3 }, new int[] { -2, 4 }, new int[] { 0, 4 }, new int[] { 2, 4 } }; // First draw main bitmap with everything except the moving unit int[] coordsOffsetsPx; var _mainBitmap = new Bitmap(6 * Map.Xpx, 7 * Map.Ypx, PixelFormat.Format32bppRgba); using (var g = new Graphics(_mainBitmap)) { g.FillRectangle(Brushes.Black, new Rectangle(0, 0, 6 * Map.Xpx, 7 * Map.Ypx)); // Fill bitmap with black (necessary for correct drawing if image is on upper map edge) foreach (int[] coordsOffsets in coordsOffsetsToBeDrawn) { // Change coords of central offset int x = e.Attacker.X + coordsOffsets[0]; int y = e.Attacker.Y + coordsOffsets[1]; coordsOffsetsPx = new int[] { (coordsOffsets[0] + 2) * Map.Xpx, (coordsOffsets[1] + 3) * Map.Ypx }; if (x < 0 || y < 0 || x >= 2 * Map.Xdim || y >= Map.Ydim) { continue; // Make sure you're not drawing tiles outside map bounds } // Tiles int civId = Map.WhichCivsMapShown; if (Map.IsTileVisibleC2(x, y, civId) || Map.MapRevealed) { Draw.Tile(g, x, y, Map.Zoom, new Point(coordsOffsetsPx[0], coordsOffsetsPx[1])); // Implement dithering in all 4 directions if necessary if (!Map.MapRevealed) { for (int tileX = 0; tileX < 2; tileX++) { for (int tileY = 0; tileY < 2; tileY++) { int[] offset = new int[] { -1, 1 }; int xNew = x + offset[tileX]; int yNew = y + offset[tileY]; if (xNew >= 0 && xNew < 2 * Map.Xdim && yNew >= 0 && yNew < Map.Ydim) // Don't observe outside map limits { if (!Map.IsTileVisibleC2(xNew, yNew, civId)) // Surrounding tile is not visible -> dither { Draw.Dither(g, tileX, tileY, Map.Zoom, new Point(coordsOffsetsPx[0] + Map.Xpx * tileX, coordsOffsetsPx[1] + Map.Ypx * tileY)); } } } } } } // Units // If tile is with attacking & defending unit, draw these two first // TODO: this won't draw correctly if unit is in city if (x == e.Attacker.X && y == e.Attacker.Y) { Draw.Unit(g, e.Attacker, e.Attacker.IsInStack, Map.Zoom, new Point(coordsOffsetsPx[0], coordsOffsetsPx[1] - Map.Ypx)); } else if (x == e.Defender.X && y == e.Defender.Y) { Draw.Unit(g, e.Defender, e.Defender.IsInStack, Map.Zoom, new Point(coordsOffsetsPx[0], coordsOffsetsPx[1] - Map.Ypx)); } else // Other units { var units = Game.UnitsHere(x, y); if (units.Count > 0) { var unit = units.Last(); if (!unit.IsInCity) { Draw.Unit(g, unit, unit.IsInStack, Map.Zoom, new Point(coordsOffsetsPx[0], coordsOffsetsPx[1] - Map.Ypx)); } } } // Cities City city = Game.CityHere(x, y); if (city != null) { Draw.City(g, city, true, Map.Zoom, new Point(coordsOffsetsPx[0], coordsOffsetsPx[1] - Map.Ypx)); } } // City names // Add additional coords for drawing city names coordsOffsetsToBeDrawn.Add(new int[] { -3, -5 }); coordsOffsetsToBeDrawn.Add(new int[] { -1, -5 }); coordsOffsetsToBeDrawn.Add(new int[] { 1, -5 }); coordsOffsetsToBeDrawn.Add(new int[] { 3, -5 }); coordsOffsetsToBeDrawn.Add(new int[] { -4, -2 }); coordsOffsetsToBeDrawn.Add(new int[] { 4, -2 }); coordsOffsetsToBeDrawn.Add(new int[] { -4, 0 }); coordsOffsetsToBeDrawn.Add(new int[] { 4, 0 }); coordsOffsetsToBeDrawn.Add(new int[] { -4, 2 }); coordsOffsetsToBeDrawn.Add(new int[] { 4, 2 }); foreach (int[] coordsOffsets in coordsOffsetsToBeDrawn) { // Change coords of central offset int x = e.Attacker.X + coordsOffsets[0]; int y = e.Attacker.Y + coordsOffsets[1]; if (x < 0 || y < 0 || x >= 2 * Map.Xdim || y >= Map.Ydim) { continue; // Make sure you're not drawing tiles outside map bounds } City city = Game.CityHere(x, y); if (city != null) { Draw.CityName(g, city, Map.Zoom, new int[] { coordsOffsets[0] + 2, coordsOffsets[1] + 3 }); } } } // Now draw the battle animation on top of attacking & defending unit // Number of battle rounds / 5 determines number of explosions (must be at least one). Each explosion has 8 frames. Point point; for (int explosion = 0; explosion < e.CombatRoundsAttackerWins.Count / 5; explosion++) { for (int frame = 0; frame < 8; frame++) { // Make a clone of the main bitmap in order to draw frames with unit on it var _bitmapWithExplosions = new Bitmap(_mainBitmap); using (var g = new Graphics(_bitmapWithExplosions)) { // Draw chaning HP of both units foreach (int[] coordsOffsets in coordsOffsetsToBeDrawn) { int x = e.Attacker.X + coordsOffsets[0]; int y = e.Attacker.Y + coordsOffsets[1]; if (x == e.Attacker.X && y == e.Attacker.Y) { Draw.UnitShield(g, e.Attacker.Type, e.Attacker.Owner.Id, e.Attacker.Order, e.Attacker.IsInStack, e.AttackerHitpoints[explosion * 5], e.Attacker.HitpointsBase, Map.Zoom, new Point(2 * Map.Xpx, 2 * Map.Ypx)); Draw.UnitSprite(g, e.Attacker.Type, false, false, Map.Zoom, new Point(2 * Map.Xpx, 2 * Map.Ypx)); } else if (x == e.Defender.X && y == e.Defender.Y) { Draw.UnitShield(g, e.Defender.Type, e.Defender.Owner.Id, e.Defender.Order, e.Defender.IsInStack, e.DefenderHitpoints[explosion * 5], e.Defender.HitpointsBase, Map.Zoom, new Point((2 + coordsOffsets[0]) * Map.Xpx, (2 + coordsOffsets[1]) * Map.Ypx)); Draw.UnitSprite(g, e.Defender.Type, e.Defender.Order == OrderType.Sleep, e.Defender.Order == OrderType.Fortified, Map.Zoom, new Point((2 + coordsOffsets[0]) * Map.Xpx, (2 + coordsOffsets[1]) * Map.Ypx)); } } // Draw explosion on defender if (e.CombatRoundsAttackerWins[explosion]) { point = new Point((int)(Map.Xpx * (2.5 + e.Defender.X - e.Attacker.X)), Map.Ypx * (3 + (e.Defender.Y - e.Attacker.Y))); } // Draw explosion on attacker else { point = new Point((int)(Map.Xpx * 2.5), Map.Ypx * 3); } Draw.BattleAnim(g, frame, Map.Zoom, point); } animationFrames.Add(_bitmapWithExplosions); } } return(animationFrames); }
void OnExecute(object sender, UnitEventArgs <string> e) { ExecutionCount++; LastArgument = e.Argument; }
/// <summary> /// Handler for the UnitRemovedEvent. Used to maintain _refrenceCount. /// </summary> /// <param name="sender">Objected that triggered event.</param> /// <param name="args">Arguments for the event.</param> public void UnitRemovedEventHandler(object sender, UnitEventArgs args) { String name = GameObjectFactory.The.getType(args.UnitBuilt.ID).Name; decrementRefCount(name); }
private void Client_SelectedUnitChnaged(object sender, UnitEventArgs e) { // show the form when the user selects a unit Show(); }