public override void Delete(float dt) { if (Parent.Tag == Tags.Server) { var proj = new EnemyMeleeProjectile(AttackDamage, Resources.ParticleMeleeSweepAttack, Util.GetUniqueId()) { Scale = ScaleX, Direction = Direction, Tag = Tags.EnemyProjectile, Position = Position }; (Parent as GameLayer).AddEntity(proj); } RemoveAllChildren(true); Remove(); }
private void SpawnProjectileToTarget() { if (Target != null) { var projectile = new EnemyMeleeProjectile(AttackDamage, Resources.ParticleMeleeSweepAttack, Util.GetUniqueId()) { PositionX = PositionX, PositionY = PositionY, Direction = AngleBetweenPoints(new CCPoint(PositionX, PositionY), new CCPoint(Target.PositionX, Target.PositionY)), OwnerId = Id }; projectile.Position += GetNormalPointByDirection(projectile.Direction)*Texture.PixelsWide*ScaleX; (Parent as GameLayer).AddEntity(projectile); } }
// TODO: сделать в конструкторе /** AccState - если создается игрок, ему передается для связывания... (что плохо :( )*/ public void AddEntity(EntityState es, AccountState accState = null) { Entity entity = null; /* Получаем название объекта по изображению */ string textureName = es.TextureName; textureName = textureName.Replace("\\", "/").Split('/').Last(); /** TODO: можно ли вынести куда-нибудь? можно ли обойтись без этого? скорее всего в Resources, через словарь */ switch (textureName) { case Resources.ClassMystic: case Resources.ClassReaper: case Resources.ClassSniper: entity = new Player(es.Id, textureName, accState); break; case Resources.ItemGold: entity = new GoldStack(es.Id); break; case Resources.ItemGate: entity = new Gate(es.Id); break; case Resources.ItemHealpot: entity = new HealPot(es.Id); break; case Resources.ObjectSmith: entity = new Smith(es.Id); break; case Resources.ProjectileMystic: entity = new MysticProjectile(es.AttackDamage, es.Id); break; case Resources.ProjectileLaser: case Resources.ProjectileCardinalPulse: case Resources.ProjectileCardinalRocket: entity = new EnemyRangeProjectile(es.AttackDamage, textureName, es.Id); break; case Resources.ParticleMeleeSweepAttack: entity = new EnemyMeleeProjectile(es.AttackDamage, textureName, es.Id); break; case Resources.ParticleMeleeSweepStart: entity = new EnemyMeleeProjectileStart(es.AttackDamage, textureName, es.Id); break; case Resources.EnemyMeleeRobot: case Resources.EnemyMagicMelee: case Resources.EnemyPirate: entity = new MeleeEnemy(textureName, es.Id); break; case Resources.EnemyStinger: case Resources.EnemyMagicRange: entity = new RangeEnemy(textureName, es.Id); break; case Resources.BossEmperor: entity = new Emperor(es.Id); break; case Resources.BossCardinal: entity = new Cardinal(es.Id); break; case Resources.BossInteritus: entity = new Interitus(es.Id); break; case Resources.BossMossorus: entity = new Mossorus(es.Id); break; } if (entity != null) { EntityState.AppendStateToEntity(entity, es); AddEntity(entity); } else { Log.Print("Error! Entity isn't created, New entity will not be added. " + textureName, LogType.Error); } }