private void nextKeyFrame() { mKeyFrameIndex++; if (mKeyFrameIndex < mKeyFrames.size() - 1) { mNextKeyFrameTime = mKeyFrames.get(mKeyFrameIndex + 1).mTime; } mFrameIndex = mKeyFrames.get(mKeyFrameIndex).mFrameIndex; mAnimationSprite.setCurrentTileIndex(mFrameIndex); }
public TowerUpgraderBack show(final Tower pTowerBase) { // Debug.i("TowerUpgrader :: show :: type=" + pTowerBase.getTowerType()); // disable tower interaction TowerManager.ENABLE_TOWER_INTERACTION = false; // set our current tower base mCurrentTowerBase = pTowerBase; // update our sell text mTowerSellText.setText(Integer.toString(pTowerBase.getTowerType().getCost())); // set our current row/col, make sure to account for our cancel + // sell button int currentCol = 0; int currentRow = 0; // find the coords final int[] coords = Registry.sMap.getCoordsFromTiles(pTowerBase.mTowerCol, pTowerBase.mTowerRow); // update the position mPositionMarker.setPosition(coords[0], coords[1]); mPositionMarker.setColor(1, 1, 1, 1.0f); // turn on updates and visibility mPositionMarker.setIgnoreUpdate(false); mPositionMarker.setVisible(true); // setup the radius marker mRadiusMarker.setIgnoreUpdate(false); mRadiusMarker.setVisible(true); mRadiusMarker.setWidth(pTowerBase.getTowerRange() * 2); mRadiusMarker.setHeight(pTowerBase.getTowerRange() * 2); // set the position of the marker mRadiusMarker.setPosition( (-pTowerBase.getTowerRange()) + (TowerManager.TOWER_WIDTH / 2), (-pTowerBase.getTowerRange()) + (TowerManager.TOWER_HEIGHT / 2)); // attach the radius marker to the position marker, then to the scene Registry.sSceneLayerTowers.attachChild(mPositionMarker); // get this towers upgrade types for (final TowerTypes tt : pTowerBase.getTowerUpgradeTypes()) { /** * final TiledSprite upgradableTower = new TiledSprite(this.mBoxX + TOWERS_UI_SPACER + * (TOWERS_UI_SPACER * currentCol) + (TOWERS_UI_ITEM_WIDTH * currentCol), mBoxY + * TOWERS_UI_SPACER + (TOWERS_UI_SPACER * currentRow) + (TOWERS_UI_ITEM_WIDTH * currentRow), * mTowerManager.getTowerMenuTiledTextureRegionClone()) { */ // PUT BORDERS ABOVE THESE FROM THE UI SPRITES THEY COME IN LARGE SIZE final float lX = mBoxX + TOWERS_UI_SPACER + (TOWERS_UI_SPACER * currentCol) + (TOWERS_UI_ITEM_WIDTH * currentCol); final float lY = mBoxY + TOWERS_UI_SPACER + (TOWERS_UI_SPACER * currentRow) + (TOWERS_UI_ITEM_HEIGHT * currentRow); final float placeX = (TOWERS_UI_ITEM_WIDTH / 2) + (lX - tt.getTowerTileCenterX()); final float placeY = (TOWERS_UI_ITEM_HEIGHT - TOWERS_UI_SPACER) + (lY - tt.getTowerTileCenterY()); final TiledSprite upgradableTower = new TiledSprite( placeX, placeY, Registry.sTowerTextureRegions[tt.getTowerTopSprite().getId()].deepCopy()); upgradableTower.setScale(.90f); if (null == tt.getPlayerRewardType() || Registry.sPlayerRewards.isRewardEarned(tt.getPlayerRewardType())) { upgradableTower.setAlpha(1f); } else { upgradableTower.setAlpha(.25f); } if (null != tt.getTowerBaseSprite()) { upgradableTower.setCurrentTileIndex(tt.getTowerBaseSprite().getInitialTileIndex()); // Debug.i("getTowerBaseSprite=" + tt.getTowerBaseSprite().getInitialTileIndex()); } if (null != tt.getTowerTopSprite()) { upgradableTower.setCurrentTileIndex(tt.getTowerTopSprite().getInitialTileIndex()); // Debug.i("getTowerTopSprite=" + tt.getTowerTopSprite().getInitialTileIndex()); } upgradableTower.setZIndex(100); attachChild(upgradableTower); registerTouchArea(upgradableTower); mUpgradeSprites.add(upgradableTower); final Rectangle rect = new Rectangle(lX, lY, TOWERS_UI_ITEM_WIDTH, TOWERS_UI_ITEM_HEIGHT) { @Override public boolean onAreaTouched( TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) { if (null == tt.getPlayerRewardType() || Registry.sPlayerRewards.isRewardEarned(tt.getPlayerRewardType())) { this.setAlpha(1f); if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) { TowerUpgraderBack.this.isValidClick = true; } if (TowerUpgraderBack.this.isValidClick && pSceneTouchEvent.getAction() == TouchEvent.ACTION_UP && GameActivity.SCROLL_MODE_DISABLED == Registry.sGameActivity.getScrollMode()) { Registry.sGameActivity.runOnUpdateThread( new Runnable() { @Override public void run() { TowerUpgraderBack.this.upgrade(pTowerBase, tt); TowerUpgraderBack.this.isValidClick = false; } }); } return true; } else { this.setAlpha(.25f); Registry.sGameActivity.userNotifyShort( "This tower requires the \"" + tt.getPlayerRewardType() + "\" reward to be unlocked. Visit the Game Points section from the main menu for more information about earning and spending Game Points (The currency \"GP\" you see above)."); return false; } } }; rect.setZIndex(90); attachChild(rect); if (++currentCol >= mTotalColumns) { currentRow++; currentCol = 0; } } sortChildren(); Debug.i("SpriteSheets.UI_128x128_01.ordinal()=" + SpriteSheets.UI_128x128_01.ordinal()); final TiledSprite ts = new TiledSprite( 25, 25, Registry.sSpriteTextureRegions[SpriteSheets.UI_128x128_01.ordinal()].deepCopy()); // final TiledSprite ts = new TiledSprite(25, 25, // Registry.sTowerTextureRegions[TowerTypes.ARCH_MAGE.getTowerTopSprite().getId()].deepCopy()); ts.setZIndex(110); ts.setCurrentTileIndex(0); attachChild(ts); Registry.sGameActivity.setScrollMode(GameActivity.SCROLL_MODE_DISABLED); Registry.sGameActivity.getCamera().setHUD(TowerUpgraderBack.this); return this; }