/// <summary> /// Creates a new action for the given creature with the given parameters and cost. /// </summary> /// <param name="type">An ActionType enumeration entry describing the type of the action.</param> /// <param name="param">An ActionParameters object.</param> /// <param name="subject">The subject, which actually performs the action.</param> /// <param name="cost">The cost of the action.</param> public Action(ActionType type, ActionParameters param, Creature subject, double cost) { this.Type = type; this.Subject = subject; this.Cost = cost; //Check if correct parameters switch (Type) { case ActionType.Move: if (param.GetType() != typeof(MovementActionParameters)) throw new Exception("Tried to construct Action of type MOVE, but parameters are not MovementActionParameters!"); break; case ActionType.Take: if (param.GetType() != typeof(TakeActionParameters)) throw new Exception("Tried to construct Action of type TAKE, but parameters are not TakeActionParameters!"); break; case ActionType.Equip: if (param.GetType() != typeof(EquipActionParameters)) throw new Exception("Tried to construct Action of type EQUIP, but parameters are not EquipActionParameters!"); break; case ActionType.Unequip: if (param.GetType() != typeof(UnequipActionParameters)) throw new Exception("Tried to construct Action of type UNEQUIP, but parameters are not UnequipActionParameters!"); break; } this.Param = param; }