예제 #1
0
 // Constructors
 public BlockSprite(SpriteInfo spriteInfo, BlockSpriteState state, SpriteDestroyedHandler handlers)
     : base(spriteInfo)
 {
     this.position = new Vector2(state.mapPoint.X * Map.CellSize, state.mapPoint.Y * Map.CellSize);
     this.type = state.type;
     this.maxHealth = state.maxHealth;
     this.Health = state.health;
     layer = Map.Layer1 - 0.0001f * state.mapPoint.Y + 0.01f;
     if (type != BlockSpriteType.Invisible)
         blockAmmo = true;
     hasBeenDestroyed = handlers;
 }
예제 #2
0
파일: Map.cs 프로젝트: sinhpham/tanka
        void ConstructOngroundMap(List<string> ongroundMap, bool newMap)
        {
            BlockSpriteType bt = BlockSpriteType.Wall;
            for (int i = 0; i < ongroundMap.Count; ++i)
            {
                for (int j = 0; j < ongroundMap[i].Length; ++j)
                {
                    if (newMap)
                        reachablePoints.Add(new Point(j, i));
                    if (ongroundMap[i][j] != '0')
                    {
                        bt = charToBlockSpriteType[ongroundMap[i][j]];
                        BlockSpriteState state = new BlockSpriteState()
                        {
                            type = bt,
                            health = null,
                            maxHealth = null,
                            mapPoint = new Point(j, i)
                        };
                        Factory.CreateBlockSprite(state);
                        if (newMap && (ongroundMap[i][j] == 'x' || ongroundMap[i][j] == 'y'))
                        {
                            reachablePoints.RemoveAt(reachablePoints.Count - 1);
                        }
                    }
                }

            }
        }
예제 #3
0
파일: Factory.cs 프로젝트: sinhpham/tanka
        public static void CreateBlockSprite(BlockSpriteState state)
        {
            SpriteInfo si = blockSpriteSI[state.type];

            state.maxHealth = null;
            switch (state.type)
            {
                case BlockSpriteType.Wall:
                    state.maxHealth = 100;
                    break;
                case BlockSpriteType.FireWall:
                    state.maxHealth = 200;
                    break;
            }

            if (state.health == null)
            {
                // Default health.
                switch (state.type)
                {
                    case BlockSpriteType.Wall:
                        state.health = 100;
                        break;
                    case BlockSpriteType.FireWall:
                        state.health = 200;
                        break;
                }
            }
            si.health = state.health;
            BlockSprite bs = new BlockSprite(si, state, destroyed);

            created(bs);
        }