diff --git a/Assets/FutileDemos.meta b/Assets/FutileDemos.meta deleted file mode 100644 index 3ec8be5..0000000 --- a/Assets/FutileDemos.meta +++ /dev/null @@ -1,5 +0,0 @@ -fileFormatVersion: 2 -guid: a4a2af180428ba5489922a7bf0e938ca -folderAsset: yes -DefaultImporter: - userData: diff --git a/Assets/Scripts/BasicEnemy.cs b/Assets/Scripts/BasicEnemy.cs new file mode 100644 index 0000000..a442c45 --- /dev/null +++ b/Assets/Scripts/BasicEnemy.cs @@ -0,0 +1,40 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using System; + +public class BasicEnemy : Enemy +{ + private float speedX = 3.0f; + private float speedY = 0.0f; + private float shotrate = RXRandom.Range (60.0f,80.0f); + + private float frameCount = 0; + + public BasicEnemy() : base("Monkey_0") + { + this.x = Futile.screen.halfWidth; + this.y = RXRandom.Range(-Futile.screen.halfHeight, Futile.screen.halfHeight); + // once the sprites are swopped out, this needs to be forgone for + // sprites with proper resolution in the first place + this.scale = 0.25f; + } + + public BasicEnemy( float x, float y ) : base(x, y) + { + } + + override public void HandleUpdate() + { + + this.x -= speedX; + this.y += speedY; + + // enemy shoots + if(frameCount % shotrate == 0) + { + _shotStrategy.shoot(this.x, this.y, true); + } + frameCount += 1; + } +} diff --git a/Assets/Scripts/BasicEnemy.cs.meta b/Assets/Scripts/BasicEnemy.cs.meta new file mode 100644 index 0000000..f27af9b --- /dev/null +++ b/Assets/Scripts/BasicEnemy.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4a6bd5b12121e4ca8ae24387849d6166 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Scripts/BasicShotStrategy.cs b/Assets/Scripts/BasicShotStrategy.cs index 0f01882..958c62e 100644 --- a/Assets/Scripts/BasicShotStrategy.cs +++ b/Assets/Scripts/BasicShotStrategy.cs @@ -4,10 +4,10 @@ public class BasicShotStrategy : ShotStrategy { public void shoot( float x, float y, bool isEnemy ) { - Shot shotToCreate = new Shot(x, y, isEnemy); - if (isEnemy) - ShotManager.addEnemyShot(shotToCreate); - else - ShotManager.addPlayerShot(shotToCreate); + Shot shotToCreate = new Shot(x, y, isEnemy); + if (isEnemy) + ShotManager.addEnemyShot(shotToCreate); + else + ShotManager.addPlayerShot(shotToCreate); } } diff --git a/Assets/Scripts/BossEnemy.cs b/Assets/Scripts/BossEnemy.cs new file mode 100644 index 0000000..7d221fe --- /dev/null +++ b/Assets/Scripts/BossEnemy.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using System; + +public class BossEnemy : Enemy +{ + private float speedX = 0.5f; + private float shotrate = 40.0f; + private float frameCount = 0; + private int direction = -1; + + public BossEnemy() : base("Monkey_0") + { + this.x = Futile.screen.halfWidth; + this.y = 0f; + this.scale = 0.5f; + } + + public BossEnemy( float x, float y) : base(x, y) + { + } + + override public void HandleUpdate() + { + //movement of boss, slowly moves across screen and up and down + this.x -= speedX; + this.y -= direction * 1.5f; + if (this.y >= Futile.screen.halfHeight - 10f || this.y <= -Futile.screen.halfHeight + 10f) + direction = direction * -1; + + // enemy shoots + if (frameCount % shotrate == 0) + { + _shotStrategy.shoot(this.x, this.y, true); + } + frameCount += 1; + } + +} diff --git a/Assets/Scripts/BossEnemy.cs.meta b/Assets/Scripts/BossEnemy.cs.meta new file mode 100644 index 0000000..0c6e954 --- /dev/null +++ b/Assets/Scripts/BossEnemy.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: afe9a90f90b0f4de48ba0fdda37bf185 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Scripts/Controls/ControlScheme.cs b/Assets/Scripts/Controls/ControlScheme.cs index 69ae849..3f63380 100644 --- a/Assets/Scripts/Controls/ControlScheme.cs +++ b/Assets/Scripts/Controls/ControlScheme.cs @@ -7,14 +7,22 @@ public abstract class ControlScheme : FContainer { // target is what the ControlScheme will move protected Player _target; - public ControlScheme( Player target ){ + public ControlScheme(){ + } + + public ControlScheme( Player target ){ + setTarget(target); + } + + public void setTarget( Player target ){ this._target = target; } //default shooting behavior public void HandleShoot() { - _target.shoot(); + if( _target != null ) + _target.shoot(); } public abstract void acceptTouchOne(FTouch touch); diff --git a/Assets/Scripts/Controls/PadControlScheme.cs b/Assets/Scripts/Controls/PadControlScheme.cs index 995465e..700a522 100644 --- a/Assets/Scripts/Controls/PadControlScheme.cs +++ b/Assets/Scripts/Controls/PadControlScheme.cs @@ -8,8 +8,7 @@ public class PadControlScheme : ControlScheme { private int speedX = 0; private int speedY = 0; - public PadControlScheme( Player target ) : base( target ){ - _target = target; + public PadControlScheme(){ pad = new GamePad(); AddChild (pad); ListenForUpdate(HandleUpdate); @@ -17,8 +16,10 @@ public PadControlScheme( Player target ) : base( target ){ public void HandleUpdate() { - _target.x += speedX; - _target.y += speedY; + if( _target != null ) { + _target.x += speedX; + _target.y += speedY; + } } override public void acceptTouchOne(FTouch touch) diff --git a/Assets/Scripts/Controls/TouchControlScheme.cs b/Assets/Scripts/Controls/TouchControlScheme.cs index 497f8e6..7002dba 100644 --- a/Assets/Scripts/Controls/TouchControlScheme.cs +++ b/Assets/Scripts/Controls/TouchControlScheme.cs @@ -6,8 +6,7 @@ public class TouchControlScheme : ControlScheme { - public TouchControlScheme( Player target ) : base( target ){ - _target = target; + public TouchControlScheme(){ } public void MoveCharacter(FTouch touch) diff --git a/Assets/Scripts/Controls/XboxControlScheme.cs b/Assets/Scripts/Controls/XboxControlScheme.cs index 637960b..e403cd3 100644 --- a/Assets/Scripts/Controls/XboxControlScheme.cs +++ b/Assets/Scripts/Controls/XboxControlScheme.cs @@ -8,16 +8,17 @@ public class XboxControlScheme : ControlScheme { private float speedX = 0; private float speedY = 0; - public XboxControlScheme( Player target ) : base( target ){ - _target = target; + public XboxControlScheme(){ ListenForUpdate(HandleUpdate); } public void HandleUpdate() { - _target.x += speedX; - _target.y += speedY; - decodeTouch(); + if( _target != null ){ + _target.x += speedX; + _target.y += speedY; + decodeTouch(); + } } // these touch mehods aren't used diff --git a/Assets/Scripts/Enemy.cs b/Assets/Scripts/Enemy.cs index e44a643..85608e8 100644 --- a/Assets/Scripts/Enemy.cs +++ b/Assets/Scripts/Enemy.cs @@ -3,39 +3,35 @@ using System.Collections.Generic; using System; -public class Enemy : FSprite +public abstract class Enemy : FSprite { - private float speedX = 3.0f; - private float speedY = 0.0f; - private float shotrate = RXRandom.Range (60.0f,80.0f); - private float frameCount = 0; + protected ShotStrategy _shotStrategy; - ShotStrategy _shotStrategy; - - public Enemy() : base("fish-fred") - { - this.x = Futile.screen.halfWidth; - this.y = RXRandom.Range(-Futile.screen.halfHeight, Futile.screen.halfHeight); - this.scale = 0.25f; - ListenForUpdate (HandleUpdate); - } + public Enemy() : base("fish-fred") + { + // default shotStrategy + _shotStrategy = new BasicShotStrategy(); + this.x = Futile.screen.halfWidth; + this.y = RXRandom.Range(-Futile.screen.halfHeight, Futile.screen.halfHeight); + // once the sprites are swopped out, this needs to be forgone for + // sprites with proper resolution in the first place + this.scale = 0.25f; + ListenForUpdate (HandleUpdate); + } - public void setShotStrategy( ShotStrategy _shotStrategy ) - { - this._shotStrategy = _shotStrategy; - } - - public void HandleUpdate() - { - - this.x -= speedX; - this.y += speedY; + public Enemy( float x, float y ) : this() + { + this.x = x; + this.y = y; + } - // enemy shoots - if(frameCount%shotrate == 0) - { - _shotStrategy.shoot(this.x, this.y, true); - } - frameCount += 1; - } -} \ No newline at end of file + public Enemy( string sprite ) : base(sprite) + { + } + + public void setShotStrategy( ShotStrategy _shotStrategy ) + { + this._shotStrategy = _shotStrategy; + } + public abstract void HandleUpdate(); +} diff --git a/Assets/Scripts/EnemyFactory.cs b/Assets/Scripts/EnemyFactory.cs new file mode 100644 index 0000000..6cacf06 --- /dev/null +++ b/Assets/Scripts/EnemyFactory.cs @@ -0,0 +1,30 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using System; + +public static class EnemyFactory +{ + public static Enemy generateEnemy( string enemyName, float x, float y ) + { + // this should really be changed, so LevelEvents have some + // sort of EnemyType built into them, so they can be type- + // checked versus being a string. + // + + if( enemyName.Equals( "enemy1" ) ) + { + return new BasicEnemy(x, y); + } else if( enemyName.Equals( "boss1" ) ) + { + Enemy _myEnemy = new BossEnemy(x, y); + _myEnemy.setShotStrategy(new FanShotStrategy()); + return _myEnemy; + } else + { + Debug.Log( "not a valid EnemyType!" ); + return null; + } + + } +} diff --git a/Assets/Scripts/EnemyFactory.cs.meta b/Assets/Scripts/EnemyFactory.cs.meta new file mode 100644 index 0000000..105617d --- /dev/null +++ b/Assets/Scripts/EnemyFactory.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6de2c9dc3548341bdade2ba116877801 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Scripts/FanShotStrategy.cs b/Assets/Scripts/FanShotStrategy.cs index bc82e20..c6b2277 100644 --- a/Assets/Scripts/FanShotStrategy.cs +++ b/Assets/Scripts/FanShotStrategy.cs @@ -2,19 +2,19 @@ using System.Collections; public class FanShotStrategy : ShotStrategy { - public void shoot( float x, float y, bool isEnemy ) - { - Shot shotToCreate; - int[] angles = { 45, 15, 0, 315, 345}; + public void shoot( float x, float y, bool isEnemy ) + { + Shot shotToCreate; + int[] angles = { 45, 15, 0, 315, 345}; - for (int i = 0; i < angles.Length; ++i) - { - float angle = angles[i]*Mathf.Deg2Rad; - shotToCreate = new Shot(x, y, isEnemy, angle) ; - if (isEnemy) - ShotManager.addEnemyShot(shotToCreate); - else - ShotManager.addPlayerShot(shotToCreate); - } + for (int i = 0; i < angles.Length; ++i) + { + float angle = angles[i]*Mathf.Deg2Rad; + shotToCreate = new Shot(x, y, isEnemy, angle); + if (isEnemy) + ShotManager.addEnemyShot(shotToCreate); + else + ShotManager.addPlayerShot(shotToCreate); } -} \ No newline at end of file + } +} diff --git a/Assets/Scripts/Level.cs b/Assets/Scripts/Level.cs index 846383f..ab754f2 100644 --- a/Assets/Scripts/Level.cs +++ b/Assets/Scripts/Level.cs @@ -1,20 +1,40 @@ using UnityEngine; -using System.Collections; +using System.Collections.Generic; -public class Level +public abstract class Level { - protected FSprite _background; - protected GamePage _gamepage; - public Level(GamePage _gamepage) - { - // how about a level takes in a BG string? -- Level manager (not written) would be able to iterate/dole out "levels" - // this will be later relegated to subclasses of the interface Level - // Level could be able to farm out to a text file, but "for now", how about just subclassing `Level` for each one? - this._gamepage = _gamepage; - } - protected void setBackground( string _background_file ){ - _background = new FSprite( _background_file ); - _gamepage.AddChild(_background); - } + protected FSprite _background; + protected GamePage _gamepage; + protected Queue _eventQueue; -} \ No newline at end of file + public Level(GamePage _gamepage) + { + // how about a level takes in a BG string? -- Level manager (not written) would be able to iterate/dole out "levels" + // this will be later relegated to subclasses of the interface Level + // Level could be able to farm out to a text file, but "for now", how about just subclassing `Level` for each one? + this._eventQueue = new Queue(); + this._gamepage = _gamepage; + } + + protected void setBackground( string _background_file ){ + _background = new FSprite( _background_file ); + _gamepage.AddChild(_background); + } + + public int eventCount() + { + return _eventQueue.Count; + } + + public float nextEventTime() + { + return _eventQueue.Peek().getTime(); + } + + // provide a way to pop off stack + public LevelEvent popEvent() + { + return _eventQueue.Dequeue(); + } + +} diff --git a/Assets/Scripts/LevelEvent.cs b/Assets/Scripts/LevelEvent.cs new file mode 100644 index 0000000..c02cdd8 --- /dev/null +++ b/Assets/Scripts/LevelEvent.cs @@ -0,0 +1,41 @@ +using UnityEngine; +using System.Collections; + +public class LevelEvent { + private float _triggerTime; + private string _enemyName; + private float _xSpawn; + private float _ySpawn; + + public LevelEvent () + { + } + + public LevelEvent( float time, string enemyName, float x, float y ) + { + this._triggerTime = time; + this._enemyName = enemyName; + this._xSpawn = x; + this._ySpawn = y; + } + + public float getTime() + { + return _triggerTime; + } + + public string getEnemyName() + { + return _enemyName; + } + + public float getXSpawn() + { + return _xSpawn; + } + + public float getYSpawn() + { + return _ySpawn; + } +} diff --git a/Assets/Scripts/LevelEvent.cs.meta b/Assets/Scripts/LevelEvent.cs.meta new file mode 100644 index 0000000..64f8601 --- /dev/null +++ b/Assets/Scripts/LevelEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d77b9828de8b5bd459b5b5f641f8d90d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Scripts/Main.cs b/Assets/Scripts/Main.cs index db87bbb..967a8d7 100644 --- a/Assets/Scripts/Main.cs +++ b/Assets/Scripts/Main.cs @@ -9,7 +9,8 @@ public enum PageType TitlePage, GamePage, OptionPage, - CreditPage + CreditPage, + GameOverPage } public class Main : MonoBehaviour @@ -17,18 +18,24 @@ public class Main : MonoBehaviour public BCharacter character; public GamePage gamePage; public static Main instance; + public ControlScheme controlScheme; + + //Initialize The player's lives. + public FLabel _livesLabel; + public int lives = 3; private PageContatiner _currentPage = null; private PageType _currentPageType = PageType.None; private FStage _stage; // Use this for initialization void Start () { + controlScheme = new TouchControlScheme(); instance = this; FutileParams fparams = new FutileParams(true,true,false,false); fparams.AddResolutionLevel(480.0f, 1.0f, 1.0f, "_Scale1"); fparams.origin = new Vector2(0.5f, 0.5f); Futile.instance.Init(fparams); - + //load atlasses Futile.atlasManager.LoadAtlas("Atlases/BananaLargeAtlas"); Futile.atlasManager.LoadAtlas("Atlases/BananaGameAtlas"); @@ -38,7 +45,7 @@ void Start () { Futile.atlasManager.LoadFont("Franchise","FranchiseFont"+Futile.resourceSuffix, "Atlases/FranchiseFont"+Futile.resourceSuffix, 0.0f,-4.0f); _stage = Futile.stage; - + //go to this page when starts the game GoToPage(PageType.GamePage); } @@ -62,6 +69,10 @@ public void GoToPage(PageType pageType) { pageToCreate = new CreditPage(); } + else if(pageType == PageType.GameOverPage) + { + pageToCreate = new GameOverPage(); + } if(pageToCreate != null) { diff --git a/Assets/Scripts/Pages/GameOverPage.cs b/Assets/Scripts/Pages/GameOverPage.cs new file mode 100644 index 0000000..94421ff --- /dev/null +++ b/Assets/Scripts/Pages/GameOverPage.cs @@ -0,0 +1,35 @@ +using UnityEngine; +using System.Collections; +using System; + +public class GameOverPage: PageContatiner +{ + private FButton _backButton; + private FSprite _background; + private FLabel _GameOver; + public GameOverPage () + { + //initialize + _background = new FSprite("JungleBlurryBG"); + _backButton = new FButton("YellowButton_normal", "YellowButton_down", "YellowButton_over", "ClickSound"); + _backButton.AddLabel("Franchise", "Back", new Color(0.45f,0.25f,0.0f,1.0f)); + _GameOver = new FLabel("Franchise", "Game Over for YOU"); + _GameOver.color = new Color(0.45f,0.25f,0.0f,1.0f); + //position back button + _backButton.x = Futile.screen.halfWidth - 30.0f; + _backButton.y = Futile.screen.halfHeight - 30.0f; + + //add to the stage + AddChild(_background); + AddChild(_backButton); + AddChild(_GameOver); + _backButton.SignalRelease += HandleBackButtonRelease; + + } + private void HandleBackButtonRelease(FButton fbutton) + { + Main.instance.GoToPage(PageType.TitlePage); + } +} + + diff --git a/Assets/Scripts/Pages/GameOverPage.cs.meta b/Assets/Scripts/Pages/GameOverPage.cs.meta new file mode 100644 index 0000000..6ab32b6 --- /dev/null +++ b/Assets/Scripts/Pages/GameOverPage.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ac320dc8901524a9fb2e6236b714cc72 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Scripts/Pages/Gamepage.cs b/Assets/Scripts/Pages/Gamepage.cs index f9dfc10..401a38b 100644 --- a/Assets/Scripts/Pages/Gamepage.cs +++ b/Assets/Scripts/Pages/Gamepage.cs @@ -1,18 +1,28 @@ -using UnityEngine; +using UnityEngine; using System.Collections; using System.Collections.Generic; using System; public class GamePage : PageContatiner, FMultiTouchableInterface { + private Level _level; + private LevelEvent _myEvent; + private float _startTime; + private Player _player; private FContainer _holder; private FButton _shootbutton; private FSprite _monkey; private FButton _backButton; + + // Labels + private FLabel _scoreLabel; + private FLabel _timeLabel; + private FLabel _livesLabel; + private int _playerLives; private Enemy _enemy; - private List _enemies; + private List _enemies; private List _playerShots; private List _enemyShots; @@ -25,24 +35,34 @@ public class GamePage : PageContatiner, FMultiTouchableInterface private FButton _rightbutton; private FButton _leftbutton; - private float frameCount = 0; - public GamePage() { - // initialise ShotManager - ShotManager.setContainer(this); + // initialise ShotManager + ShotManager.setContainer(this); ListenForUpdate (HandleUpdate); _player = new Player(); - _enemies = new List(); + _enemies = new List(); _backButton = new FButton("CloseButton_normal", "CloseButton_down", "CloseButton_over", "ClickSound"); _backButton.x = Futile.screen.halfWidth - 30.0f; _backButton.y = Futile.screen.halfHeight - 30.0f; + + //initialize player's lives + _playerLives = 3; + + // initialise level + LevelInit(); - // initialise level - Level myLevel = new TestLevel(this); + // lives + _livesLabel = new FLabel("Franchise", "Player's lives: 3 "); + _livesLabel.anchorX = 0.0f; + _livesLabel.anchorY = 1.0f; + _livesLabel.scale = 0.75f; + _livesLabel.color = new Color(0.45f,0.25f,0.0f,1.0f); + _livesLabel.x = -Futile.screen.halfWidth + 30.0f; + _livesLabel.y = Futile.screen.halfHeight - 0.0f; // initialise player _player.x = 0.0f; @@ -53,30 +73,39 @@ public GamePage() // enable MultiTouch EnableMultiTouch(); - // add backbutton + // add backbutton AddChild(_backButton); + + // add live label + AddChild(_livesLabel); - //_control = new TouchControlScheme(_player); - _control = new PadControlScheme(_player); + //_control = new TouchControlScheme(); + _control = new PadControlScheme(); + _control.setTarget(_player); + // add control from the main class + _control = Main.instance.controlScheme; + _control.setTarget ( _player ); AddChild (_control); - // add xbox controls for debugging only - #if UNITY_EDITOR - _debug_control = new XboxControlScheme(_player); - AddChild (_debug_control); - #endif + + // add xbox controls for debugging only + #if UNITY_EDITOR + _debug_control = new XboxControlScheme(); + _debug_control.setTarget ( _player ); + AddChild (_debug_control); + #endif - // music loop - //FSoundManager.PlayMusic("loop1", 1.0f); + // music loop + FSoundManager.PlayMusic("loop1", 1.0f); _backButton.SignalRelease += HandleBackButtonRelease; } - override public void HandleRemovedFromStage() - { - base.HandleRemovedFromStage(); - ShotManager.reset(); - } + override public void HandleRemovedFromStage() + { + base.HandleRemovedFromStage(); + ShotManager.reset(); + } private void HandleBackButtonRelease(FButton fbutton) { @@ -85,20 +114,30 @@ private void HandleBackButtonRelease(FButton fbutton) public void HandleUpdate() { - _playerShots = ShotManager.playerShots(); + + _playerShots = ShotManager.playerShots(); _enemyShots = ShotManager.enemyShots(); - // generate enemies - frameCount += 1; - if(frameCount%60 == 0) - { - _enemy = new Enemy(); - _enemy.setShotStrategy( new BasicShotStrategy() ); - AddChild(_enemy); - _enemies.Add(_enemy); - } + // level checking code + // -- eventually this stuff could move to a dedicated level manager or something + if( _level.eventCount() != 0 ) { + if( (Time.time - _startTime) > _level.nextEventTime() ) + { + _myEvent = _level.popEvent(); + _enemy = EnemyFactory.generateEnemy( _myEvent.getEnemyName(), _myEvent.getXSpawn(), _myEvent.getYSpawn() ); + _enemy.x = _myEvent.getXSpawn(); + _enemy.y = _myEvent.getYSpawn(); + AddChild(_enemy); + _enemies.Add(_enemy); + } + } else { + // end of level + // -- either get a new one or end game, yo + Main.instance.GoToPage(PageType.GameOverPage); + } + // remove shots from edge of screen - ShotManager.checkBoundaries(); + ShotManager.checkBoundaries(); // Check if Enemies are out of screen boundaries for(int c = _enemies.Count - 1; c>=0; c--) @@ -151,13 +190,26 @@ public void HandleUpdate() if(playerBounds.Contains(shotPos)) { - _player.playerDeath (); ShotManager.removeShot(_shot); + _player.playerDeath(); + _playerLives--; } } - } + + //decrease the number of player's lives + if(_playerLives <= 0) + { + _livesLabel.text = "Player's Lives: " + _playerLives; + Main.instance.GoToPage(PageType.GameOverPage); + } + else + { + _livesLabel.text = "Player's Lives: " + _playerLives; + } + + } // END HANDLEUPDATE - // Player input + // Player input public void HandleMultiTouch(FTouch[] touches) { if (touches.Length > 0){ @@ -167,4 +219,10 @@ public void HandleMultiTouch(FTouch[] touches) _control.acceptTouchTwo(touches[1]); } } -} \ No newline at end of file + private void LevelInit() + { + _level = new TestLevel(this); + _startTime = Time.time; + } + +} diff --git a/Assets/Scripts/Pages/OptionPage.cs b/Assets/Scripts/Pages/OptionPage.cs index 4c45da8..c0caaee 100644 --- a/Assets/Scripts/Pages/OptionPage.cs +++ b/Assets/Scripts/Pages/OptionPage.cs @@ -5,21 +5,57 @@ public class OptionPage: PageContatiner { private FButton _backButton; + private FButton _padControlButton; + private FButton _touchControlButton; private FSprite _background; + private FLabel _controlLabel; public OptionPage () { + //Create background _background = new FSprite("JungleBlurryBG"); + //Control label created + _controlLabel = new FLabel("Franchise", "Controls: "); + //buttons created _backButton = new FButton("YellowButton_normal", "YellowButton_down", "YellowButton_over", "ClickSound"); _backButton.AddLabel("Franchise", "Back", new Color(0.45f,0.25f,0.0f,1.0f)); + _padControlButton = new FButton("YellowButton_normal", "YellowButton_down", "YellowButton_over", "ClickSound"); + _padControlButton.AddLabel("Franchise", "Buttons", new Color(0.45f,0.25f,0.0f,1.0f)); + _touchControlButton = new FButton("YellowButton_normal", "YellowButton_down", "YellowButton_over", "ClickSound"); + _touchControlButton.AddLabel("Franchise", "Touch", new Color(0.45f,0.25f,0.0f,1.0f)); + //positioning the buttons + _controlLabel.x = -Futile.screen.halfWidth + 120.0f; + _backButton.x = -Futile.screen.halfWidth + 80.0f; + _backButton.y = Futile.screen.halfHeight - 30.0f; + _touchControlButton.x = -Futile.screen.halfWidth + 120.0f; + _padControlButton.x = Futile.screen.halfWidth - 120.0f; + _touchControlButton.y = -Futile.screen.halfHeight + 60.0f; + _padControlButton.y = -Futile.screen.halfHeight + 60.0f; + _controlLabel.color = new Color(0.45f,0.25f,0.0f,1.0f); + //adding to the stage AddChild(_background); + AddChild(_controlLabel); AddChild(_backButton); + AddChild(_touchControlButton); + AddChild(_padControlButton); + //something happens when buttons are pressed _backButton.SignalRelease += HandleBackButtonRelease; + _touchControlButton.SignalRelease += HandleTouchControlsRelease; + _padControlButton.SignalRelease += HandlePadControlsRelease; } private void HandleBackButtonRelease(FButton fbutton) { Main.instance.GoToPage(PageType.TitlePage); } + + private void HandleTouchControlsRelease(FButton Btouch) + { + Main.instance.controlScheme = new TouchControlScheme(); + } + private void HandlePadControlsRelease(FButton Bpad) + { + Main.instance.controlScheme = new PadControlScheme(); + } } diff --git a/Assets/Scripts/Pages/TitlePage.cs b/Assets/Scripts/Pages/TitlePage.cs index 1e9906f..837afca 100644 --- a/Assets/Scripts/Pages/TitlePage.cs +++ b/Assets/Scripts/Pages/TitlePage.cs @@ -4,44 +4,49 @@ public class TitlePage : PageContatiner { - private FLabel _titlePage; - private FSprite _background; - private FButton _backButton; - private FButton _optionButton; - private FButton _creditButton; - private FButton _startButton; - public TitlePage () - { - _background = new FSprite("background_1_blur"); - _optionButton = new FButton("YellowButton_normal", "YellowButton_down", "YellowButton_over", "ClickSound"); - _optionButton.AddLabel("Franchise", "Option", new Color(0.45f,0.25f,0.0f,1.0f)); - _creditButton = new FButton("YellowButton_normal", "YellowButton_down", "YellowButton_over", "ClickSound"); - _creditButton.AddLabel("Franchise", "Credits", new Color(0.45f,0.25f,0.0f,1.0f)); - _startButton = new FButton("YellowButton_normal", "YellowButton_down", "YellowButton_over", "ClickSound"); - _startButton.AddLabel("Franchise", "START!", new Color(0.45f,0.25f,0.0f,1.0f)); - _optionButton.x = -Futile.screen.halfWidth + 120.0f; - _creditButton.x = Futile.screen.halfWidth - 120.0f; - _startButton.y = -Futile.screen.halfHeight + 30.0f; - AddChild(_background); - AddChild(_optionButton); - AddChild(_creditButton); - AddChild(_startButton); - _optionButton.SignalRelease += HandleOptionButtonRelease; - _creditButton.SignalRelease += HandleCreditButtonRelease; - _startButton.SignalRelease += HandleStartButtonRelease; - - } - private void HandleOptionButtonRelease (FButton button) - { - Main.instance.GoToPage(PageType.OptionPage); - } - private void HandleCreditButtonRelease (FButton button) - { - Main.instance.GoToPage(PageType.CreditPage); - } - private void HandleStartButtonRelease (FButton button) - { - Main.instance.GoToPage(PageType.GamePage); - } + private FLabel _titlePage; + private FSprite _background; + private FButton _backButton; + private FButton _optionButton; + private FButton _creditButton; + private FButton _startButton; + public TitlePage () + { + //background and buttons are created + _background = new FSprite("background_1_blur"); + + _optionButton = new FButton("YellowButton_normal", "YellowButton_down", "YellowButton_over", "ClickSound"); + _optionButton.AddLabel("Franchise", "Option", new Color(0.45f,0.25f,0.0f,1.0f)); + _creditButton = new FButton("YellowButton_normal", "YellowButton_down", "YellowButton_over", "ClickSound"); + _creditButton.AddLabel("Franchise", "Credits", new Color(0.45f,0.25f,0.0f,1.0f)); + _startButton = new FButton("YellowButton_normal", "YellowButton_down", "YellowButton_over", "ClickSound"); + _startButton.AddLabel("Franchise", "START!", new Color(0.45f,0.25f,0.0f,1.0f)); + //positioning the buttons + _optionButton.x = -Futile.screen.halfWidth + 120.0f; + _creditButton.x = Futile.screen.halfWidth - 120.0f; + _startButton.y = -Futile.screen.halfHeight + 30.0f; + //adding to display them on stage + AddChild(_background); + AddChild(_optionButton); + AddChild(_creditButton); + AddChild(_startButton); + //something happens when buttons are pressed + _optionButton.SignalRelease += HandleOptionButtonRelease; + _creditButton.SignalRelease += HandleCreditButtonRelease; + _startButton.SignalRelease += HandleStartButtonRelease; + + } + private void HandleOptionButtonRelease (FButton button) + { + Main.instance.GoToPage(PageType.OptionPage); + } + private void HandleCreditButtonRelease (FButton button) + { + Main.instance.GoToPage(PageType.CreditPage); + } + private void HandleStartButtonRelease (FButton button) + { + Main.instance.GoToPage(PageType.GamePage); + } } diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 5c15e0a..6448ed8 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -2,37 +2,37 @@ using System.Collections; public class Player : FSprite { - - // last shot time - private float last_shot_time; - private ShotStrategy _shotStrategy; - - public Player() : base("fish-frond") - { - this.scale = 0.5f; - this.scaleX = -0.5f; - } - - public void setShotStrategy( ShotStrategy _shotStrategy ) - { - this._shotStrategy = _shotStrategy; - } - - public void playerDeath() - { - //return player to the middle of the screen - this.x = 0; - this.y = 0; - - //handle any death consequences - } - - public void shoot() - { - if( Time.time-last_shot_time > 0.15 ){ - _shotStrategy.shoot(this.x, this.y, false); - last_shot_time = Time.time; - } + + // last shot time + private float last_shot_time; + private ShotStrategy _shotStrategy; + + public Player() : base("fish-frond") + { + this.scale = 0.5f; + this.scaleX = -0.5f; + } + + public void setShotStrategy( ShotStrategy _shotStrategy ) + { + this._shotStrategy = _shotStrategy; + } + + public void playerDeath() + { + //return player to the middle of the screen + this.x = 0; + this.y = 0; + + //handle any death consequences + } + + public void shoot() + { + if( Time.time-last_shot_time > 0.15 ){ + _shotStrategy.shoot(this.x, this.y, false); + last_shot_time = Time.time; } - + } + } diff --git a/Assets/Scripts/Shot.cs b/Assets/Scripts/Shot.cs index 35ef4fd..8b53cd7 100644 --- a/Assets/Scripts/Shot.cs +++ b/Assets/Scripts/Shot.cs @@ -5,33 +5,32 @@ public class Shot : FSprite { - - private float speedX = 0.0f; - private float speedY = 0.0f; - - public Shot(float x, float y, bool isEnemy) : base("bullet_gray") - { - this.x = x; - this.y = y; - this.scale = 0.25f; - int direction = isEnemy ? -1 : 1; - this.speedX = 5*direction; - this.speedY = 0; - ListenForUpdate (HandleUpdate); - } - // overloaded constructor, for angled shots - public Shot(float x, float y, bool isEnemy, float angle) : this(x, y, isEnemy) - { - int direction = isEnemy ? -1 : 1; - this.speedX = Mathf.Cos(angle) * direction * speedX; - this.speedY = Mathf.Sin(angle) * speedX; - } - - public void HandleUpdate() - { - this.x += speedX; - this.y += speedY; - } + private float speedX = 0.0f; + private float speedY = 0.0f; -} \ No newline at end of file + public Shot(float x, float y, bool isEnemy) : base("bullet_gray") + { + this.x = x; + this.y = y; + this.scale = 0.25f; + int direction = isEnemy ? -1 : 1; + this.speedX = 5*direction; + this.speedY = 0; + ListenForUpdate (HandleUpdate); + } + + // overloaded constructor, for angled shots + public Shot(float x, float y, bool isEnemy, float angle) : this(x, y, isEnemy) + { + this.speedX = Mathf.Cos(angle) * speedX; + this.speedY = Mathf.Sin(angle) * speedX; + } + + public void HandleUpdate() + { + this.x += speedX; + this.y += speedY; + } + +} diff --git a/Assets/Scripts/ShotManager.cs b/Assets/Scripts/ShotManager.cs index 7e7fc63..f251162 100644 --- a/Assets/Scripts/ShotManager.cs +++ b/Assets/Scripts/ShotManager.cs @@ -5,7 +5,7 @@ public static class ShotManager { - private static FContainer _container; + private static FContainer _container; private static List _allShots = new List(); private static List _enemyShots = new List(); @@ -13,72 +13,82 @@ public static class ShotManager public static void checkBoundaries() { - // delete out-of-boundary shots - for(int i = _allShots.Count - 1; i>=0; --i) - { - Shot shot = _allShots[i]; - if ((shot.x < -Futile.screen.halfWidth) || (shot.x > Futile.screen.halfWidth)) - { - ShotManager.removeShot(shot); - } - } + // delete out-of-boundary shots + for(int i = _allShots.Count - 1; i>=0; --i) + { + Shot shot = _allShots[i]; + if ((shot.x < -Futile.screen.halfWidth) || (shot.x > Futile.screen.halfWidth)) + { + ShotManager.removeShot(shot); + } + } } public static void setContainer(FContainer fc) { - reset(); - _container = fc; + reset(); + _container = fc; } public static void addPlayerShot(Shot shot) { - _playerShots.Add(shot); - _allShots.Add(shot); - _container.AddChild(shot); + if( _container != null ) { + _playerShots.Add(shot); + _allShots.Add(shot); + _container.AddChild(shot); + } } public static void addEnemyShot(Shot shot) { - _enemyShots.Add(shot); - _allShots.Add(shot); - _container.AddChild(shot); - } + if( _container != null ) { + _enemyShots.Add(shot); + _allShots.Add(shot); + _container.AddChild(shot); + } + } public static void removePlayerShot(Shot shot) { - _playerShots.Remove(shot); - _allShots.Remove(shot); - _container.RemoveChild(shot); + if( _container != null ) { + _playerShots.Remove(shot); + _allShots.Remove(shot); + _container.RemoveChild(shot); + } } public static void removeEnemyShot(Shot shot) { - _enemyShots.Remove(shot); - _allShots.Remove(shot); - _container.RemoveChild(shot); + if( _container != null ) { + _enemyShots.Remove(shot); + _allShots.Remove(shot); + _container.RemoveChild(shot); + } } - public static void removeShot(Shot shot) - { - _playerShots.Remove(shot); - _enemyShots.Remove(shot); - _allShots.Remove(shot); - _container.RemoveChild(shot); + public static void removeShot(Shot shot) + { + if( _container != null ) { + _playerShots.Remove(shot); + _enemyShots.Remove(shot); + _allShots.Remove(shot); + _container.RemoveChild(shot); } + } - public static void reset() + public static void reset() + { + for(int i = _allShots.Count - 1; i>=0; --i) { - for(int i = _allShots.Count - 1; i>=0; --i) - { - ShotManager.removeShot( _allShots[i] ); - } - _container = null; + ShotManager.removeShot( _allShots[i] ); } - - public static List allShots() - { - return _allShots; - } + _container = null; + } + + public static List allShots() + { + return _allShots; + } public static List enemyShots() { diff --git a/Assets/Scripts/TestLevel.cs b/Assets/Scripts/TestLevel.cs index 5479909..0d4491b 100644 --- a/Assets/Scripts/TestLevel.cs +++ b/Assets/Scripts/TestLevel.cs @@ -2,8 +2,14 @@ using System.Collections; public class TestLevel : Level { - public TestLevel( GamePage _gamepage ) : base( _gamepage ) - { - setBackground("background_1"); - } -} \ No newline at end of file + public TestLevel( GamePage _gamepage ) : base( _gamepage ) + { + setBackground("background_1"); + this._eventQueue.Enqueue( new LevelEvent(5.0f, "enemy1", Futile.screen.halfWidth, -15.0f) ); + this._eventQueue.Enqueue( new LevelEvent(5.0f, "enemy1", Futile.screen.halfWidth, 15.0f) ); + this._eventQueue.Enqueue( new LevelEvent(1.0f, "boss1", Futile.screen.halfWidth, 0.0f) ); + this._eventQueue.Enqueue( new LevelEvent(10.0f, "enemy1", Futile.screen.halfWidth, 0.0f) ); + this._eventQueue.Enqueue( new LevelEvent(10.0f, "enemy1", Futile.screen.halfWidth, 0.0f) ); + this._eventQueue.Enqueue( new LevelEvent(15.0f, "boss1", Futile.screen.halfWidth, 0.0f) ); + } +} diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 1777c1c..f96f2ba 100644 Binary files a/ProjectSettings/ProjectSettings.asset and b/ProjectSettings/ProjectSettings.asset differ