Commented research

This commit is contained in:
Aaron Moser
2023-07-23 16:19:21 +02:00
parent 3ef4abc67f
commit 0504837cce
9 changed files with 484 additions and 88 deletions

View File

@@ -1,9 +1,21 @@
/**
* @file
*
* @author Marc de Craigher
*
* @package Assets.Scripts.Research.Technology
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace NTechnology
{
/**
* @section DESCRIPTION
*
* Enum contains all possible technologies.
*/
public enum ETechnology
{
IndustryTech,

View File

@@ -1,13 +1,62 @@
/**
* @file
*
* @author Aaron Moser
*
* @package Assets.Scripts.Research.Technology
*/
namespace NTechnology
{
/**
* @section DESCRIPTION
*
* Class is a container to transport all tech levels at once.
*/
public class TechLevels
{
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public values
/**
* Level of industry tech.
*/
public int IndustryTechLevel;
/**
* Level of wealth tech.
*/
public int WealthTechLevel;
/**
* Level of science tech.
*/
public int ScienceTechLevel;
/**
* Level of food tech.
*/
public int FoodTechLevel;
/**
* Level of power tech.
*/
public int PowerTechLevel;
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private values
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public functions
/**
* Initializes levels with overhanded values.
*
* @param IndustryTechLevel, level of industry tech to transport.
* @param WealthTechLevel, level of wealth tech to transport.
* @param ScienceTechLevel, level of science tech to transport.
* @param FoodTechLevel, level of food tech to transport.
* @param PowerTechLevel, level of power tech to transport.
*/
public TechLevels(int IndustryTechLevel, int WealthTechLevel, int ScienceTechLevel, int FoodTechLevel, int PowerTechLevel)
{
this.IndustryTechLevel = IndustryTechLevel;
@@ -16,5 +65,8 @@ namespace NTechnology
this.FoodTechLevel = FoodTechLevel;
this.PowerTechLevel = PowerTechLevel;
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private functions
}
}

View File

@@ -1,18 +1,60 @@
/**
* @file
*
* @author Marc de Craigher
*
* @package Assets.Scripts.Research.Technology
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace NTechnology
{
/**
* @section DESCRIPTION
*
* Class contains all technologies.
*/
public class Technologies
{
// Technology levels
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public values
/**
* Technology of wealth.
*/
public Technology WealthTech { get; set; }
/**
* Technology of science.
*/
public Technology ScienceTech { get; set; }
/**
* Technology of power.
*/
public Technology PowerTech { get; set; }
/**
* Technology of food.
*/
public Technology FoodTech { get; set; }
/**
* Technology of industry.
*/
public Technology IndustrialCapacityTech { get; set; }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private values
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public functions
/**
* Init all techs starting cost and level with 1.
*/
public Technologies()
{
// Init all techs starting cost and level with 1.
@@ -23,6 +65,17 @@ namespace NTechnology
IndustrialCapacityTech = new Technology(1, 1, ETechnology.IndustryTech);
}
/**
* Init all techs starting cost and level with overhanded techs.
*
* @todo create deep copy instead of references.
*
* @param wealth, technology representing wealth tech of player.
* @param science, technology representing science tech of player.
* @param power, technology representing power tech of player.
* @param food, technology representing food tech of player.
* @param industry, technology representing industry tech of player.
*/
public Technologies(Technology wealth, Technology science, Technology power, Technology food, Technology industry)
{
WealthTech = wealth;
@@ -31,5 +84,8 @@ namespace NTechnology
FoodTech = food;
IndustrialCapacityTech = industry;
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private functions
}
}

View File

@@ -1,20 +1,62 @@
/**
* @file
*
* @author Marc de Craigher
*
* @package Assets.Scripts.Research.Technology
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace NTechnology
{
/**
* @section DESCRIPTION
*
* Class contains information about a technology.
*/
public class Technology
{
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public values
/**
* Cost of technology to increase level.
*/
public int Cost;
/**
* Current level of technology.
*/
public int Level;
/**
* Name of technology.
*/
public ETechnology Name;
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private values
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public functions
/**
* Sets cost, level and name to overhanded values.
*
* @param cost, starting cost of technology.
* @param level, starting level of technology.
* @param name, name of technology.
*/
public Technology(int cost, int level, ETechnology name)
{
this.Cost = cost;
this.Level = level;
this.Name = name;
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private functions
}
}

View File

@@ -1,21 +1,57 @@
using System.Collections;
using System.Collections.Generic;
/**
* @file
*
* @author Marc de Craigher
*
* @package Assets.Scripts.Research.View
*/
using UnityEngine;
using UnityEngine.UI;
/**
* @section DESCRIPTION
*
* Class contains functionality to set cost label.
*/
public class ResearchCostViewScript : MonoBehaviour
{
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public values
/**
* Reference to tech cost banner.
*/
public Text TechCostBanner;
/**
* Reference to tech cost label.
*/
public Text TechCostLabel;
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private values
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public functions
/**
* Sets text of cost label to overhanded value.
*
* @param Cost, value to set text of cost label to.
*/
public void SetCostLabel(int Cost)
{
TechCostLabel.text = Cost.ToString();
}
/**
* @todo Changes language of cost banner, depending on overhanded value or public fetchable settings variable/function.
*/
public void ChangeLanguage()
{
//TechCostBanner.text;
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private functions
}

View File

@@ -1,30 +1,78 @@
/**
* @file
*
* @author Marc de Craigher
*
* @package Assets.Scripts.Research.View
*/
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
/**
* @section DESCRIPTION
*
* Class contains functionality of research queue view, displaying the research queue model.
*/
public class ResearchQueueViewScript : MonoBehaviour
{
private const int TECHQUEUESIZE = 4;
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public values
/**
* Reference of tech queue banner.
*
* GalaxyCanvas.ScienceManagerCanvas.ResearchQueueCanvas.QueueBanner
*/
public Text TechQueueBanner;
/**
* Reference of tech queue labels.
*
* GalaxyCanvas.ScienceManagerCanvas.ResearchQueueCanvas.QueuePos1
* GalaxyCanvas.ScienceManagerCanvas.ResearchQueueCanvas.QueuePos2
* GalaxyCanvas.ScienceManagerCanvas.ResearchQueueCanvas.QueuePos3
* GalaxyCanvas.ScienceManagerCanvas.ResearchQueueCanvas.QueuePos4
*/
public Text[] TechQueueLabels = new Text[TECHQUEUESIZE];
/**
* Reference of remove last tech from queue button.
*
* GalaxyCanvas.ScienceManagerCanvas.ResearchTechsCanvas.RemoveLastButton
*/
public Button RemoveLastTechFromQueueButton;
/**
* Reference to game model.
*/
public GameModel oGameModel;
void Start()
{
RemoveLastTechFromQueueButton.onClick.AddListener(() => SendEventToController(NResearch.EResearchEvent.RemoveLastTechFromQueue));
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private values
/**
* Maximum size of tech queue.
*/
private const int TECHQUEUESIZE = 4;
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public functions
/**
* Sends overhanded research event to research queue controller.
*
* @param eResearchEvent, research event that occured.
*/
public void SendEventToController(NResearch.EResearchEvent eResearchEvent)
{
NResearchController.ResearchQueueController.TechRemoveButtonPressedEvent(this, eResearchEvent);
}
/**
* Fetches data from research queue model at game model and writes data into tech queue labels.
*/
public void UpdateQueueLabelsText()
{
for (int i = 0; i < 4; i++)
@@ -42,14 +90,33 @@ public class ResearchQueueViewScript : MonoBehaviour
}
}
/**
* Sets game model.
*
* @param oGameModel, reference to game model.
*/
public void SetGameModel(GameModel oGameModel)
{
this.oGameModel = oGameModel;
}
/**
* @todo Change language of research queue banner and labels.
*/
public void ChangeLanguage()
{
//TechQueueBanner.text = ;
//RemoveLastTechFromQueueButton.GetComponent<Text>().text = ;
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private functions
/**
* Start is called before the first frame update is called.
*/
void Start()
{
RemoveLastTechFromQueueButton.onClick.AddListener(() => SendEventToController(NResearch.EResearchEvent.RemoveLastTechFromQueue));
}
}

View File

@@ -1,31 +1,135 @@
/**
* @file
*
* @author Marc de Craigher
*
* @package Assets.Scripts.Research.View
*/
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace NResearch
{
/**
* @section DESCRIPTION
*
* Class contains functionality of research tech view, containing refernces to tech buttons, sending events to research tech and cost controllers.
*/
public class ResearchTechViewScript : MonoBehaviour
{
/// <summary>
/// References to unity TechButtons, used to add new tech to research queue or check cost of next level.
/// </summary>
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public values
/**
* References to unity TechButtons, used to add new tech to research queue or check cost of next level.
*
* GalaxyCanvas.ScienceManagerCanvas.ResearchTechsCanvas.IndustryButton
* GalaxyCanvas.ScienceManagerCanvas.ResearchTechsCanvas.WealthButton
* GalaxyCanvas.ScienceManagerCanvas.ResearchTechsCanvas.ScienceButton
* GalaxyCanvas.ScienceManagerCanvas.ResearchTechsCanvas.FoodButton
*/
public TechButton IndustrialTechButton, WealthTechButton, ScienceTechButton, FoodTechButton;
/// <summary>
/// References to unity labels, displaying current level of tech.
/// </summary>
/**
* References to unity labels, displaying current level of tech.
*
* GalaxyCanvas.ScienceManagerCanvas.ResearchTechsCanvas.IndustryVal
* GalaxyCanvas.ScienceManagerCanvas.ResearchTechsCanvas.WealthVal
* GalaxyCanvas.ScienceManagerCanvas.ResearchTechsCanvas.ScienceVal
* GalaxyCanvas.ScienceManagerCanvas.ResearchTechsCanvas.FoodVal
*/
public Text IndustrialTechLevelLabel, WealthTechLevelLabel, ScienceTechLevelLabel, FoodTechLevelLabel;
/// <summary>
/// Reference for gamemodel. Set from parent view.
/// </summary>
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private values
/**
* Reference for gamemodel. Set from parent view.
*/
private GameModel oGameModel;
/// <summary>
/// Called at start of game. Sets EResearchEvents, onClick-, onMouseEnter- and onMouseExit-events of TechButtons.
/// </summary>
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public functions
/**
* Sets reference to game model.
*
* @param oGameModel, reference to game model.
*/
public void SetGameModel(GameModel oGameModel)
{
this.oGameModel = oGameModel;
}
/**
* Calls enter or exit method, depending on eResearchEvent of event args.
*
* @param sender, object which triggered the event.
* @param e, research event args, containing additional information about event.
*/
public void SendEventToCostController(object sender, NResearch.ResearchEventArgs e)
{
switch (e.eResearchEvent)
{
case (EResearchEvent.EnterIndustryTechButton):
case (EResearchEvent.EnterWealthTechButton): // Fall through wanted
case (EResearchEvent.EnterScienceTechButton): // Fall through wanted
case (EResearchEvent.EnterFoodTechButton): // Fall through wanted
{
NResearchController.ResearchCostController.TechButtonEnterEvent(this, e.eResearchEvent);
}
break;
case (EResearchEvent.ExitTechButton):
{
NResearchController.ResearchCostController.TechButtonExitEvent(this, e.eResearchEvent);
}
break;
}
}
/**
* Sends event eResearchEvent which indicates which tech button was pressed to research tech controller.
*
* @param eResearchEvent, event which was triggered.
*/
public void SendEventToController(EResearchEvent eResearchEvent)
{
NResearchController.ResearchTechController.TechButtonPressedEvent(this, eResearchEvent);
}
/**
* Gets the level of the techs from model and sets labels of view.
*/
public void UpdateResearchTechView()
{
// Get levels of techs
int IndustryTechLevel = oGameModel.PlayerModel.GetPlayerManagers()[0].ResearchModel.Techs.IndustrialCapacityTech.Level;
int WealthTechLevel = oGameModel.PlayerModel.GetPlayerManagers()[0].ResearchModel.Techs.WealthTech.Level;
int ScienceTechLevel = oGameModel.PlayerModel.GetPlayerManagers()[0].ResearchModel.Techs.ScienceTech.Level;
int FoodTechLevel = oGameModel.PlayerModel.GetPlayerManagers()[0].ResearchModel.Techs.FoodTech.Level;
// Set text of labels to levels values
IndustrialTechLevelLabel.text = IndustryTechLevel.ToString();
WealthTechLevelLabel.text = WealthTechLevel.ToString();
ScienceTechLevelLabel.text = ScienceTechLevel.ToString();
FoodTechLevelLabel.text = FoodTechLevel.ToString();
}
/**
* @todo Change language depending on overhanded value.
*/
public void ChangeLanguage()
{
//TechnologiesButtons[i].GetComponent<Text>().text;
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private functions
/**
* Called at start of game. Sets EResearchEvents, onClick-, onMouseEnter- and onMouseExit-events of TechButtons.
*/
void Start()
{
// Set EResearchEvents
@@ -52,71 +156,5 @@ namespace NResearch
ScienceTechButton.onMouseExit += SendEventToCostController;
FoodTechButton.onMouseExit += SendEventToCostController;
}
/// <summary>
/// Sets reference to game model.
/// </summary>
/// <param name="oGameModel"></param>
public void SetGameModel(GameModel oGameModel)
{
this.oGameModel = oGameModel;
}
/// <summary>
/// Calls enter or exit method, depending on eResearchEvent of event args.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void SendEventToCostController(object sender, NResearch.ResearchEventArgs e)
{
switch (e.eResearchEvent)
{
case (EResearchEvent.EnterIndustryTechButton):
case (EResearchEvent.EnterWealthTechButton): // Fall through wanted
case (EResearchEvent.EnterScienceTechButton): // Fall through wanted
case (EResearchEvent.EnterFoodTechButton): // Fall through wanted
{
NResearchController.ResearchCostController.TechButtonEnterEvent(this, e.eResearchEvent);
}
break;
case (EResearchEvent.ExitTechButton):
{
NResearchController.ResearchCostController.TechButtonExitEvent(this, e.eResearchEvent);
}
break;
}
}
/// <summary>
/// Sends event eResearchEvent which indicates which tech button was pressed to research tech controller.
/// </summary>
/// <param name="eResearchEvent"></param>
public void SendEventToController(EResearchEvent eResearchEvent)
{
NResearchController.ResearchTechController.TechButtonPressedEvent(this, eResearchEvent);
}
/// <summary>
/// Gets the level of the techs from model and sets labels of view.
/// </summary>
public void UpdateResearchTechView()
{
// Get levels of techs
int IndustryTechLevel = oGameModel.PlayerModel.GetPlayerManagers()[0].ResearchModel.Techs.IndustrialCapacityTech.Level;
int WealthTechLevel = oGameModel.PlayerModel.GetPlayerManagers()[0].ResearchModel.Techs.WealthTech.Level;
int ScienceTechLevel = oGameModel.PlayerModel.GetPlayerManagers()[0].ResearchModel.Techs.ScienceTech.Level;
int FoodTechLevel = oGameModel.PlayerModel.GetPlayerManagers()[0].ResearchModel.Techs.FoodTech.Level;
// Set text of labels to levels values
IndustrialTechLevelLabel.text = IndustryTechLevel.ToString();
WealthTechLevelLabel.text = WealthTechLevel.ToString();
ScienceTechLevelLabel.text = ScienceTechLevel.ToString();
FoodTechLevelLabel.text = FoodTechLevel.ToString();
}
public void ChangeLanguage()
{
//TechnologiesButtons[i].GetComponent<Text>().text;
}
}
}

View File

@@ -1,3 +1,11 @@
/**
* @file
*
* @author Marc de Craigher
* @author Aaron Moser
*
* @package Assets.Scripts.Research.View
*/
using System;
using System.Collections;
using System.Collections.Generic;
@@ -7,16 +15,53 @@ using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
/**
* @section DESCRIPTION
*
* Class represents research view.
*/
public class ResearchViewScript : MonoBehaviour
{
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public values
/**
* Reference to research queue view.
*
* InvisibleObjectsCanvas.GameView.ResearchView.ResearchQueueView
*/
public ResearchQueueViewScript ResearchQueueView;
/**
* Reference to research tech view.
*
* InvisibleObjectsCanvas.GameView.ResearchView.ResearchTechView
*/
public NResearch.ResearchTechViewScript ResearchTechView;
/**
* Reference to research cost view.
*
* InvisibleObjectsCanvas.GameView.ResearchView.ResearchCostView
*/
public ResearchCostViewScript ResearchCostView;
/**
* Reference to game model.
*/
public GameModel oGameModel;
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private values
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public functions
/**
* Sets own and children game model.
*
* @param oGameModel, reference to game model.
*/
public void SetGameModel(GameModel oGameModel)
{
// Set own game model
@@ -29,6 +74,9 @@ public class ResearchViewScript : MonoBehaviour
// The cost will be overhanded to the given method
}
/**
* Gets called every day, updates children views.
*/
public void DailyUpdateView()
{
if (oGameModel != null)
@@ -43,8 +91,16 @@ public class ResearchViewScript : MonoBehaviour
}
}
/**
* @todo Change language depending on overhanded value.
*
* @param Language, indicates language, to set view elements to.
*/
public void ChangeLanguage(ELanguage Language)
{
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private functions
}

View File

@@ -1,13 +1,47 @@
/**
* @file
*
* @author Marc de Craigher
*
* @package Assets.Scripts.Research.View
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/**
* @section DESCRIPTION
*
* Class contains functionality to toggle visibility of science manager and galaxy bodys canvas.
*/
public class ToggleScienceUIScript : MonoBehaviour
{
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public values
/**
* Reference to science manager canvas.
*
* GalaxyCanvas.ScienceManagerCanvas
*/
public Canvas scienceManagerCanvas;
/**
* Reference to galaxy bodys canvas.
*
* GalaxyCanvas.GalaxyBodysCanvas
*/
public Canvas galaxyBodysCanvas;
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private values
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Public functions
/**
* Toggles visibility of science manager canvas and galaxy bodys canvas.
*/
public void ToggleCanvasVisibility()
{
GameObject smObject = scienceManagerCanvas.gameObject;
@@ -18,4 +52,7 @@ public class ToggleScienceUIScript : MonoBehaviour
// Toggle visibility of galaxy body canvas
gbObject.SetActive(!gbObject.activeSelf);
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Private functions
}