public void attack(AttackDTO dto) { PlayerCon obj = models[dto.userID]; PlayerCon target = models[dto.targetID]; obj.attack(new Transform[] { target.transform }); }
private void Attack(AttackDTO atk) { PlayerCtr obj = models[atk.UserID]; PlayerCtr target = models[atk.TargetID]; obj.Attack(new Transform[] { target.transform }); }
//private void OnTriggerEnter2D(Collider2D other) private void OnCollisionEnter2D(Collision2D other) { if (exploded == true) { Rigidbody2D otherRigidBody = other.gameObject.GetComponent <Rigidbody2D>(); if (otherRigidBody != null) { Vector2 target = other.gameObject.transform.position; Vector2 explosion = gameObject.transform.position; Vector2 direction = 70f * (target - explosion); // otherRigidBody.AddForce(direction); BaseEntity atkedEntity = other.gameObject.GetComponent <BaseEntity>(); if (atkedEntity) { if (atkedEntity.ID == ownerID) { return; } else { AttackDTO atk = new AttackDTO(); atk.damage = Random.Range(minDamage, maxDamage + 1); atk.type = Enums.Damage.Type.Explosion; atkedEntity.Hit(atk); } } } } }
private void atk(AttackDTO dto) { PlayerCon obj = models[dto.userId]; PlayerCon target = models[dto.target]; obj.GetComponent <PlayerCon>().attack(new Transform[] { target.transform }); }
private void attack(UserToken token, int value) { AttackDTO atk = new AttackDTO(); atk.userId = getUserId(token); atk.targetId = value; brocast(FightProtocol.ATTACK_BRO, atk); }
private void Attack(UserToken token, int value) { AttackDTO atk = new AttackDTO(); atk.UserID = GetUserId(token); atk.TargetID = value; Brocast(FightProtocol.ATTACK_BRO, atk); }
private void attack(UserToken token, int[] target) { AttackDTO atk = new AttackDTO(); atk.id = getUserId(token); atk.target = target; brocast(FightProtocol.ATTACK_BRO, atk); }
void attack(NetFrame.UserToken token, int value) { AttackDTO dto = new AttackDTO(); dto.userID = getUserID(token); dto.targetID = value; brocast(FightProtocol.ATTACK_BRO, dto); }
private void attack(AttackDTO atk) { GameObject attackUnit = FightUnitMgr.Instance.GetGameObjectById(atk.id); if (attackUnit != null) { attackUnit.GetComponent <FightUnit>().attack(atk.target); } }
void Attack(UserToken token, int[] targetsId) { AttackDTO attackDto = new AttackDTO(); int userId = userCache.GetUserId(token); attackDto.userId = userId; attackDto.targetsId = targetsId; Brocast(MapProtocol.Attack_BRO, attackDto); }
private void attack(AttackDTO atk) { GameObject hero = heros[atk.id]; List <GameObject> list = new List <GameObject>(); foreach (int item in atk.target) { list.Add(heros[item]); Debug.Log("xxxx" + item); } hero.GetComponent <PlayerComponent>().con.attack(list.ToArray()); }
void AttackBro(AttackDTO attackDto) { int userId = attackDto.userId; int[] targetsId = attackDto.targetsId; List <Transform> targets = new List <Transform>(); for (int i = 0; i < targetsId.Length; i++) { targets.Add(idToGameObjectDic[targetsId[i]].transform); } idToGameObjectDic[userId].GetComponent <Info>().Attack(targets.ToArray()); }
/// <summary> /// 攻击 /// </summary> /// <param name="attackDTO"></param> private void Attack(AttackDTO attackDTO) { if (instances.ContainsKey(attackDTO.attackerId) && instances.ContainsKey(attackDTO.targetId)) { bool couldAtk = false; //1.验证时间上能否攻击 float atkSpeed = instances[attackDTO.attackerId].atkSpeed; couldAtk = (GetAtkTimeStamp(attackDTO.attackerId) + atkSpeed * 10000000 >= attackDTO.timeStamp); //TODO 2.验证位置是否能够攻击 //3.允许攻击 if (couldAtk) { SetAtkTimeStamp(attackDTO.attackerId, attackDTO.timeStamp); brocast(FightProtocol.ATTACK_BRO, attackDTO); } } }
protected virtual void OnCollisionEnter2D(Collision2D other) { BaseEntity atkedEntity = other.gameObject.GetComponent <BaseEntity>(); if (atkedEntity) { if (atkedEntity.ID == ownerID) { return; } AttackDTO atk = new AttackDTO(); atk.damage = Random.Range(minDamage, maxDamage + 1); atk.type = Enums.Damage.Type.Normal; atkedEntity.Hit(atk); } Destroy(gameObject); }
public void Hit(AttackDTO atk) { //calc the damage reducer by damage type defense etc int finalDamage = atk.damage; if (finalDamage > currentHP) { finalDamage = currentHP; } DisplayFloatingNumber(finalDamage, Enums.FloatingTextType.Damage); currentHP -= finalDamage; LogWithHP("Was hit by", finalDamage); if (currentHP <= 0) { Dead(); } }
public async Task <IEnumerable <SimpleUnitViewModel> > AttackAsync(int attackerUserId, AttackDTO attack) { var game = await db.Game .Include(game => game.Attacks) .SingleAsync(); var unitTypes = await db.UnitTypes.ToListAsync(); var attackingUser = await db.Users .Include(u => u.Country) .ThenInclude(country => country.DefendingArmy) .ThenInclude(defendingArmy => defendingArmy.Units) .ThenInclude(unit => unit.Type) .ThenInclude(type => type.Levels) .Include(u => u.Country) .ThenInclude(country => country.AttackingArmy) .ThenInclude(attackingArmy => attackingArmy.Units) .ThenInclude(unit => unit.Type) .ThenInclude(type => type.Levels) .SingleAsync(u => u.Id == attackerUserId); var defendingCountry = await db.Countries .Include(country => country.User) .SingleAsync(c => c.UserId == attack.DefenderUserId); var defendingUser = defendingCountry.User; var tranferList = new List <Unit>(); await db.SaveChangesAsync(); foreach (var sendUnit in attack.AttackingUnits) { int ownedCount = attackingUser.Country.DefendingArmy.Units .Count(u => u.Type.Id == sendUnit.Id && u.Level == sendUnit.Level); if (sendUnit.SendCount > ownedCount) { throw new HttpResponseException { Status = 400, Value = "Nem küldhetsz több egységet, mint amennyid van!" } } ; else { //Összeszedjük a kívánt egységeket a defending armyból foreach (var oneAttack in attack.AttackingUnits) { foreach (var defender in attackingUser.Country.DefendingArmy.Units) { if (defender.Type.Id == oneAttack.Id //Group by LVL && defender.Level == oneAttack.Level) { oneAttack.SendCount--; tranferList.Add(defender); } if (oneAttack.SendCount <= 0) { break; } } } // levonjuk az egységeket a defending armyból // ÉS hozzáadjuk az attacking armyhoz foreach (var item in tranferList) { attackingUser.Country.DefendingArmy.Units.Remove(item); item.UnitGroupId = attackingUser.Country.AttackingArmyId; attackingUser.Country.AttackingArmy.Units.Add(item); } } } game.Attacks.Add(new Attack { AttackerUserId = attackingUser.Id, AttackerUser = attackingUser, DefenderUserId = defendingUser.Id, DefenderUser = defendingUser, GameId = game.Id, UnitList = tranferList }); await db.SaveChangesAsync(); List <SimpleUnitViewModel> result = new List <SimpleUnitViewModel>(); var found = false; foreach (var unit in tranferList) { found = false; foreach (var unitvm in result) { if (unitvm.TypeId == unit.Type.Id //Group by LVL && unitvm.Level == unit.Level) { unitvm.Count++; found = true; break; } } if (!found) { result.Add(new SimpleUnitViewModel() { Count = 1, Level = unit.Level, TypeId = unit.Type.Id }); } } return(result); }
public Task <IEnumerable <SimpleUnitViewModel> > Attack([FromBody] AttackDTO attack) { int userId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)); return(armyService.AttackAsync(userId, attack)); }
void attack(AttackDTO dto) { FightScene._instance.attack(dto); }