Commented research controller
This commit is contained in:
@@ -1,45 +1,74 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Marc de Craigher
|
||||
* @author Aaron Moser
|
||||
*
|
||||
* @package Assets.Scripts.Research.Controller
|
||||
*/
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NResearchController
|
||||
{
|
||||
/**
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* Class administrates top level of game.
|
||||
*/
|
||||
public class ResearchCostController
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to gamemodel, set by constructor.
|
||||
/// </summary>
|
||||
private GameModel oGameModel;
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public values
|
||||
|
||||
/// <summary>
|
||||
/// Reference to research cost view, set by constructor.
|
||||
/// </summary>
|
||||
private ResearchCostViewScript oResearchCostView;
|
||||
|
||||
/// <summary>
|
||||
/// Delegate of TechButtonEnterEvent.
|
||||
/// </summary>
|
||||
/**
|
||||
* Delegate of TechButtonEnterEvent.
|
||||
*
|
||||
* @param sender, object, which triggered event.
|
||||
* @param e, research event args, containing information about event.
|
||||
*/
|
||||
public delegate void TechButtonEnterHandler(object sender, NResearch.ResearchEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Event invoked if mouse/pointer enters a TechButton.
|
||||
/// </summary>
|
||||
/**
|
||||
* Event invoked if mouse/pointer enters a TechButton.
|
||||
*/
|
||||
public static event TechButtonEnterHandler TechButtonEnter;
|
||||
|
||||
/// <summary>
|
||||
/// Delegate of TechButtonExit event.
|
||||
/// </summary>
|
||||
/**
|
||||
* Delegate of TechButtonExit event.
|
||||
*
|
||||
* @param sender, object, which triggered event.
|
||||
* @param e, research event args, containing information about event.
|
||||
*/
|
||||
public delegate void TechButtonExitHandler(object sender, NResearch.ResearchEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Event invoked if mouse/pointer exits a TechButton.
|
||||
/// </summary>
|
||||
/**
|
||||
* Event invoked if mouse/pointer exits a TechButton.
|
||||
*/
|
||||
public static event TechButtonExitHandler TechButtonExit;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor of ResearchCostController, sets own gamemodel and researchcostview. Also adds methods to TechButtonEnter and TechButtonExit events.
|
||||
/// </summary>
|
||||
/// <param name="oGameModel"></param>
|
||||
/// <param name="ResearchCostView"></param>
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private values
|
||||
|
||||
/**
|
||||
* Reference to gamemodel, set by constructor.
|
||||
*/
|
||||
private GameModel oGameModel;
|
||||
|
||||
/**
|
||||
* Reference to research cost view, set by constructor.
|
||||
*/
|
||||
private ResearchCostViewScript oResearchCostView;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public functions
|
||||
|
||||
/**
|
||||
* Constructor of ResearchCostController, sets own gamemodel and researchcostview. Also adds methods to TechButtonEnter and TechButtonExit events.
|
||||
*
|
||||
* @param oGameModel, reference to game model.
|
||||
* @param ResearchCostView, reference to research cost view.
|
||||
*/
|
||||
public ResearchCostController(GameModel oGameModel, ResearchCostViewScript ResearchCostView)
|
||||
{
|
||||
this.oGameModel = oGameModel;
|
||||
@@ -50,33 +79,38 @@ namespace NResearchController
|
||||
TechButtonExit += OnTechButtonExit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when mouse/pointer enters TechButton.
|
||||
/// </summary>
|
||||
/// <param name="oSender"></param>
|
||||
/// <param name="eResearchEvent"></param>
|
||||
/**
|
||||
* Called when mouse/pointer enters TechButton.
|
||||
*
|
||||
* @param oSender, object, which triggered event.
|
||||
* @param eReasearchEvent, research event args, containing information about event.
|
||||
*/
|
||||
public static void TechButtonEnterEvent(object oSender, NResearch.EResearchEvent eResearchEvent)
|
||||
{
|
||||
TechButtonEnter?.Invoke(oSender, new NResearch.ResearchEventArgs(eResearchEvent));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when mouse/pointer exits TechButton.
|
||||
/// </summary>
|
||||
/// <param name="oSender"></param>
|
||||
/// <param name="eResearchEvent"></param>
|
||||
/**
|
||||
* Called when mouse/pointer exits TechButton.
|
||||
*
|
||||
* @param oSender, object, which triggered event.
|
||||
* @param eReasearchEvent, research event args, containing information about event.
|
||||
*/
|
||||
public static void TechButtonExitEvent(object oSender, NResearch.EResearchEvent eResearchEvent)
|
||||
{
|
||||
TechButtonExit?.Invoke(oSender, new NResearch.ResearchEventArgs(eResearchEvent));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method added to TechButtonEnter event. Depending on which tech button hovered, gets queue elements and current tech level and calculates the cost for the next upgrade.
|
||||
/// Then writes the outcome into the cost view.
|
||||
/// </summary>
|
||||
/// <param name="oSender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <exception cref="Exception"></exception>
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private functions
|
||||
|
||||
/**
|
||||
* Function added to TechButtonEnter event. Depending on which tech button hovered, gets queue elements and current tech level and calculates the cost for the next upgrade.
|
||||
* Then writes the outcome into the cost view.
|
||||
*
|
||||
* @param oSender, object, which triggered event.
|
||||
* @param e, research event args, containing information about event.
|
||||
*/
|
||||
private void OnTechButtonEnter(object oSender, NResearch.ResearchEventArgs e)
|
||||
{
|
||||
// Get research queue
|
||||
@@ -164,12 +198,13 @@ namespace NResearchController
|
||||
oResearchCostView.SetCostLabel(iCost);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets called when mouse pointer exits a tech button. Sets cost label text to 0.
|
||||
/// Parameters are not used.
|
||||
/// </summary>
|
||||
/// <param name="oSender"></param>
|
||||
/// <param name="e"></param>
|
||||
/**
|
||||
* Gets called when mouse pointer exits a tech button. Sets cost label text to 0.
|
||||
* Parameters are not used.
|
||||
*
|
||||
* @param oSender, object, which triggered event.
|
||||
* @param e, research event args, containing information about event.
|
||||
*/
|
||||
private void OnTechButtonExit(object oSender, NResearch.ResearchEventArgs e)
|
||||
{
|
||||
oResearchCostView.SetCostLabel(0);
|
||||
|
||||
@@ -1,18 +1,60 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Marc de Craigher
|
||||
* @author Aaron Moser
|
||||
*
|
||||
* @package Assets.Scripts.Research.Controller
|
||||
*/
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NResearchController
|
||||
{
|
||||
/**
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* Class administrates communication between research queue model and view.
|
||||
*/
|
||||
public class ResearchQueueController
|
||||
{
|
||||
private GameModel oGameModel;
|
||||
|
||||
private ResearchQueueViewScript oResearchQueueView;
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public values
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sender, object, which triggered event.
|
||||
* @param e, research event arguments, conataining additional information about event triggered.
|
||||
*/
|
||||
public delegate void TechRemoveButtonPressedHandler(object sender, NResearch.ResearchEventArgs e);
|
||||
|
||||
/**
|
||||
* Event handler for event when tech remove button is pressed.
|
||||
*/
|
||||
public static event TechRemoveButtonPressedHandler TechRemoveButtonPressed;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private values
|
||||
|
||||
/**
|
||||
* Reference to game model.
|
||||
*/
|
||||
private GameModel oGameModel;
|
||||
|
||||
/**
|
||||
* Reference to research queue view.
|
||||
*/
|
||||
private ResearchQueueViewScript oResearchQueueView;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public functions
|
||||
|
||||
/**
|
||||
* Constructor sets references to game model and research queue view.
|
||||
*
|
||||
* @param oGameModel, reference to game model.
|
||||
* @param oResearchQueueView, reference to research queue view.
|
||||
*/
|
||||
public ResearchQueueController(GameModel oGameModel, ResearchQueueViewScript oResearchQueueView)
|
||||
{
|
||||
this.oGameModel = oGameModel;
|
||||
@@ -22,11 +64,152 @@ namespace NResearchController
|
||||
TechRemoveButtonPressed += OnTechRemoveButtonPressed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes TechRemoveButtonPressed event if it is not null with overhanded parameters.
|
||||
*
|
||||
* @param oSender, object, which triggered event.
|
||||
* @param eResearchEvent, research event arguments, conataining additional information about event triggered.
|
||||
*/
|
||||
public static void TechRemoveButtonPressedEvent(object oSender, NResearch.EResearchEvent eResearchEvent)
|
||||
{
|
||||
TechRemoveButtonPressed?.Invoke(oSender, new NResearch.ResearchEventArgs(eResearchEvent));
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulates one day for the tech queue, popping the first element and increasing the tech level, if the player has enough science points.
|
||||
*
|
||||
* @todo string at queue not optimal because mapping is necessary and changing language not possible.
|
||||
*/
|
||||
public void SimulateDay()
|
||||
{
|
||||
PlayerManager[] oPlayerManager = oGameModel.PlayerModel.GetPlayerManagers();
|
||||
|
||||
for (int i = 0; i < oPlayerManager.Length; i++)
|
||||
{
|
||||
int iCost = 0;
|
||||
|
||||
string sTechnologyToLevelUp = oPlayerManager[i].ResearchModel.ResearchQueueModel.GetTechnologyQueueElement(0);
|
||||
|
||||
switch (sTechnologyToLevelUp)
|
||||
{
|
||||
case ("IndustryTech"):
|
||||
{
|
||||
// Checks if player has enough science to increase the level.
|
||||
if (oPlayerManager[i].PlayerAttributes.Resous.Science >= oPlayerManager[i].ResearchModel.Techs.IndustrialCapacityTech.Cost)
|
||||
{
|
||||
// If player has enough science to increase the level, reduce science by cost.
|
||||
oPlayerManager[i].PlayerAttributes.Resous.Science -= (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.IndustrialCapacityTech.Level, (double)2);
|
||||
|
||||
oPlayerManager[i].ResearchModel.Techs.IndustrialCapacityTech.Level++;
|
||||
|
||||
//Calcuate new cost and set cost at model
|
||||
iCost = (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.IndustrialCapacityTech.Level, (double)2);
|
||||
oPlayerManager[i].ResearchModel.Techs.IndustrialCapacityTech.Cost = iCost;
|
||||
|
||||
// Remove first element of tech queue since the player had enough science to increase the tech level.
|
||||
oPlayerManager[i].ResearchModel.ResearchQueueModel.PopFirstTechnologyQueueElement();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ("WealthTech"):
|
||||
{
|
||||
// Checks if player has enough science to increase the level.
|
||||
if (oPlayerManager[i].PlayerAttributes.Resous.Science >= oPlayerManager[i].ResearchModel.Techs.WealthTech.Cost)
|
||||
{
|
||||
// If player has enough science to increase the level, reduce science by cost.
|
||||
oPlayerManager[i].PlayerAttributes.Resous.Science -= (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.WealthTech.Level, (double)2);
|
||||
|
||||
oPlayerManager[i].ResearchModel.Techs.WealthTech.Level++;
|
||||
|
||||
//Calcuate new cost and set cost at model
|
||||
iCost = (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.WealthTech.Level, (double)2);
|
||||
oPlayerManager[i].ResearchModel.Techs.WealthTech.Cost = iCost;
|
||||
|
||||
// Remove first element of tech queue since the player had enough science to increase the tech level.
|
||||
oPlayerManager[i].ResearchModel.ResearchQueueModel.PopFirstTechnologyQueueElement();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ("ScienceTech"):
|
||||
{
|
||||
// Checks if player has enough science to increase the level.
|
||||
if (oPlayerManager[i].PlayerAttributes.Resous.Science >= oPlayerManager[i].ResearchModel.Techs.ScienceTech.Cost)
|
||||
{
|
||||
// If player has enough science to increase the level, reduce science by cost.
|
||||
oPlayerManager[i].PlayerAttributes.Resous.Science -= (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.ScienceTech.Level, (double)2);
|
||||
|
||||
oPlayerManager[i].ResearchModel.Techs.ScienceTech.Level++;
|
||||
|
||||
//Calcuate new cost and set cost at model
|
||||
iCost = (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.ScienceTech.Level, (double)2);
|
||||
oPlayerManager[i].ResearchModel.Techs.ScienceTech.Cost = iCost;
|
||||
|
||||
// Remove first element of tech queue since the player had enough science to increase the tech level.
|
||||
oPlayerManager[i].ResearchModel.ResearchQueueModel.PopFirstTechnologyQueueElement();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ("FoodTech"):
|
||||
{
|
||||
// Checks if player has enough science to increase the level.
|
||||
if (oPlayerManager[i].PlayerAttributes.Resous.Science >= oPlayerManager[i].ResearchModel.Techs.FoodTech.Cost)
|
||||
{
|
||||
// If player has enough science to increase the level, reduce science by cost.
|
||||
oPlayerManager[i].PlayerAttributes.Resous.Science -= (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.FoodTech.Level, (double)2);
|
||||
|
||||
oPlayerManager[i].ResearchModel.Techs.FoodTech.Level++;
|
||||
|
||||
//Calcuate new cost and set cost at model
|
||||
iCost = (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.FoodTech.Level, (double)2);
|
||||
oPlayerManager[i].ResearchModel.Techs.FoodTech.Cost = iCost;
|
||||
|
||||
// Remove first element of tech queue since the player had enough science to increase the tech level.
|
||||
oPlayerManager[i].ResearchModel.ResearchQueueModel.PopFirstTechnologyQueueElement();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ("PowerTech"):
|
||||
{
|
||||
// Checks if player has enough science to increase the level.
|
||||
if (oPlayerManager[i].PlayerAttributes.Resous.Science >= oPlayerManager[i].ResearchModel.Techs.PowerTech.Cost)
|
||||
{
|
||||
// If player has enough science to increase the level, reduce science by cost.
|
||||
oPlayerManager[i].PlayerAttributes.Resous.Science -= (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.PowerTech.Level, (double)2);
|
||||
|
||||
oPlayerManager[i].ResearchModel.Techs.PowerTech.Level++;
|
||||
|
||||
//Calcuate new cost and set cost at model
|
||||
iCost = (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.PowerTech.Level, (double)2);
|
||||
oPlayerManager[i].ResearchModel.Techs.PowerTech.Cost = iCost;
|
||||
|
||||
// Remove first element of tech queue since the player had enough science to increase the tech level.
|
||||
oPlayerManager[i].ResearchModel.ResearchQueueModel.PopFirstTechnologyQueueElement();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ("--"):
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
throw new Exception("Unknown element popped from tech queue.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private functions
|
||||
|
||||
/**
|
||||
* Removes last added technology from queue.
|
||||
* And updates queue view.
|
||||
*
|
||||
* @param oSender, object, which triggered event.
|
||||
* @param e, research event arguments, conataining additional information about event triggered.
|
||||
*/
|
||||
private void OnTechRemoveButtonPressed(object oSender, NResearch.ResearchEventArgs e)
|
||||
{
|
||||
switch (e.eResearchEvent)
|
||||
@@ -44,101 +227,5 @@ namespace NResearchController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO string at queue not optimal
|
||||
public void SimulateDay()
|
||||
{
|
||||
PlayerManager[] oPlayerManager = oGameModel.PlayerModel.GetPlayerManagers();
|
||||
|
||||
for (int i = 0; i < oPlayerManager.Length; i++)
|
||||
{
|
||||
int iCost = 0;
|
||||
|
||||
string sTechnologyToLevelUp = oPlayerManager[i].ResearchModel.ResearchQueueModel.GetTechnologyQueueElement(0);
|
||||
|
||||
switch (sTechnologyToLevelUp)
|
||||
{
|
||||
case ("IndustryTech"):
|
||||
{
|
||||
if (oPlayerManager[i].PlayerAttributes.Resous.Science >= oPlayerManager[i].ResearchModel.Techs.IndustrialCapacityTech.Cost)
|
||||
{
|
||||
oPlayerManager[i].PlayerAttributes.Resous.Science -= (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.IndustrialCapacityTech.Level, (double)2);
|
||||
|
||||
oPlayerManager[i].ResearchModel.Techs.IndustrialCapacityTech.Level++;
|
||||
iCost = (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.IndustrialCapacityTech.Level, (double)2);
|
||||
oPlayerManager[i].ResearchModel.Techs.IndustrialCapacityTech.Cost = iCost;
|
||||
|
||||
oPlayerManager[i].ResearchModel.ResearchQueueModel.PopFirstTechnologyQueueElement();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ("WealthTech"):
|
||||
{
|
||||
if (oPlayerManager[i].PlayerAttributes.Resous.Science >= oPlayerManager[i].ResearchModel.Techs.WealthTech.Cost)
|
||||
{
|
||||
oPlayerManager[i].PlayerAttributes.Resous.Science -= (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.WealthTech.Level, (double)2);
|
||||
|
||||
oPlayerManager[i].ResearchModel.Techs.WealthTech.Level++;
|
||||
iCost = (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.WealthTech.Level, (double)2);
|
||||
oPlayerManager[i].ResearchModel.Techs.WealthTech.Cost = iCost;
|
||||
|
||||
oPlayerManager[i].ResearchModel.ResearchQueueModel.PopFirstTechnologyQueueElement();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ("ScienceTech"):
|
||||
{
|
||||
if (oPlayerManager[i].PlayerAttributes.Resous.Science >= oPlayerManager[i].ResearchModel.Techs.ScienceTech.Cost)
|
||||
{
|
||||
oPlayerManager[i].PlayerAttributes.Resous.Science -= (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.ScienceTech.Level, (double)2);
|
||||
|
||||
oPlayerManager[i].ResearchModel.Techs.ScienceTech.Level++;
|
||||
iCost = (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.ScienceTech.Level, (double)2);
|
||||
oPlayerManager[i].ResearchModel.Techs.ScienceTech.Cost = iCost;
|
||||
|
||||
oPlayerManager[i].ResearchModel.ResearchQueueModel.PopFirstTechnologyQueueElement();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ("FoodTech"):
|
||||
{
|
||||
if (oPlayerManager[i].PlayerAttributes.Resous.Science >= oPlayerManager[i].ResearchModel.Techs.FoodTech.Cost)
|
||||
{
|
||||
oPlayerManager[i].PlayerAttributes.Resous.Science -= (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.FoodTech.Level, (double)2);
|
||||
|
||||
oPlayerManager[i].ResearchModel.Techs.FoodTech.Level++;
|
||||
iCost = (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.FoodTech.Level, (double)2);
|
||||
oPlayerManager[i].ResearchModel.Techs.FoodTech.Cost = iCost;
|
||||
|
||||
oPlayerManager[i].ResearchModel.ResearchQueueModel.PopFirstTechnologyQueueElement();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ("PowerTech"):
|
||||
{
|
||||
if (oPlayerManager[i].PlayerAttributes.Resous.Science >= oPlayerManager[i].ResearchModel.Techs.PowerTech.Cost)
|
||||
{
|
||||
oPlayerManager[i].PlayerAttributes.Resous.Science -= (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.PowerTech.Level, (double)2);
|
||||
|
||||
oPlayerManager[i].ResearchModel.Techs.PowerTech.Level++;
|
||||
iCost = (int)Math.Pow((double)oPlayerManager[i].ResearchModel.Techs.PowerTech.Level, (double)2);
|
||||
oPlayerManager[i].ResearchModel.Techs.PowerTech.Cost = iCost;
|
||||
|
||||
oPlayerManager[i].ResearchModel.ResearchQueueModel.PopFirstTechnologyQueueElement();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ("--"):
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
throw new Exception("Unknown element popped from tech queue.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,60 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Marc de Craigher
|
||||
* @author Aaron Moser
|
||||
*
|
||||
* @package Assets.Scripts.Research.Controller
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace NResearchController
|
||||
{
|
||||
/**
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* @todo Class administrates communication between research tech model and view.
|
||||
*/
|
||||
public class ResearchTechController
|
||||
{
|
||||
private GameModel oGameModel;
|
||||
|
||||
private ResearchQueueViewScript oResearchQueueView;
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public values
|
||||
|
||||
/**
|
||||
* Delegate of TechButtonPressed event.
|
||||
*
|
||||
* @param oGameModel, reference to game model.
|
||||
* @param oResearchQueueView, reference to research queue view.
|
||||
*/
|
||||
public delegate void TechButtonPressedHandler(object sender, NResearch.ResearchEventArgs e);
|
||||
|
||||
/**
|
||||
* Event TechButtonPressed triggered from tech buttons if they are pressed.
|
||||
*/
|
||||
public static event TechButtonPressedHandler TechButtonPressed;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private values
|
||||
|
||||
/**
|
||||
* Reference to game model.
|
||||
*/
|
||||
private GameModel oGameModel;
|
||||
|
||||
/**
|
||||
* Reference to research queue view.
|
||||
*/
|
||||
private ResearchQueueViewScript oResearchQueueView;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public functions
|
||||
|
||||
/**
|
||||
* Sets game model and research queue view references.
|
||||
*
|
||||
* @param oGameModel, reference to game model.
|
||||
* @param oResearchQueueView, reference to research queue view.
|
||||
*/
|
||||
public ResearchTechController(GameModel oGameModel, ResearchQueueViewScript oResearchQueueView)
|
||||
{
|
||||
this.oGameModel = oGameModel;
|
||||
@@ -20,22 +63,25 @@ namespace NResearchController
|
||||
TechButtonPressed += OnTechButtonPressed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="oSender"></param>
|
||||
/// <param name="eResearchEvent"></param>
|
||||
/**
|
||||
*
|
||||
* @param oSender, object, which triggered event.
|
||||
* @param eResearchEvent, research event arguments, containing additional information to event occured.
|
||||
*/
|
||||
public static void TechButtonPressedEvent(object oSender, NResearch.EResearchEvent eResearchEvent)
|
||||
{
|
||||
TechButtonPressed?.Invoke(oSender, new NResearch.ResearchEventArgs(eResearchEvent));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="oSender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <exception cref="Exception"></exception>
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private functions
|
||||
|
||||
/**
|
||||
* Adds tech to research indicated by event args to queue.
|
||||
*
|
||||
* @param oSender, object, which triggered event.
|
||||
* @param e, research event arguments, containing additional information to event occured.
|
||||
*/
|
||||
private void OnTechButtonPressed(object oSender, NResearch.ResearchEventArgs e)
|
||||
{
|
||||
ResearchQueueModel oResearchQueueModel = oGameModel.PlayerModel.GetPlayerManagers()[0].ResearchModel.ResearchQueueModel;
|
||||
|
||||
Reference in New Issue
Block a user