Android dash is an open source project powered by Assembla

Assembla offers free public and private SVN/Git repositories and project hosting with bug/issue tracking and collaboration tools.

android-dash

Commit 11

User picture
  • Author: androiddash
  • 2011-12-02 10:11 (over 2 years ago)

Bubblegum.as, Level.as e GenericEnemy.as - Chiclete funcionando =D

Files Affected

 
1011
94
                        Level._arrayOfItensBeingUsed.push(bomb);
94
                        Level._arrayOfItensBeingUsed.push(bomb);
95
                        Level._itemActivedType = "";
95
                        Level._itemActivedType = "";
96
                        break;
96
                        break;
97
                    case "bubblegum":
 
 
98
                        var bubblegum:Bubblegum = new Bubblegum(this);
 
 
99
                        Level._arrayOfItensBeingUsed.push(bubblegum);
 
 
100
                        Level._itemActivedType = "";
 
 
101
                        break;
 
 
102
                }
97
                }
103
            }
98
            }
104
        }
99
        }
1011
31
            //Drop Itens
31
            //Drop Itens
32
            this.chanceOfDropItem = 100;
32
            this.chanceOfDropItem = 100;
33
            this.chanceOfNoItem = 30;
33
            this.chanceOfNoItem = 30;
34
            this._itemType = "bomb";
34
            this._itemType = "bubblegum";
35
 
35
 
36
        }
36
        }
37
 
37
 
1011
4
    import Class.Screens.Level;
4
    import Class.Screens.Level;
5
    import flash.display.MovieClip;
5
    import flash.display.MovieClip;
6
    import flash.events.Event;
6
    import flash.events.Event;
 
 
7
    import flash.events.TimerEvent;
7
    import flash.utils.Timer;
8
    import flash.utils.Timer;
8
    /**
9
    /**
9
     * ...
10
     * ...
...
 
...
 
11
     */
12
     */
12
    public class Bubblegum extends MovieClip
13
    public class Bubblegum extends MovieClip
13
    {
14
    {
14
        private var _enemyReference:GenericEnemy;
15
        private var _activeTimer:Timer = new Timer(1000, 4);
15
        private var _timeAlive:Timer = new Timer(1000, 4);
 
 
16
        private var _countTimer:Number = 0;
16
        private var _countTimer:Number = 0;
17
        private var _imActive:Boolean = false;
17
        private var _imActive:Boolean = false;
 
 
18
        private var _enemyReference:GenericEnemy;
 
 
19
        private var _enemyLastXSpeed:Number;
 
 
20
        private var _haveEnemy:Boolean = false;
18
 
21
 
19
        public function Bubblegum(enemyReference:GenericEnemy) 
22
        public function Bubblegum(xPos, yPos) 
20
        {
23
        {
21
            _enemyReference = enemyReference
24
            Level._level.addChildAt(this, 0);
22
            Level._level.addChild(this);
25
            this.x = xPos;
 
 
26
            this.y = yPos;
23
            _imActive = true;
27
            _imActive = true;
24
            _timeAlive.addEventListener(Event.ACTIVATE, desactiveMe);
28
            _activeTimer.addEventListener(TimerEvent.TIMER , desactiveMe);
25
 
29
 
26
        }
30
        }
27
 
31
 
...
 
...
 
31
            if (_countTimer == 4)
35
            if (_countTimer == 4)
32
            {
36
            {
33
                _countTimer = 0;
37
                _countTimer = 0;
 
 
38
                _enemyReference.xSpeed = _enemyLastXSpeed;
 
 
39
                killYourSelf();
34
            }
40
            }
35
        }
41
        }
36
 
42
 
...
 
...
 
39
            _imActive = false;
45
            _imActive = false;
40
            Level._itemActivedType = "";
46
            Level._itemActivedType = "";
41
            Level._arrayOfItensBeingUsed.splice(Level._arrayOfItensBeingUsed.indexOf(this), 1);
47
            Level._arrayOfItensBeingUsed.splice(Level._arrayOfItensBeingUsed.indexOf(this), 1);
42
            _timeAlive.stop();
48
            _activeTimer.stop();
43
            _timeAlive.removeEventListener(TimerEvent.TIMER, desactiveMe);
49
            _activeTimer.removeEventListener(TimerEvent.TIMER, desactiveMe);
 
 
50
            _haveEnemy = false;
 
 
51
            
44
            while (this.numChildren)
52
            while (this.numChildren)
45
            {
53
            {
46
                this.removeChildAt(0);
54
                this.removeChildAt(0);
...
 
...
 
49
 
57
 
50
        public function update():void
58
        public function update():void
51
        {
59
        {
 
 
60
            for (var i:uint = 0; i < Level._enemyArray.length; i++)
 
 
61
            {
 
 
62
                if (!_haveEnemy)
 
 
63
                {
 
 
64
                    if (this.hitTest.hitTestObject(Level._enemyArray[i]))
 
 
65
                    {
 
 
66
                        _haveEnemy = true;
 
 
67
                        _activeTimer.start();
 
 
68
                        _enemyReference = Level._enemyArray[i];
 
 
69
                        _enemyLastXSpeed = _enemyReference.xSpeed;
 
 
70
                        _enemyReference.xSpeed = 0;
 
 
71
                    }
 
 
72
                }
 
 
73
 
 
 
74
            }
52
 
75
 
53
        }
76
        }
54
 
77
 
1011
1
package Class.Screens {
1
package Class.Screens {
2
 
2
 
3
    import Class.Enemies.NormalEnemy;
3
    import Class.Enemies.NormalEnemy;
 
 
4
    import Class.Item.Bubblegum;
4
    import Class.Item.Slot;
5
    import Class.Item.Slot;
5
    import Class.Main.*;
6
    import Class.Main.*;
6
 
7
 
...
 
...
 
95
 
96
 
96
            Main._stageRef.addEventListener(MouseEvent.MOUSE_DOWN, charging);
97
            Main._stageRef.addEventListener(MouseEvent.MOUSE_DOWN, charging);
97
            Main._stageRef.addEventListener(MouseEvent.MOUSE_UP, charging);
98
            Main._stageRef.addEventListener(MouseEvent.MOUSE_UP, charging);
 
 
99
            Level._level.itemAreaHit.addEventListener(MouseEvent.CLICK, checkIfHaveItensBeingUsedOnStage);
98
 
100
 
99
            //Variável para verificar se o jogo está rodando ou não
101
            //Variável para verificar se o jogo está rodando ou não
100
            RUNNING = true;
102
            RUNNING = true;
...
 
...
 
103
            this.addEventListener(Event.ACTIVATE, resumeGame);
105
            this.addEventListener(Event.ACTIVATE, resumeGame);
104
        }
106
        }
105
 
107
 
 
 
108
        private function checkIfHaveItensBeingUsedOnStage(e:MouseEvent):void 
 
 
109
        {
 
 
110
 
 
 
111
            if (Level._itemActivedType != "")
 
 
112
            {
 
 
113
 
 
 
114
                switch(Level._itemActivedType)
 
 
115
                {    
 
 
116
                    case "bubblegum":
 
 
117
                        var bubblegum:Bubblegum = new Bubblegum(Level._level.mouseX, Level._level.mouseY);
 
 
118
                        Level._arrayOfItensBeingUsed.push(bubblegum);
 
 
119
                        Level._itemActivedType = "";
 
 
120
                        break;
 
 
121
                }
 
 
122
                Level._activeSlot.cleanSlot();
 
 
123
            }
 
 
124
 
 
 
125
        }
106
 
126
 
 
 
127
 
107
        private function timerHandler(e:TimerEvent):void 
128
        private function timerHandler(e:TimerEvent):void 
108
        {
129
        {
109
            var _currentTime = 500 * _timeCount;
130
            var _currentTime = 500 * _timeCount;