// TODO: Get cost of unit // TODO: Get player resources // TODO: Get buildtime of the unit private Queue <Command> evaluateAdd(Command req, RuleBook rules, Player player, TimeSpan time) { // Decorate the command Command add = new AddDecorator(req); // Get the units parent UInt16 parent = add.ParentID; // Get its name to look up in the rule book String name = GameObjectFactory.The.getType(add.Type).Name; // Get the type evaluator from the rule book UnitEvaluation dep = rules.getDependancy(name); // Get the name of the type to add name = dep.getType(rules._unitExists); // Get UInt16 type id from name UInt16 type = GameObjectFactory.The.getType(name).ID; // TODO: Get cost of unit // TODO: Get player resources // TODO: Get buildtime of the unit Queue <Command> retval = new Queue <Command>(); Command toadd = new AddDecorator(parent, 0, type, time, new Command()); retval.Enqueue(toadd); return(retval); }
/// <summary> /// Handle a unit added command. This function should read /// the data out of the command and either: /// 1. Use it to create a new game object from the factory or /// 2. Use it to ressurect a game object from the factory /// </summary> /// <param name="addCommand"></param> protected void handleAddUnitCommand(Command cmd) { AddDecorator addCommand = new AddDecorator(cmd); Unit newUnit = createNewUnit(addCommand.UnitID, addCommand.Type, addCommand.ParentID); Unit adder = (Unit)GameObjectFactory.The.getGameObject(addCommand.ParentID); newUnit.setPosition(adder.getPosition()); units.Add(newUnit); }
/// <summary> /// Handler for the add unit button. /// </summary> /// <param name="sender">Object that triggered the event.</param> /// <param name="args">Arguments for the AddButtonClicked Event.</param> private void AddHandler(object sender, EventArgs args) { Command command; GameObjectType type = GameObjectFactory.The.getType("TestUnit"); foreach (ActiveGameObject o in _selectedObjects) { command = new AddDecorator(o.ID, 0, type.ID, new TimeSpan(), new Command()); if (NewCommandEvent != null) { NewCommandEvent.Invoke(this, new NewCommandEventArgs(command)); } } }
/// <summary> /// Handler for the add unit button. /// </summary> /// <param name="sender">Object that triggered the event.</param> /// <param name="args">Arguments for the AddButtonClicked Event.</param> private void AddHandler(object sender, EventArgs args) { Command command; GameObjectType type = GameObjectFactory.The.getType("TestUnit"); foreach (ActiveGameObject o in _selectedObjects) { command = new AddDecorator(o.ID, 0, type.ID, new TimeSpan(), new Command()); if(NewCommandEvent != null) NewCommandEvent.Invoke(this, new NewCommandEventArgs(command)); } }
/// <summary> /// Handle a unit added command. This function should read /// the data out of the command and either: /// 1. Use it to create a new game object from the factory or /// 2. Use it to ressurect a game object from the factory /// </summary> /// <param name="addCommand"></param> protected void handleAddUnitCommand(Command cmd) { AddDecorator addCommand = new AddDecorator(cmd); Unit newUnit = createNewUnit(addCommand.UnitID,addCommand.Type, addCommand.ParentID); Unit adder = (Unit)GameObjectFactory.The.getGameObject(addCommand.ParentID); newUnit.setPosition(adder.getPosition()); units.Add(newUnit); }
// TODO: Get cost of unit // TODO: Get player resources // TODO: Get buildtime of the unit private Queue<Command> evaluateAdd(Command req, RuleBook rules, Player player, TimeSpan time) { // Decorate the command Command add = new AddDecorator(req); // Get the units parent UInt16 parent = add.ParentID; // Get its name to look up in the rule book String name = GameObjectFactory.The.getType(add.Type).Name; // Get the type evaluator from the rule book UnitEvaluation dep = rules.getDependancy(name); // Get the name of the type to add name = dep.getType(rules._unitExists); // Get UInt16 type id from name UInt16 type = GameObjectFactory.The.getType(name).ID; // TODO: Get cost of unit // TODO: Get player resources // TODO: Get buildtime of the unit Queue<Command> retval = new Queue<Command>(); Command toadd = new AddDecorator(parent, 0, type, time, new Command()); retval.Enqueue(toadd); return retval; }