Permalink
Browse files

all attribute data now loads from file correctly

  • Loading branch information...
1 parent cce25ab commit e3d9b854173015d205c84119ed69cb685607f4c5 unknown committed May 2, 2012
View
BIN dist/Mutation.swf
Binary file not shown.
View
23 resources/xml/foods.xml
@@ -2,8 +2,8 @@
<!--
//////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// This File //////////////////////////////////
- XML data for the hats; embedded into the SWF file; but could be loaded at runtime with few tweaks
- Allows easy changes to each type of hat, and addition of new types by simply listing them here
+ XML data for the foods; embedded into the SWF file; but could be loaded at runtime with few tweaks
+ Allows easy changes to each type of food, and addition of new types by simply listing them here
Uncomplete data will corrupt the program, as will bad syntax - there is no eror checking on this
///////////////////////////////////////////////////////////////////////////////////////////
@@ -18,14 +18,17 @@
<debrisCount> 3 </debrisCount> // Number of pieces of debris poduced when eaten
<debrisType> 0 </debrisType> // Type of debris (by food ID) produced when eaten
</food>
+
+ NB: Any food ID can be utilised for the debrisType, but it is recommended that a new specific
+ food is created as a debris; otherwise each particle will in turn, create debris
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
-->
<!-- Start of Actual File Data -->
<data>
- <!-- Starter Food -->
+ <!-- Basic Debris -->
<food>
<id> 0 </id>
<name> DEBRIS </name>
@@ -35,8 +38,13 @@
<foodAmount> 50 </foodAmount>
<debrisCount> 0 </debrisCount>
<debrisType> 0 </debrisType>
+ <unlock>
+ <unlocked> 1 </unlocked>
+ <cost> 0 </cost>
+ </unlock>
</food>
+ <!-- Starter Food -->
<food>
<id> 0 </id>
<name> BASIC </name>
@@ -46,6 +54,10 @@
<foodAmount> 100 </foodAmount>
<debrisCount> 3 </debrisCount>
<debrisType> 0 </debrisType>
+ <unlock>
+ <unlocked> 1 </unlocked>
+ <cost> 0 </cost>
+ </unlock>
</food>
<!-- High Explosive Food -->
@@ -54,9 +66,14 @@
<name> DOUBLE </name>
<graphic> 0 </graphic>
<radius> 6 </radius>
+ <life> 0.5 </life>
<foodAmount> 100 </foodAmount>
<debrisCount> 10 </debrisCount>
<debrisType> 0 </debrisType>
+ <unlock>
+ <unlocked> 1 </unlocked>
+ <cost> 0 </cost>
+ </unlock>
</food>
</data>
View
33 resources/xml/hats.xml
@@ -37,52 +37,53 @@
<!-- Basic Explorer hat -->
<hat>
<id> 0 </id>
- <name> EXPLORER</name>
+ <name> EXPLORE </name>
<graphic> 0 </graphic>
- <unlock>
- <default> true </default>
- <cost> 0 </cost>
- </unlock>
<stats>
<foodRate> 1 </foodRate>
<foodAmount> 1 </foodAmount>
<moneyRate> 1 </moneyRate>
<moneyAmount> 1 </moneyAmount>
- </stats>
+ </stats>
+ <unlock>
+ <unlocked> 1 </unlocked>
+ <cost> 0 </cost>
+ </unlock>
</hat>
<!-- Pirate hat -->
<hat>
<id> 1 </id>
<name> PIRATE </name>
<graphic> 1 </graphic>
- <unlock>
- <default> true </default>
- <cost> 0 </cost>
- </unlock>
<stats>
<foodRate> 1 </foodRate>
<foodAmount> 1 </foodAmount>
<moneyRate> 1.1 </moneyRate>
<moneyAmount> 1.2 </moneyAmount>
- </stats>
+ </stats>
+ <unlock>
+ <unlocked> 1 </unlocked>
+ <cost> 0 </cost>
+ </unlock>
</hat>
<!-- Pretty Purple Women's hat -->
<hat>
<id> 2 </id>
<name> PRETTY </name>
<graphic> 2 </graphic>
- <unlock>
- <default> true </default>
- <cost> 0 </cost>
- </unlock>
<stats>
<foodRate> 1 </foodRate>
<foodAmount> 1 </foodAmount>
<moneyRate> 0.1 </moneyRate>
<moneyAmount> 2 </moneyAmount>
- </stats>
+ </stats>
+ <unlock>
+ <unlocked> 1 </unlocked>
+ <cost> 0 </cost>
+ </unlock>
</hat>
+
</data>
View
45 resources/xml/items.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ //////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////// This File //////////////////////////////////
+ XML data for the foods; embedded into the SWF file; but could be loaded at runtime with few tweaks
+ Allows easy changes to each type of food, and addition of new types by simply listing them here
+ Uncomplete data will corrupt the program, as will bad syntax - there is no eror checking on this
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////// Data Layout //////////////////////////////////
+ <food>
+ <id> 0 </id>
+ <name> BASIC </name> // Name of this Food presented to the player
+ <graphic> 0 </graphic> // Graphic to use from Resources.as
+ <radius> 4 </radius> // Size as a radius to be drawn, and for collisions
+ <life> 4 </life> // Time in seconds it will remain, before it dissapears
+ <foodAmount> 100 </foodAmount> // Amount of food it provides when eaten
+ <debrisCount> 3 </debrisCount> // Number of pieces of debris poduced when eaten
+ <debrisType> 0 </debrisType> // Type of debris (by food ID) produced when eaten
+ </food>
+
+ NB: Any food ID can be utilised for the debrisType, but it is recommended that a new specific
+ food is created as a debris; otherwise each particle will in turn, create debris
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+-->
+
+<!-- Start of Actual File Data -->
+<data>
+
+ <!-- Silver Coins -->
+ <item>
+ <id> 0 </id>
+ <name> SILVER </name>
+ <graphic> 0 </graphic>
+ <radius> 3 </radius>
+ <life> 3 </life>
+ <money> 330 </money>
+ <unlock>
+ <unlocked> 1 </unlocked>
+ <cost> 0 </cost>
+ </unlock>
+ </item>
+
+</data>
View
31 resources/xml/levels.xml
@@ -2,10 +2,15 @@
<!--
//////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// This File //////////////////////////////////
-
+ Contains the levelling data for how the bacteria to level up. Allows for simple editing of
+ this data, without chaging the source files.
+ Currently the project needs recompiled each time, as these files are embedded, not loaded.
+ In future, it would be best to load them from file - but this causes issues on some machines.
+ Warning: There is no error or syntax checking on this. Bad data will corrupt the application.
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// Data Layout //////////////////////////////////
+ Each level data is layed out on it's own line, so it is easy to see patterns of progression.
<level><e> 200 </e><f> 1 </f><m> 1 </m></level>
Symbols:
@@ -19,16 +24,18 @@
<!-- Start of Actual File Data -->
<data>
- <level><e> 200 </e><f> 1 </f><m> 1 </m></level>
- <level><e> 200 </e><f> 1 </f><m> 1 </m></level>
- <level><e> 200 </e><f> 1 </f><m> 1 </m></level>
- <level><e> 200 </e><f> 1 </f><m> 1 </m></level>
- <level><e> 200 </e><f> 1 </f><m> 1 </m></level>
-
- <level><e> 200 </e><f> 1 </f><m> 1 </m></level>
- <level><e> 200 </e><f> 1 </f><m> 1 </m></level>
- <level><e> 200 </e><f> 1 </f><m> 1 </m></level>
- <level><e> 200 </e><f> 1 </f><m> 1 </m></level>
- <level><e> 200 </e><f> 1 </f><m> 1 </m></level>
+ <!-----------EXP-----------FOOD--------MONEY--------->
+ <level><e> 0 </e><f> 1 </f><m> 1 </m></level>
+ <level><e> 200 </e><f> 1 </f><m> 1.1 </m></level>
+ <level><e> 400 </e><f> 1 </f><m> 1.1 </m></level>
+ <level><e> 600 </e><f> 1 </f><m> 1.1 </m></level>
+ <level><e> 800 </e><f> 1 </f><m> 1.1 </m></level>
+ <!-----------EXP-----------FOOD--------MONEY--------->
+ <level><e> 1000 </e><f> 1 </f><m> 1.2 </m></level>
+ <level><e> 1500 </e><f> 1 </f><m> 1.2 </m></level>
+ <level><e> 1600 </e><f> 1 </f><m> 1.2 </m></level>
+ <level><e> 1800 </e><f> 1 </f><m> 1.2 </m></level>
+ <level><e> 2000 </e><f> 1 </f><m> 1.2 </m></level>
+ <!-----------EXP-----------FOOD--------MONEY--------->
</data>
View
58 src/mutation/Game.as
@@ -1,12 +1,66 @@
package mutation
{
+ import mutation.entity.foods.FoodDescriptor;
+ import mutation.entity.hats.HatDescriptor;
+ import mutation.entity.items.Item;
+ import mutation.entity.items.ItemDescriptor;
+ import mutation.entity.levelling.Level;
+ import mutation.util.Resources;
public class Game
{
+ public static var hats:Vector.<HatDescriptor> = new Vector.<HatDescriptor>();
+ public static var foods:Vector.<FoodDescriptor> = new Vector.<FoodDescriptor>();
+ public static var items:Vector.<ItemDescriptor> = new Vector.<ItemDescriptor>();
+ public static var levels:Vector.<Level> = new Vector.<Level>();
- public function Game()
+ public static var selectedFood:Number = 1;
+
+ public function Game();
+
+ // Initialises the game
+ public static function init():void
+ {
+ initHats(Resources.getXML(Resources.XML_HATS));
+ initFoods(Resources.getXML(Resources.XML_FOODS));
+ initItems(Resources.getXML(Resources.XML_ITEMS));
+ initLevels(Resources.getXML(Resources.XML_LEVELS));
+ }
+
+ // Loads the Hats data from XML
+ private static function initHats(xml:XML):void
+ {
+ var hatList:XMLList = xml.hat;
+ for each (var hatXML:XML in hatList) {
+ hats.push( new HatDescriptor(hatXML) );
+ }
+ }
+
+ // Loads the Food data from XML
+ private static function initFoods(xml:XML):void
+ {
+ var foodList:XMLList = xml.food;
+ for each (var foodXML:XML in foodList) {
+ foods.push( new FoodDescriptor(foodXML) );
+ }
+ }
+
+ // Loads the Items data from XML
+ private static function initItems(xml:XML):void
+ {
+ var itemList:XMLList = xml.item;
+ for each (var itemXML:XML in itemList) {
+ items.push( new ItemDescriptor(itemXML) );
+ }
+ }
+
+ // Loads the level (experience level) data from XML
+ private static function initLevels(xml:XML):void
{
-
+ var levelList:XMLList = xml.level;
+ for each (var levelXML:XML in levelList) {
+ levels.push( new Level(levelXML) );
+ }
}
}
View
9 src/mutation/Main.as
@@ -19,10 +19,10 @@ package mutation
import mutation.container.Background;
import mutation.entity.Bacteria;
import mutation.entity.foods.Food;
- import mutation.entity.foods.Foods;
import mutation.events.BacteriaEvent;
import mutation.ui.Button;
import mutation.ui.NameBacteriaDisplay;
+ import mutation.util.Resources;
import mutation.events.MutationEvent;
import mutation.entity.TestTube;
@@ -59,6 +59,8 @@ package mutation
// Initialisation once the stage is created
private function onInit(e:Event = null):void
{
+ Game.init();
+
testTube = new TestTube(125, 200, 100);
moneyOut = new TextField();
collectedOut = new TextField();
@@ -69,6 +71,7 @@ package mutation
Keys.init(stage);
+
var format:TextFormat = new TextFormat();
format.size = 48;
format.font = "Calibri";
@@ -153,8 +156,8 @@ package mutation
private function onFoodUpgrade(e:ButtonEvent):void
{
if (money >= FOOD_UPGRADE_COST) {
- Foods.selectedFood++;
- if (Foods.selectedFood > (Foods.foods.length - 1)) Foods.selectedFood = Foods.foods.length - 1;
+ Game.selectedFood++;
+ if (Game.selectedFood > (Game.foods.length - 1)) Game.selectedFood = Game.foods.length - 1;
money -= FOOD_UPGRADE_COST;
}
}
View
11 src/mutation/entity/Bacteria.as
@@ -16,12 +16,13 @@ package mutation.entity
import flash.text.TextField;
import flash.text.TextFormat;
import flash.ui.Mouse;
- import mutation.entity.hats.Hats;
import mutation.entity.items.Item;
+ import mutation.entity.levelling.Leveling;
+ import mutation.Game;
+ import mutation.util.Resources;
import mutation.entity.hats.Hat;
import mutation.entity.levelling.Level;
- import mutation.entity.levelling.SimpleLeveling;
import mutation.events.BacteriaEvent;
import mutation.events.ItemEvent;
import mutation.events.MutationEvent;
@@ -51,7 +52,7 @@ package mutation.entity
public var nameString:String;
public var food:Resource;
public var money:Resource;
- public var level:SimpleLeveling = new SimpleLeveling();
+ public var level:Leveling = new Leveling(Resources.getXML(Resources.XML_LEVELS));
public var moneyType:Class;
public var target:Sprite;
@@ -75,7 +76,7 @@ package mutation.entity
if (hat != null) {
this.hat = hat;
}else {
- this.hat = new Hat(Hats.PIRATE);
+ this.hat = new Hat(Game.hats[0]);
}
addChild(this.hat);
@@ -114,7 +115,7 @@ package mutation.entity
}
if (money.isFilled()) {
- dispatchEvent(new ItemEvent(ItemEvent.PRODUCE, new Item(x,y, money.amount), true));
+ dispatchEvent(new ItemEvent(ItemEvent.PRODUCE, new Item(x,y, Game.items[0], money.amount), true));
money.amount = 0;
}
View
10 src/mutation/entity/TestTube.as
@@ -14,11 +14,11 @@ package mutation.entity
import flash.ui.Mouse;
import mutation.entity.items.Item;
import mutation.entity.foods.Food;
- import mutation.entity.foods.Foods;
import mutation.events.ItemEvent;
import mutation.events.MutationEvent;
import mutation.events.BacteriaEvent;
import mutation.events.FoodEvent;
+ import mutation.Game;
import mutation.Main;
import mutation.ui.BacteriaDisplay;
import mutation.ui.NameBacteriaDisplay;
@@ -86,7 +86,7 @@ package mutation.entity
private function updateItems():void
{
for each (var i:Item in items) {
- if ( !(Util.inRadius(i.x, i.y, radius - i.radius)) ){
+ if ( !(Util.inRadius(i.x, i.y, radius - i.type.radius)) ){
i.ySpeed *= -0.5;
i.xSpeed *= -0.5;
// Abuse the inRadius function to check if the combined speed is in range 0->1
@@ -95,7 +95,7 @@ package mutation.entity
if (i.flagIsClicked) {
this.flagIsClicked = false;
- Main.collect(i.money);
+ Main.collect(i.getMoney());
i.kill();
}
i.flagIsClicked = false;
@@ -181,7 +181,7 @@ package mutation.entity
// Ensure it is in radius of the testTube
if (Util.inRadius(x, y, radius)) {
if (Main.money >= cost){
- var food:Food = new Food(x, y, Foods.foods[Foods.selectedFood]);
+ var food:Food = new Food(x, y, Game.foods[Game.selectedFood]);
foods.push(food);
addChild(food);
Main.money -= cost;
@@ -197,7 +197,7 @@ package mutation.entity
if (e.food.type.debrisType > -1) {
for (var i:int = 0; i < e.food.type.debrisCount; ++i) {
- var debris:Food = new Food(e.food.x, e.food.y, Foods.foods[e.food.type.debrisType]);
+ var debris:Food = new Food(e.food.x, e.food.y, Game.foods[e.food.type.debrisType]);
debris.xSpeed = e.food.xSpeed - (Math.random() - 0.5);
debris.ySpeed = e.food.ySpeed - 3*(Math.random());
foods.push(debris);
View
5 src/mutation/entity/foods/Food.as
@@ -31,14 +31,15 @@ package mutation.entity.foods
{
super();
+ type = foodType;
this.x = x;
this.y = y;
xSpeed = 0;
ySpeed = 0;
- life = 5 * 30;
+ life = type.startingLife * 30;
flagIsMoving = true;
- type = foodType;
+
draw();
if (stage) onInit();
View
7 src/mutation/entity/foods/FoodDescriptor.as
@@ -10,12 +10,19 @@ package mutation.entity.foods
public var debrisType:int;
public var startingLife:int;
+ public var isUnlocked:Boolean;
+ public var unlockCost:Number;
+
public function FoodDescriptor(xml:XML)
{
this.radius = xml.radius;
this.foodAmount = xml.foodAmount;
this.debrisType = xml.debrisType;
this.debrisCount = xml.debrisCount;
+ this.startingLife = xml.life;
+
+ isUnlocked = xml.unlock.unlocked;
+ unlockCost = xml.unlock.cost;
}
}
View
24 src/mutation/entity/foods/Foods.as
@@ -1,24 +0,0 @@
-package mutation.entity.foods
-{
- import mutation.util.Resources;
-
- // Static, temporary holding for the different types of Food types available
- // Should be replaced with a runtime array of hats available; allowing easy changes by changing the XML
- public class Foods
- {
- public static const DEBRIS:FoodDescriptor = new FoodDescriptor((Resources.getXML(Resources.XML_FOODS).food[0]));
- public static const BASIC:FoodDescriptor = new FoodDescriptor((Resources.getXML(Resources.XML_FOODS).food[1]));
- public static const DOUBLE:FoodDescriptor = new FoodDescriptor((Resources.getXML(Resources.XML_FOODS).food[2]));
-
- public static var selectedFood:int = 1;
-
- public static const foods:Vector.<FoodDescriptor> = new <FoodDescriptor>[
- DEBRIS,
- BASIC,
- DOUBLE
- ];
-
- public function Foods();
- }
-
-}
View
16 src/mutation/entity/hats/HatDescriptor.as
@@ -13,19 +13,23 @@ package mutation.entity.hats
public var foodAmountScale:Number; // Factor for the amount of food the bacteria can hold
public var moneyAmountScale:Number; // Factor for the amount of money the bacteria can hold
public var moneyRateScale:Number; // Factor for the rate the money is created at
+
public var isUnlocked:Boolean; // True if it is unlocked/useable by default
public var unlockCost:Boolean; // Cost to unlock it (if it is not unlocked)
// Creates a new HatDescriptor from the XML input
// XML input expected to be just the XML for this hat node; not the entire file
public function HatDescriptor(xml:XML)
{
- bitmapIndex = xml.graphic;
- var stats:XMLList = xml.stats;
- foodAmountScale = stats.foodAmount;
- foodRateScale = stats.foodRate;
- moneyAmountScale = stats.moneyAmount;
- moneyRateScale = stats.moneyRate;
+ bitmapIndex = xml.graphic;
+ var stats:XMLList = xml.stats;
+ foodAmountScale = stats.foodAmount;
+ foodRateScale = stats.foodRate;
+ moneyAmountScale = stats.moneyAmount;
+ moneyRateScale = stats.moneyRate;
+
+ isUnlocked = xml.unlock.unlocked;
+ unlockCost = xml.unlock.cost;
}
}
View
16 src/mutation/entity/hats/Hats.as
@@ -1,16 +0,0 @@
-package mutation.entity.hats
-{
- import mutation.util.Resources;
-
- // Static, temporary holding for the different types of Hat available
- // Should be replaced with a runtime array of hats available; allowing easy changes by changing the XML
- public class Hats
- {
- public static const EXPLORER:HatDescriptor = new HatDescriptor((Resources.getXML(Resources.XML_HATS)).hat[0]);
- public static const PIRATE:HatDescriptor = new HatDescriptor((Resources.getXML(Resources.XML_HATS)).hat[1]);
- public static const PRETTY:HatDescriptor = new HatDescriptor((Resources.getXML(Resources.XML_HATS)).hat[2]);
-
- public function Hats();
- }
-
-}
View
19 src/mutation/entity/items/Item.as
@@ -15,23 +15,24 @@ package mutation.entity.items
public var ySpeed:Number;
public var life:Number;
- public var radius:Number;
- public var money:Number;
+ public var amount:Number = 0;
+
+ public var type:ItemDescriptor;
public var flagIsMoving:Boolean = true;
public var flagIsClicked:Boolean = false;
public var flagIsAlive:Boolean = true;
// Constructor: default
- public function Item(x:Number, y:Number, amount:Number = 100)
+ public function Item(x:Number, y:Number, itemType:ItemDescriptor, money:Number = 0 )
{
+ type = itemType;
this.x = x;
this.y = y;
xSpeed = 0;
ySpeed = 0;
- life = 8 * 30;
- radius = 4 * (amount/100);
- money = amount;
+ life = type.startingLife * 30;
+ this.amount = money;
draw();
@@ -46,6 +47,10 @@ package mutation.entity.items
addEventListener(MouseEvent.CLICK, onClick);
}
+ public function getMoney():Number
+ {
+ return (type.money + amount);
+ }
// OnTick Updates
public function onTick(e:MutationEvent):void {
@@ -83,7 +88,7 @@ package mutation.entity.items
// Draw the graphics representation
private function draw():void {
graphics.beginFill(0xFFAA33);
- graphics.drawCircle(0, 0, radius);
+ graphics.drawCircle(0, 0, type.radius * ((type.money + amount)/type.money));
graphics.endFill();
}
View
25 src/mutation/entity/items/ItemDescriptor.as
@@ -0,0 +1,25 @@
+package mutation.entity.items
+{
+
+ public class ItemDescriptor
+ {
+ public var radius:Number;
+ public var money:Number;
+ public var startingLife:Number;
+
+ public var isUnlocked:Boolean;
+ public var unlockCost:Number;
+
+ public function ItemDescriptor(xml:XML)
+ {
+ radius = xml.radius;
+ money = xml.money;
+ startingLife = xml.life;
+ isUnlocked = xml.unlock.unlocked;
+ unlockCost = xml.unlock.cost;
+
+ }
+
+ }
+
+}
View
13 src/mutation/entity/levelling/Level.as
@@ -13,13 +13,14 @@ package mutation.entity.levelling
public var visual:Sprite; // New visual appearance, or null if the appearance won't change this level
// Users of this class must check for moneyType and visual being null; indicating they aren't to change
- public function Level(exp:Number, food:Number, money:Number, moneyTypeChange:Class = null, visualChange:Sprite = null)
+ // the XML data used is the XML of a specific <Level></Level> tag; not the entire file.
+ public function Level(xml:XML)
{
- experienceNeeded = exp;
- foodScale = food;
- moneyScale = money;
- moneyType = moneyTypeChange;
- visual = visualChange;
+ experienceNeeded = xml.e;
+ foodScale = xml.f;
+ moneyScale = xml.m;
+ moneyType = null;
+ visual = null;
}
// Returns true if the level can be obtained with the given amount of exp
View
17 src/mutation/entity/levelling/Leveling.as
@@ -1,40 +1,39 @@
package mutation.entity.levelling
{
+ import mutation.Game;
// Levelling component for bacteria experience
public class Leveling
{
- private var levels:Vector.<Level> = null; // The amount of exp needed to progress for each level
- public var level:Number = 1; // The current level
- public var experience:Number = 0; // The current amount of experience, resets each level
- private var hasLevelledThisTick:Boolean = false; // True if it has levelled in this tick
+ public var level:Number = 1; // The current level
+ public var experience:Number = 0; // The current amount of experience, resets each level
+ private var hasLevelledThisTick:Boolean = false; // True if it has levelled in this tick
// Base class constructor
- public function Leveling(levelsVector:Vector.<Level>)
+ public function Leveling(xml:XML)
{
- this.levels = levelsVector;
}
// Updates the levelling system with the given amount of exp
public function update(exp:Number):void
{
hasLevelledThisTick = false;
experience += exp;
- if (levels[level].canLevel(experience)) {
+ if (Game.levels[level].canLevel(experience)) {
nextLevel();
}
}
// Returns the current level for the bacteria to update with
public function getLevel():Level
{
- return (levels[level]);
+ return (Game.levels[level]);
}
// Called whenever the object gets to the next level
private function nextLevel():void
{
- if (level < (levels.length-1)){
+ if (level < (Game.levels.length-1)){
hasLevelledThisTick = true;
level++;
experience = 0;
View
22 src/mutation/entity/levelling/SimpleLeveling.as
@@ -1,22 +0,0 @@
-package mutation.entity.levelling
-{
-
- // Simple levelling used for the Bacteria
- // Should be refactored into XML
- public class SimpleLeveling extends Leveling
- {
- public function SimpleLeveling()
- {
- super(
- new <Level>[
- new Level(200, 0.999, 1),
- new Level(400, 0.999, 1),
- new Level(600, 0.999, 1),
- new Level(800, 0.999, 1),
- new Level(1000, 0.999, 1),
- ]
- );
- }
- }
-
-}
View
22 src/mutation/ui/HatSelector.as
@@ -5,37 +5,31 @@ package mutation.ui
import flash.events.MouseEvent;
import mutation.entity.hats.Hat;
import mutation.entity.hats.HatDescriptor;
- import mutation.entity.hats.Hats;
+ import mutation.Game;
import mx.core.SpriteAsset;
+ // Very temporary - don't think twice before refactoring this into something more generic
public class HatSelector extends Sprite
- {
- private static const HAT_TYPES:Array = [
- Hats.EXPLORER,
- Hats.PIRATE,
- Hats.PRETTY
- ];
-
+ {
private var selectedHat:Number = 0;
private var leftArrow:Sprite;
private var rightArrow:Sprite;
private var hat:Hat;
-
public function HatSelector()
{
super();
leftArrow = new Sprite();
rightArrow = new Sprite();
- hat = new Hat(HAT_TYPES[selectedHat]);
+ hat = new Hat(Game.hats[selectedHat]);
if (stage) onInit();
else addEventListener(Event.ADDED_TO_STAGE, onInit);
}
public function getHatDescriptor():HatDescriptor
{
- return HAT_TYPES[selectedHat];
+ return Game.hats[selectedHat];
}
private function onInit(e:Event = null):void
@@ -65,15 +59,15 @@ package mutation.ui
{
selectedHat--;
if (selectedHat < 0) {
- selectedHat = HAT_TYPES.length-1;
+ selectedHat = Game.hats.length-1;
}
drawHat();
}
private function onRight(e:MouseEvent):void
{
selectedHat++;
- if (selectedHat > (HAT_TYPES.length - 1)) {
+ if (selectedHat > (Game.hats.length - 1)) {
selectedHat = 0;
}
drawHat();
@@ -82,7 +76,7 @@ package mutation.ui
private function drawHat():void
{
removeChild(hat);
- hat = new Hat(HAT_TYPES[selectedHat]);
+ hat = new Hat(Game.hats[selectedHat]);
addChild(hat);
hat.x = 50;
hat.scaleX = 3;
View
7 src/mutation/util/Resources.as
@@ -34,6 +34,9 @@ package mutation.util
[Embed(source = "../../../resources/xml/foods.xml", mimeType="application/octet-stream")]
public static const XML_FOODS:Class;
+ [Embed(source="../../../resources/xml/items.xml", mimeType="application/octet-stream")]
+ public static const XML_ITEMS:Class;
+
// Returns the XML from an embedded octet-stream (XML).
// This is a workaround to a bug in the AS3 compiler, that tries to compile XML files.
public static function getXML(embeddedXML:Class):XML
@@ -47,9 +50,7 @@ package mutation.util
//////////////////////////////////////////////////
// END OF RESOURCES LISTING
////////////////////////////////////////////////
- public function Resources()
- {
- }
+ public function Resources();
}

0 comments on commit e3d9b85

Please sign in to comment.