public SpriteBox(Color color, Sprite sprite) { m_sprite = sprite; Color = color; Location = new Rectangle( m_sprite.box.X, m_sprite.box.Y, m_sprite.box.Width - 1, m_sprite.box.Height - 1 ); m_center = new Point( Location.X + (Location.Width + 1) / 2 - m_sprite.offset.X, Location.Y + (Location.Height + 1) / 2 - m_sprite.offset.Y); m_shootPoint = new Point( Location.X + (Location.Width + 1) / 2 - m_sprite.shootPoint.X, Location.Y + (Location.Height + 1) / 2 - m_sprite.shootPoint.Y); }
static void Main(string[] args) { try { ActionInfoAttack ai = new ActionInfoAttack(); ai.location = new Rectangle(0, 0, 20, 20); Sprite sprite = new Sprite(); sprite.action = new AActionInfo[1]; sprite.action[0] = ai; // demonstration versions // note these are total nonsense /* {"accuracy", 0.5f}, // (# hit) / (# fired) {"shots", 100f}, // total shots fired {"damageTaken", 10f}, // total damage taken {"damageDone", 8f}, // total damage inflicted to enemies {"roomsExplored", 0.5f}, // % of total space explored {"roomsVisited", 10f} // total rooms entered */ PlayerModel testModel = new PlayerModel(); List<string> explorativityList = new List<string>() { "roomsExplored", "30", "*", "roomsVisited", "+" }; ModelFormula explorativityForm = new ModelFormula(explorativityList); float explorativityVal = explorativityForm.evalFormula(testModel.getAllStats()); List<string> killativityList = new List<string>() { "damageTaken", "0.5", "*", "damageDone", "2.0", "*", "-", "accuracy", "30", "*", "shots", "+", "+" }; ModelFormula killativityForm = new ModelFormula(killativityList); float killativityVal = killativityForm.evalFormula(testModel.getAllStats()); ModelFormula formA = new ModelFormula("postfix", "25+22+*"); object test = killativityForm; object testData = sprite; /* Dictionary<string, float> testDict = new Dictionary<string, float>() { {"a", 100}, {"b", 150} }; ModelFormula formA = new ModelFormula("postfix", "2a+22+*"); string testStrApre = formA.PrefixString(); string testStrApost = formA.PostfixString(); float testValA = formA.evalFormula(testDict); ModelFormula formB = new ModelFormula("prefix", "+2*3^25"); string testStrBpre = formA.PrefixString(); string testStrBpost = formA.PostfixString(); float testValB = formB.evalFormula(testDict); object test = formA; */ /* DecorationSetInfo testData = new DecorationSetInfo(); testData.assetPath = "Sprites/trees"; testData.decorations = new Dictionary<string, DecorationInfo>(); DecorationInfo di = new DecorationInfo(); testData.decorations.Add("forest", di); * */ /* CharacterInfo testData = new CharacterInfo(); testData.animationDataPath = @"Animation/Data/mask"; testData.animationTexturePath = @"Animation/Sprites/mask"; testData.collisionBox = new Rectangle(-14, 22, 28, 10); testData.speed = 5; */ /* TileSet testData = new TileSet(15); testData.assetPath = "Sprites/grassRock"; testData.tileWidth = 40; testData.tileHeight = 40; testData.tileInfos[0].passable = true; testData.tileInfos[1].passable = true; testData.tileInfos[2].passable = true; testData.tileInfos[12].passable = true; testData.columnsOnSpritesheet = 5; */ /* PropAnimSet pas = new PropAnimSet(); pas.props.Add("frameHeight", "32"); pas.props.Add("frameWidth", "23"); pas.props.Add("duration", "5"); pas.anims.Add(new PropAnim("right", 2)); pas.anims.Add(new PropAnim("left", 2)); pas.anims.Add(new PropAnim("up", 2)); pas.anims.Add(new PropAnim("down", 2)); pas.anims.Add(new PropAnim("upright", 2)); pas.anims.Add(new PropAnim("downleft", 2)); pas.anims.Add(new PropAnim("upleft", 2)); pas.anims.Add(new PropAnim("downright", 2)); Object testData = pas; */ /* AnimationSet testData = new AnimationSet(); testData.anims = new List<Animation>(); Animation walk = new Animation("walk", 2, 1, true, 0, "idle"); walk.frames[0] = new Frame(); walk.frames[0].box = new Rectangle(0, 0, 23, 32); walk.frames[0].duration = 2; walk.frames[0].trigger = ""; walk.frames[1] = new Frame(); walk.frames[1].box = new Rectangle(23, 0, 23, 32); walk.frames[1].duration = 2; walk.frames[1].trigger = ""; Animation run = new Animation("run", 2, 1, true, 0, "idle"); run.frames[0] = new Frame(); run.frames[0].box = new Rectangle(0, 33, 23, 32); run.frames[0].duration = 2; run.frames[0].trigger = ""; run.frames[1] = new Frame(); run.frames[1].box = new Rectangle(23, 33, 23, 32); run.frames[1].duration = 2; run.frames[1].trigger = ""; testData.anims.Add(walk); testData.anims.Add(run); * */ XnaSerialize(test); } catch (System.IO.FileNotFoundException fex) { //fex.Data; int a = 7; } }
public SpriteBox(Color color, Rectangle location) { m_sprite = new Sprite(); m_sprite.duration = 1; Color = color; Location = location; Center = new Point( Location.X + (Location.Width+1)/2, Location.Y + (Location.Height+1)/2); ShootPoint = new Point( Location.X + (Location.Width + 1) / 2 - 5, Location.Y + (Location.Height + 1) / 2 - 5); }