~eda-qa/dhlib/main

« back to all changes in this revision

Viewing changes to restricted/app-fortress/fortress/CannonSpeedTarget.hx

  • Committer: edA-qa mort-ora-y
  • Date: 2010-02-16 05:36:32 UTC
  • Revision ID: eda-qa@disemia.com-20100216053632-60lt7fndfi3fgblw
first

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package fortress;
 
2
 
 
3
class CannonSpeedTarget extends StdBuildDropTarget
 
4
{
 
5
        public function new( gd : GameDriver )
 
6
        {
 
7
                super( "+ Speed", new IClipPanelIncreaseSpeed(), gd, Math.floor(gd.global.cannonUpgradeLevels/2), 2 );  //dot bar with 20 slots by default
 
8
                reset();
 
9
        }
 
10
        
 
11
        override public function acceptObject( bo : BuildObject, sp : flash.geom.Point ) : Bool
 
12
        {
 
13
                //consume and increase cannon size
 
14
                gameDriver.data.plCannonSpeed += gameDriver.global.cannonSpeedInc;
 
15
                reset();
 
16
                return true;
 
17
        }
 
18
        
 
19
        override public function canAcceptObject( bo : BuildObject, sp : flash.geom.Point ) : Bool
 
20
        {
 
21
                return Std.is( bo, CannonBuildObject );
 
22
        }
 
23
        
 
24
        public function reset()
 
25
        {
 
26
                dotBar.setNumActive( 
 
27
                        Math.round( //we expect exact increments, but use round to deal with precision errors
 
28
                                (gameDriver.data.plCannonSpeed - gameDriver.data.plCannonSpeedInit) / gameDriver.global.cannonSpeedInc 
 
29
                                )
 
30
                         );
 
31
        }
 
32
        
 
33
}