-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3eee071
commit c6d8abf
Showing
6 changed files
with
87 additions
and
56 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Nez; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FlappyNez.Entities | ||
{ | ||
class TimedEvent : Entity | ||
{ | ||
float _previousRefreshTime = -0f; | ||
float _refreshTime; | ||
|
||
public event EventHandler Interval; | ||
|
||
public TimedEvent(float refreshTime) : base("TimedEvent") | ||
{ | ||
_refreshTime = refreshTime; | ||
} | ||
|
||
public override void onAddedToScene() | ||
{ | ||
base.onAddedToScene(); | ||
OnInterval(new EventArgs()); | ||
} | ||
|
||
public override void update() | ||
{ | ||
base.update(); | ||
|
||
if (Time.time - _previousRefreshTime > _refreshTime) | ||
{ | ||
_previousRefreshTime = Time.time; | ||
|
||
OnInterval(new EventArgs( /* roba */ )); | ||
} | ||
} | ||
|
||
protected virtual void OnInterval(EventArgs e) | ||
{ | ||
EventHandler handler = Interval; | ||
|
||
if (handler != null) | ||
{ | ||
handler(this, e); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using Microsoft.Xna.Framework; | ||
using Nez; | ||
using Nez.Sprites; | ||
using Microsoft.Xna.Framework.Input; | ||
using Microsoft.Xna.Framework.Graphics; | ||
using FlappyNez.Entities; | ||
|
||
namespace FlappyNez.Factories | ||
{ | ||
class RockFactory | ||
{ | ||
Scene _scene; | ||
|
||
public RockFactory(Scene scene) | ||
{ | ||
_scene = scene; | ||
} | ||
|
||
public void CreateRocks(object sender, EventArgs e) | ||
{ | ||
_scene.addEntity(new Rock()); | ||
_scene.addEntity(new Rock(false)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters