private void CreateText(int damage, Attacked newAttackedObject) { if (m_TextController != null) { m_TextController.CreateTextBehaviour(damage, newAttackedObject.transform, false); } }
public API(string ip, FadeProxyClient proxy, Mode mode = Mode.BOT) { _ip = ip; this.mode = mode; // Depedency injection Account = new Account(this); _proxy = proxy; _remoteClient = new RemoteClient(this); _vanillaClient = new VanillaClient(this, proxy, _remoteClient); Account.LoginSucceed += (s, e) => Connect(); _vanillaClient.AuthFailed += (s, e) => AuthFailed?.Invoke(s, e); _vanillaClient.Disconnected += (s, e) => Disconnected?.Invoke(s, e); _vanillaClient.HeroInited += (s, e) => { HeroInited?.Invoke(s, e); if (LoginTime == DateTime.MinValue) { LoginTime = DateTime.Now; } }; _vanillaClient.Attacked += (s, e) => Attacked?.Invoke(s, e); _vanillaClient.ShipMoving += (s, e) => ShipMoving?.Invoke(s, e); _vanillaClient.Destroyed += (s, e) => Destroyed?.Invoke(s, e); }
public virtual void TakeDamage(float damage) { if (!isAlive || damage <= 0.0f) { return; } if (SupportRange.InSupportRange(gameObject)) { damage *= 0.75f; } HeroUIScript.Damage(damage * (1.0f - dmgDamp * 0.01f), transform.position + Vector3.up * 10.0f); currHP -= damage * (1.0f - dmgDamp * 0.01f); Attacked?.Invoke(); if (currHP <= 0.0f) { currHP = 0.0f; isAlive = false; if (!(this is PortalInfo)) { gameObject.SetActive(false); if (destroyable) { Destroy(gameObject, 1.0f); } } Destroyed?.Invoke(); } }
internal void When(Attacked @event) { From = Countries.ById(@event.Attacker); To = Countries.ById(@event.Defender); From.Army = @event.Result.Attacker; To.Army = @event.Result.Defender; }
public void Atack() { Attacked?.Invoke("Удар!"); if (type == "Petya") { Console.WriteLine("Хммм.... Ошибочка! Вызовите справку!"); return; } if (HP < 0) { Console.WriteLine("Вы пинаете мертвую тушку!"); } else { if (!Agressive) { TurnOn(); } switch (Level) { case 2: Damage = 21; break; case 3: Damage = 8; break; } HP -= Damage; Console.WriteLine($"Урон {Damage}HP"); if (HP == 70 || HP == 28) { Upgrade(); } } }
private void InstantiateFlashAttackEffect(Attacked newAttackedObject) { if (flashAttackVFX != null) { Instantiate(flashAttackVFX, newAttackedObject.transform); } }
private void setCommandEvents() { foreach (var command in Commands.Where(c => c is INavigationCommand)) { command.Action = () => { Navigated?.Invoke(this, new NavigationEventArgs(this, (command as NavigationCommand).Direction)); }; } foreach (var command in Commands.Where(c => c is IGameCommand)) { command.Action = () => { GameMenuSelected?.Invoke(this, new GameEventArgs(this, command.Keys)); }; } foreach (var command in Commands.Where(c => c is IAttackCommand)) { command.Action = () => { Attacked?.Invoke(this, new AttackEventArgs(this)); }; } }
public void OnAttacked(Ent WhoKilledMe) { Attacked?.Invoke(this, new EntEvent(box)); if (Hp <= 0) { Die(WhoKilledMe); } }
public virtual void AttackPosition(Point position, Direction attackDirection = Direction.None) { if (Attack != null) { var positionsToAttack = Attack.GetPositions(position, attackDirection == Direction.None ? Direction : attackDirection); Attacked?.Invoke(this, new AttackEventArgs(positionsToAttack, Attack)); } }
void Start() { Attacked attacked = this.gameObject.AddComponent <Attacked>(); attacked.healthBar = this.gameObject.GetComponentInChildren <HealthBar>(); animator = this.gameObject.GetComponent <Animator>(); walk = this.gameObject.AddComponent <Walk>(); }
public void Attack(Character other) { var damage = calculateDamage(other); Attacked?.Invoke(this, new AttackEventArgs { Damages = damage }); other.Receive(damage); }
protected void Attack(Actor defender, uint strenght) { if (defender is null) { throw new ArgumentNullException(nameof(defender)); } var ea = new AttackedEventArgs(this, defender, strenght); Attacked?.Invoke(this, ea); defender.ReceiveDamage(strenght, this); }
private void OnOpen() { collection.Set(MessageCodes.EnteredScene, SceneEntered.ToMessageHandler()); collection.Set(MessageCodes.ChangeScene, SceneChanged.ToMessageHandler()); collection.Set(MessageCodes.GameObjectAdded, GameObjectsAdded.ToMessageHandler()); collection.Set(MessageCodes.GameObjectRemoved, GameObjectsRemoved.ToMessageHandler()); collection.Set(MessageCodes.PositionChanged, PositionChanged.ToMessageHandler()); collection.Set(MessageCodes.AnimationStateChanged, AnimationStateChanged.ToMessageHandler()); collection.Set(MessageCodes.Attacked, Attacked.ToMessageHandler()); collection.Set(MessageCodes.BubbleNotification, BubbleMessageReceived.ToMessageHandler()); Connected?.Invoke(); }
public void Attack(Hero hero) { if (Weapon.Durability >= 100) { return; } hero.Defence(Weapon.Damage); Weapon.Using(); Attacked?.Invoke(this, new AttackedEventArgs() { Hero = hero, Damage = CountDammage(hero, Weapon.Damage) }); }
public override Node SetUp_Tree() { Node idling = new Idling(); Node running = new Running(); Node crouching = new Crouching(); Node jumping = new Jumping(); Node falling = new Falling(); Node nonAttacked = Node_Selector.Create(crouching, running, idling, jumping, falling); Node attacked = new Attacked(); return(Node_Selector.Create(attacked, nonAttacked)); }
public void Fight() { ApplyModifiers(); BattleUnitsStack attacker = Subject; BattleUnitsStack target = Object; attacker.AttackStack(target); Attacked?.Invoke(); if (target.canRetaliate) { target.AttackStack(attacker); } target.canRetaliate = false; Revenged?.Invoke(); }
public void Attack(Hero hero) { if (Weapon.Durability < 100) { int damage = hero.TakeDamege(Weapon.Damage); Weapon.Using(); Attacked?.Invoke(this, new AttakedEventArgs() { Hero = hero, AttakedHp = damage }); } else { Console.WriteLine("Оружие сломалось"); } }
public void Attack(float multiplier, bool isPerfect) { var target = Cameraer.Instance.GetTargetPosition(); transform.LookAt(new Vector3(target.x, transform.position.y, target.z)); var args = new AttackArgs() { Position = transform.position, Rotation = transform.rotation, Multiplier = multiplier, IsPerfect = isPerfect }; Attacks.Execute(AttackType, args, false); Attacked?.Invoke(this, new AttackedArgs(AttackType, args)); }
public void Attack(Vector2 attackDirection, int damage) { HitBoxArea(attackDirection); int amountOfCollision = Physics2D.OverlapArea(pointA, pointB, attackFilter, attackColliders); for (int i = 0; i < amountOfCollision; i++) { Attacked newAttackedObject = attackColliders [i].gameObject.GetComponent <Attacked>(); if (newAttackedObject != null) { newAttackedObject.GetAttack(attackDirection, damage); InstantiateFlashAttackEffect(newAttackedObject); CreateText(damage, newAttackedObject); } } }
public void Update(TimeSpan deltaTime) { var playerDistance = Vector2.Distance(mGame.Player.Position, Position); if (playerDistance > DetectionRange) { if (mTurnCooldown.Elapsed.TotalSeconds > 5) { var angle = UnityEngine.Random.Range(0, Mathf.PI * 2); Direction = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)); mTurnCooldown = Stopwatch.StartNew(); } } else { if (playerDistance > AttackRange.Value) { Direction = mGame.Player.Position - Position; Direction.Normalize(); } else { Direction = Vector2.zero; if (mAttackCooldown.Elapsed.TotalSeconds >= 1 / AttackRate.Value) { mGame.Attack(this, mGame.Player); mAttackCooldown = Stopwatch.StartNew(); Attacked?.Invoke(this, EventArgs.Empty); } } } var dir = Direction; if (dir != Vector2.zero) { dir.Normalize(); var newPos = Position + dir * Speed.Value * (float)deltaTime.TotalSeconds; var collided = mGame.CheckMonsterCollision(new Rect(newPos, Size), this); collided = MathUtils.Collide(collided, mGame.Player.Bounds); collided = mGame.Map.CheckCollision(collided); Position = new Vector2(collided.xMin, collided.yMin); } }
void Start() { this.gameObject.AddComponent <DestructOfBuilding>(); this.gameObject.AddComponent <Build_Building>(); this.gameObject.AddComponent <Attack>(); Attacked attacked = this.gameObject.AddComponent <Attacked>(); attacked.healthBar = this.gameObject.GetComponentInChildren <HealthBar>(); attacked.maxHealth = health; walk = this.gameObject.AddComponent <Walk>(); walk.SetAutomaticWalking(enemySoldier); walk.speed = speed; }
//Computes a location for the AI to attack and returns the results of the attack and the coordinates that were attacked in an array of arrays public Array[] AIAttack() { Array[] AIResults = new Array[2]; Random aiAttack = new Random(); int[] aiCoords = new int[2]; bool[] aiCheck = new bool[2]; while (aiCheck[1] == false) { int aiX = aiAttack.Next(Size); int aiY = aiAttack.Next(Size); aiCoords[0] = aiX; aiCoords[1] = aiY; aiCheck = Human.Attack(aiX, aiY); } HShips = Human.Ships.Count; AIResults[0] = aiCheck; AIResults[1] = aiCoords; if (aiCheck[0] == false) { Attacked.Add(aiCoords); Play("Miss.wav"); } else if (aiCheck[0] == true) { Play("Hit.wav"); } return(AIResults); }
protected virtual void OnAttacked(DrawableMiniBoss drawableMiniBoss, double timeOffset) => Attacked?.Invoke(drawableMiniBoss, timeOffset);
public void OnAttacked(DoneEventArgs Args) { Attacked?.Invoke(this, Args); }
public override void Parse(EndianBinaryReader reader) { ushort length; ushort id; byte[] content; if (!IsConnected() || tcpClient.Available == 0) { return; } var lengthBuffer = reader.ReadBytes(2); lengthBuffer = _proxy.Decrypt(lengthBuffer); if (BitConverter.IsLittleEndian) { Array.Reverse(lengthBuffer); } length = BitConverter.ToUInt16(lengthBuffer, 0); if (!IsConnected()) { return; } content = _proxy.Decrypt(reader.ReadBytes(length)); EndianBinaryReader cachedReader = new EndianBinaryReader(EndianBitConverter.Big, new MemoryStream(content)); id = cachedReader.ReadUInt16(); Console.WriteLine($"Received: {id}"); switch (id) { case ServerVersionCheck.ID: ServerVersionCheck serverVersionCheck = new ServerVersionCheck(cachedReader); if (serverVersionCheck.compatible) { Compatible?.Invoke(this, EventArgs.Empty); Send(new ClientRequestCode()); } else { NotCompatible?.Invoke(this, EventArgs.Empty); thread.Abort(); } break; case ServerRequestCode.ID: ServerRequestCode serverRequestCode = new ServerRequestCode(cachedReader); Generator generator = new Generator(); generator.Build(serverRequestCode.code); _proxy.InitStageOne(generator.Output); break; case ServerRequestCallback.ID: Console.WriteLine("Stage two received"); ServerRequestCallback serverRequestCallback = new ServerRequestCallback(cachedReader); _proxy.InitStageTwo(serverRequestCallback.secretKey); Console.WriteLine("StageTwo initialized"); Console.WriteLine("Sending login request"); SendEncoded(new Ping()); SendEncoded(new Login(api.Account.UserID, api.Account.SID, 0, api.Account.InstanceID)); SendEncoded(new Ready()); break; case BuildingInit.ID: BuildingInit buildingInit = new BuildingInit(cachedReader); lock (api.buildingsLocker) api.Buildings.Add(new Building(buildingInit.BuildingID, buildingInit.Name, buildingInit.X, buildingInit.Y, buildingInit.AssetType)); break; case DestroyBuilding.ID: DestroyBuilding destroyBuilding = new DestroyBuilding(cachedReader); lock (api.buildingsLocker) api.Buildings.RemoveAll(building => building.BuildingID == destroyBuilding.BuildingID); break; case GateInit.ID: GateInit gateInit = new GateInit(cachedReader); api.Gates.Add(new Gate(gateInit.GateType, gateInit.X, gateInit.Y)); break; case ShipDestroyed.ID: ShipDestroyed shipDestroyed = new ShipDestroyed(cachedReader); if (shipDestroyed.UserID == api.Account.UserID) { Destroyed?.Invoke(this, EventArgs.Empty); } break; case Notify.ID: Notify notify = new Notify(cachedReader); if (notify.MessageType == "ttip_killscreen_basic_repair") { Destroyed?.Invoke(this, EventArgs.Empty); } break; case MapChanged.ID: MapChanged mapChanged = new MapChanged(cachedReader); Console.WriteLine($"Map changed to: {mapChanged.MapID} | {mapChanged.var_294}"); SendEncoded(new MapChangeConfirmation(true)); break; case HeroInit.ID: HeroInit heroInit = new HeroInit(cachedReader); api.Boxes.Clear(); api.MemorizedBoxes.Clear(); api.Ores.Clear(); api.Ships.Clear(); api.Gates.Clear(); api.Buildings.Clear(); // Movement api.Account.X = heroInit.X; api.Account.Y = heroInit.Y; // Map statistics api.Account.HP = (int)heroInit.HP; api.Account.MaxHP = (int)heroInit.MaxHP; api.Account.Shield = (int)heroInit.Shield; api.Account.MaxShield = (int)heroInit.MaxShield; api.Account.NanoHP = (int)heroInit.NanoHP; api.Account.MaxNanoHP = (int)heroInit.MaxNanoHP; api.Account.FreeCargoSpace = (int)heroInit.FreeCargoSpace; api.Account.CargoCapacity = (int)heroInit.CargoCapacity; // Ship api.Account.Shipname = heroInit.Shipname; api.Account.Speed = (int)(heroInit.Speed * 0.97); // Statistics api.Account.Cloaked = heroInit.Cloaked; api.Account.Jackpot = heroInit.Jackpot; api.Account.Premium = heroInit.Premium; api.Account.Credits = heroInit.Credits; api.Account.Honor = heroInit.Honor; api.Account.Uridium = heroInit.Uridium; api.Account.XP = heroInit.XP; api.Account.Level = (int)heroInit.Level; api.Account.Rank = (int)heroInit.Rank; // Social api.Account.ClanID = (int)heroInit.ClanID; api.Account.ClanTag = heroInit.ClanTag; api.Account.FactionID = heroInit.FactionID; HeroInited?.Invoke(this, EventArgs.Empty); api.Account.Ready = true; Task.Delay(15000).ContinueWith(_ => api.Account.JumpAllowed = true); SendEncoded(new InitPacket(1)); SendEncoded(new InitPacket(2)); break; case 24328: //CpuInitializationCommand SendEncoded(new OldStylePacket("JCPU|GET")); break; case DroneFormationUpdated.ID: DroneFormationUpdated droneFormationUpdated = new DroneFormationUpdated(cachedReader); break; case ShipUpdated.ID: ShipUpdated shipUpdated = new ShipUpdated(cachedReader); api.Account.UpdateHitpointsAndShield(shipUpdated.HP, shipUpdated.Shield, shipUpdated.NanoHP); break; case ShieldUpdated.ID: ShieldUpdated shieldUpdated = new ShieldUpdated(cachedReader); api.Account.UpdateShield(shieldUpdated.Shield, shieldUpdated.MaxShield); break; case CargoUpdated.ID: CargoUpdated cargoUpdated = new CargoUpdated(cachedReader); api.Account.FreeCargoSpace = api.Account.CargoCapacity - (int)cargoUpdated.CargoCount; break; case HitpointsUpdated.ID: HitpointsUpdated hitpointsUpdated = new HitpointsUpdated(cachedReader); api.Account.UpdateHitpoints(hitpointsUpdated.HP, hitpointsUpdated.MaxHP, hitpointsUpdated.NanoHP, hitpointsUpdated.MaxNanoHP); break; case ShipAttacked.ID: ShipAttacked shipAttacked = new ShipAttacked(cachedReader); Attacked?.Invoke(this, shipAttacked); break; case ShipInit.ID: ShipInit shipInit = new ShipInit(cachedReader); Ship newShip = new Ship(); newShip.UserID = (int)shipInit.UserID; newShip.Username = shipInit.Username; newShip.NPC = shipInit.NPC; // Movement newShip.X = shipInit.X; newShip.Y = shipInit.Y; // Ship newShip.Shipname = shipInit.Shipname; // Statistics newShip.Cloaked = shipInit.Cloaked; // Social newShip.ClanID = (int)shipInit.ClanID; newShip.ClanTag = shipInit.ClanTag; newShip.FactionID = (int)shipInit.FactionID; lock (api.shipsLocker) api.Ships.Add(newShip); break; case ShipMove.ID: ShipMove shipMove = new ShipMove(cachedReader); ShipMoving?.Invoke(this, shipMove); break; case BoxInit.ID: BoxInit boxInit = new BoxInit(cachedReader); if (boxInit.Hash.Length != 5) { Box box = new Box(boxInit.Hash, boxInit.X, boxInit.Y, boxInit.Type); lock (api.boxesLocker) lock (api.memorizedBoxesLocker) { api.Boxes.Add(box); api.MemorizedBoxes.Add(box); } } break; case DestroyItem.ID: DestroyItem item = new DestroyItem(cachedReader); lock (api.boxesLocker) lock (api.memorizedBoxesLocker) { api.Boxes.RemoveAll(box => box.Hash == item.Hash); if (item.CollectedByPlayer) { api.MemorizedBoxes.RemoveAll(box => box.Hash == item.Hash); } } lock (api.oresLocker) api.Ores.RemoveAll(ore => ore.Hash == item.Hash); break; case DestroyShip.ID: DestroyShip destroyedShip = new DestroyShip(cachedReader); lock (api.Ships) api.Ships.RemoveAll(ship => ship.UserID == destroyedShip.UserID); break; case OreInit.ID: OreInit oreInit = new OreInit(cachedReader); lock (api.oresLocker) api.Ores.Add(new Ore(oreInit.Hash, oreInit.X, oreInit.Y, oreInit.Type)); break; case 17162: if (!pingThread.IsAlive) { pingThread = new Thread(new ThreadStart(PingLoop)); pingThread.Start(); } break; case OldStylePacket.ID: OldStylePacket oldStylePacket = new OldStylePacket(cachedReader); string[] splittedMessage = oldStylePacket.Message.Split('|'); switch (splittedMessage[1]) { case OldPackets.SELECT: switch (splittedMessage[2]) { case OldPackets.CONFIG: api.Account.Config = Convert.ToInt32(splittedMessage[3]); break; } break; case OldPackets.PORTAL_JUMP: Console.WriteLine($"(Old) Map changed to: {splittedMessage[2]}"); SendEncoded(new MapChangeConfirmation(true)); break; case OldPackets.LOG_MESSAGE: switch (splittedMessage[3]) { case OldPackets.BOX_CONTENT_CREDITS: api.Account.CollectedCredits += double.Parse(splittedMessage[4]); break; case OldPackets.BOX_CONTENT_URIDIUM: api.Account.CollectedUridium += double.Parse(splittedMessage[4]); break; case OldPackets.BOX_CONTENT_EE: api.Account.CollectedEE += int.Parse(splittedMessage[4]); break; case OldPackets.BOX_CONTENT_XP: api.Account.CollectedXP += double.Parse(splittedMessage[4]); break; case OldPackets.BOX_CONTENT_HON: api.Account.CollectedHonor += double.Parse(splittedMessage[4]); break; } LogMessage?.Invoke(this, string.Join("|", splittedMessage)); break; default: Console.WriteLine("Received unsupported old style packet with message: {0}", oldStylePacket.Message); break; } break; default: Console.WriteLine("Received packet of ID {0} with total size of {1} which is not supported", id, length + 4); break; } }
public void OnAttack() { Console.WriteLine($"King {Name} is under attack!"); Attacked?.Invoke(); }
protected void OnAttacked(AttackerableEventArgs e) => Attacked?.Invoke(this, e);
public void Attack(ICreature enemy) { enemy.AcceptDamage(Damage); Attacked?.Invoke(this); }
protected virtual void OnAttacked() { Attacked?.Invoke(); }
/// <summary> /// return true to block packet /// </summary> bool UseEntityFromClient(UseEntity ue) { //Attack others if (ue.Type == UseEntity.Types.Attack) { //Admin instant kill using bedrock if (Player.Admin(Permissions.AnyAdmin) && this.ActiveItem != null && this.ActiveItem.ItemID == BlockID.Bedrock) { VanillaSession dust = World.Main.GetPlayer(ue.Target); if (dust == null) { Player.TellSystem(Chat.Purple, "Failed to find player"); return(true); } dust.SendToBackend(new ChatMessageClient("/kill")); Log.WritePlayer(this, "Admin kill: " + dust.Player.MinecraftUsername); return(true); } if (Player.Settings.Cloaked != null) { return(false); } Debug.WriteLine("Attacked: " + ue.Target); VanillaSession target = World.Main.GetPlayer(ue.Target); if (target == null && Player.Settings.Cloaked == null) { Entity e = World.Main.GetEntity(ue.Target); var m = e as Mob; var v = e as Vehicle; WorldRegion cr = CurrentRegion; //prevent killing mobs and villagers inside region if (cr != null && cr.Type == "protected" && (cr.IsResident(Player) == false)) { if (m != null && m.Type >= MobType.Pig) { Player.TellSystem(Chat.Pink, "No killing inside this region"); return(true); } if (v != null && v.Type == Vehicles.Frame) { //Protect frames Debug.WriteLine("Frame protected"); return(true); } } if (m != null && m.Owner != "") { //this could prevent killing of tamed animals } } if (target != null && target.Player.Settings.Cloaked == null) { if (this.ActiveItem != null) { switch (this.ActiveItem.ItemID) { case BlockID.Rose: case BlockID.Dandelion: PlayerInteraction.Prod(this.Player, target.Player); return(true); } } //Anywhere but war WorldRegion r = CurrentRegion; if (r != null && r.Type == "war") { //War Zone //r.Say (Chat.Yellow + Name + Chat.Gold + " attacked " + Chat.Yellow + target.Name + Chat.Gold + " using " + newAttack.Item); SendToBackend(ue); return(true); } //Anywhere but war if (Player.PvP == false) { Player.TellSystem(Chat.Purple, "PvP active"); Player.PvP = true; } Attacked newAttack = new Attacked(this.Player); if (target.Attacker == null || target.Attacker.Timestamp.AddSeconds(10) < DateTime.Now) { //Regular zone if (target.Player.PvP == false && ((r == null) || (r.IsResident(Player) == false))) { if (target.lastPvpMessage < DateTime.Now) { target.lastPvpMessage = DateTime.Now.AddSeconds(5); PlayerInteraction.Prod(target.Player); target.Player.TellSystem(Chat.Pink, Player.Name + " can't hurt you"); } Player.TellSystem(Chat.Pink, "You challenge " + target.Player.Name + " to a fight to the " + Chat.Red + "death"); return(true); } string msg = Player.Name + " attacked " + target.Player.Name + " using " + newAttack.Item; Chatting.Parser.SayFirehose(Chat.Gray, msg); target.TellSystem(Chat.Gray, msg); this.TellSystem(Chat.Gray, msg); Log.WriteAction(target.Player, newAttack, false); } target.Attacker = newAttack; } return(false); } else { //Right click Mob m = World.Main.GetEntity(ue.Target) as Mob; if (m == null) { return(false); } if (m.Owner == "") { return(false); } if (m.Type == MobType.Ocelot) { this.TellSystem(Chat.Pink, "Meow " + m.Owner); } else if (m.Type == MobType.Wolf) { this.TellSystem(Chat.Pink, "Woof " + m.Owner); } else { this.TellSystem(Chat.Pink, "Owner: " + m.Owner); } return(false); } }