示例#1
0
        public static List<IEntity> CreateBuilding(Vector2 position)
        {
            List<IEntity> retList = new List<IEntity>();
            Vector2 xOffs = new Vector2(8.0f, 0.0f);
            Vector2 yOffs = new Vector2(0.0f, -8.0f);
            var chunk = new BuildingChunk();
            chunk.Place(position);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position + xOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position - xOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position + 2 * xOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position - 2 * xOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position + 3 * xOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position - 3 * xOffs);
            retList.Add(chunk);

            chunk = new BuildingChunk();
            chunk.Place(position + 3 * xOffs - yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position - 3 * xOffs - yOffs);
            retList.Add(chunk);

            chunk = new BuildingChunk();
            chunk.Place(position + yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position + xOffs + yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position - xOffs + yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position + 2 * xOffs + yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position - 2 * xOffs + yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position + 3 * xOffs + yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position - 3 * xOffs + yOffs);
            retList.Add(chunk);

            chunk = new BuildingChunk();
            chunk.Place(position + 2 * yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position + xOffs + 2 * yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position - xOffs + 2 * yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position + 2 * xOffs + 2 * yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position - 2 * xOffs + 2 * yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position + 3 * xOffs + 2 * yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position - 3 * xOffs + 2 * yOffs);
            retList.Add(chunk);

            chunk = new BuildingChunk();
            chunk.Place(position + 3 * yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position + xOffs + 3 * yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position - xOffs + 3 * yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position + 2 * xOffs + 3 * yOffs);
            retList.Add(chunk);
            chunk = new BuildingChunk();
            chunk.Place(position - 2 * xOffs + 3 * yOffs);
            retList.Add(chunk);

            return retList;
        }
示例#2
0
        public void Spawn(GameMessage message)
        {
            int index = message.index;
            int p = BitConverter.ToInt32(message.Message, 16);
            if (entities.Keys.Contains<int>(index))
            {
                if (entities[index].typeID == -1)
                {
                    entities.Remove(index);
                }
                else
                {
                    return;
                }
            }

            if (idCounter <= index)
                idCounter = index + 1;

            switch (p)
            {
                case 0:
                    var ship = new PlayerShip();
                    ship.HandleSpawnMessage(message);
                    AddEntity(index, ship);
                    break;
                case 1:
                    var enemyShip = new EnemyShip();
                    enemyShip.HandleSpawnMessage(message);
                    AddEntity(index, enemyShip);
                    break;
                case 2:
                    var bullet = new Bullet();
                    bullet.HandleSpawnMessage(message);
                    AddEntity(index, bullet);
                    break;
                case 3:
                    var chunk = new BuildingChunk();
                    chunk.HandleSpawnMessage(message);
                    AddEntity(index, chunk);
                    break;
            }
        }