Esempio n. 1
0
 private void SpawnProjectileToTarget() {
     if (Target != null) {
         var projectile = new EnemyMeleeProjectileStart(AttackDamage, Resources.ParticleMeleeSweepStart,
             Util.GetUniqueId()) {
                 PositionX = PositionX,
                 PositionY = PositionY,
                 Direction =
                     AngleBetweenPoints(new CCPoint(PositionX, PositionY),
                         new CCPoint(Target.PositionX, Target.PositionY)),
                 OwnerId = Id,
                 Scale = 8
             };
         projectile.Position += GetNormalPointByDirection(projectile.Direction)*Texture.PixelsWide/2*ScaleX;
         (Parent as GameLayer).AddEntity(projectile);
     }
 }
Esempio n. 2
0
        // 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);
            }
        }