コード例 #1
0
        private void SpawnBoss() {
            Entity boss = null;
            switch (_gameLayer.Location) {
                case Locations.Desert:
                    boss = new Emperor(Util.GetUniqueId());
                    break;
                case Locations.City:
                    boss = new Cardinal(Util.GetUniqueId());
                    break;
                case Locations.Cave:
                    boss = new Mossorus(Util.GetUniqueId());
                    var boss2 = new Interitus(Util.GetUniqueId()) {
                        Position = new CCPoint(_gameLayer.MapSize().Width, _gameLayer.MapSize().Height),
                    };
                    _gameLayer.AddEntity(boss2);
                    break;
                default:
                    Log.Print("DO nothing at SpawnBoss");
                    break;
            }

            if (boss != null) {
                boss.Position = new CCPoint(_gameLayer.MapSize().Width, _gameLayer.MapSize().Height);
                _gameLayer.AddEntity(boss);
                _boss = boss;
            }
        }
コード例 #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);
            }
        }