Commented player files
This commit is contained in:
@@ -1,9 +1,32 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Aaron Moser
|
||||
*
|
||||
* @package Assets.Scripts.Player.Controller
|
||||
*/
|
||||
namespace NPlayer
|
||||
{
|
||||
/**
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* Class controls communication of playermodel and view.
|
||||
*
|
||||
* @todo Doesn't provide any interfaces to access playermodel yet.
|
||||
*/
|
||||
public class PlayerController
|
||||
{
|
||||
/**
|
||||
* Reference to player model.
|
||||
*/
|
||||
private PlayerModel oPlayerModel;
|
||||
|
||||
/**
|
||||
* Constructor, sets player model reference, number of players and colors of player model.
|
||||
* Also initiates the player managers by calling @see InitPlayerManagers(int iNumberOfPlayers).
|
||||
*
|
||||
* @param oPlayerModel, reference to player model.
|
||||
*/
|
||||
public PlayerController(PlayerModel oPlayerModel)
|
||||
{
|
||||
this.oPlayerModel = oPlayerModel;
|
||||
@@ -15,10 +38,11 @@ namespace NPlayer
|
||||
InitPlayerManagers(oPlayerModel.GetNumberOfPlayers());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes numberOfPlayers player managers and puts them into array of model
|
||||
/// </summary>
|
||||
/// <param name="iNumberOfPlayers"></param>
|
||||
/**
|
||||
* Initializes numberOfPlayers player managers and puts them into array of model.
|
||||
*
|
||||
* @param iNumberOfPlayers, number of player managers to create.
|
||||
*/
|
||||
private void InitPlayerManagers(int iNumberOfPlayers)
|
||||
{
|
||||
oPlayerModel.SetPlayerManagers(new PlayerManager[iNumberOfPlayers]);
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Aaron Moser
|
||||
*
|
||||
* @package Assets.Scripts.Player.Model
|
||||
*/
|
||||
|
||||
/**
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* Enum contains values for player color.
|
||||
*
|
||||
* @todo map to Unity Color or replace by it.
|
||||
*/
|
||||
public enum EPlayerColor
|
||||
{
|
||||
None,
|
||||
|
||||
@@ -1,15 +1,34 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Aaron Moser
|
||||
*
|
||||
* @package Assets.Scripts.Player.Model
|
||||
*/
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
|
||||
/**
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* Class contains all parts of a player.
|
||||
*/
|
||||
public class PlayerManager
|
||||
{
|
||||
// Contains all fleets of player
|
||||
//private List<GameObject> fleets = new List<GameObject>();
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public values
|
||||
|
||||
private ResearchModel _researchModel;
|
||||
/**
|
||||
* Increments each time, a new player manager is created.
|
||||
* Used to set unique player id.
|
||||
*/
|
||||
public static int PlayerIDCount = 0;
|
||||
|
||||
/**
|
||||
* Property making reference to player research model accessible.
|
||||
*/
|
||||
public ResearchModel ResearchModel
|
||||
{
|
||||
get
|
||||
@@ -26,13 +45,9 @@ public class PlayerManager
|
||||
}
|
||||
}
|
||||
|
||||
public static int PlayerIDCount = 0;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private PlayerValues _playerAttributes;
|
||||
|
||||
/**
|
||||
* Property making reference to player attributes accessible.
|
||||
*/
|
||||
public PlayerValues PlayerAttributes
|
||||
{
|
||||
get
|
||||
@@ -49,10 +64,37 @@ public class PlayerManager
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private values
|
||||
|
||||
/**
|
||||
* Contains all fleets of player
|
||||
*/
|
||||
//private List<GameObject> fleets = new List<GameObject>();
|
||||
|
||||
/**
|
||||
* Reference to research model.
|
||||
*/
|
||||
private ResearchModel _researchModel;
|
||||
|
||||
/**
|
||||
* Reference to player attributes, containing id and resources.
|
||||
*/
|
||||
private PlayerValues _playerAttributes;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public functions
|
||||
|
||||
/**
|
||||
* Constructor, initializes researxh model and player attributes.
|
||||
*/
|
||||
public PlayerManager()
|
||||
{
|
||||
this._researchModel = new ResearchModel();
|
||||
this._playerAttributes = new PlayerValues(PlayerIDCount, new NResources.Resources());
|
||||
PlayerIDCount++;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private functions
|
||||
}
|
||||
|
||||
@@ -1,25 +1,68 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Aaron Moser
|
||||
*
|
||||
* @package Assets.Scripts.Player.Model
|
||||
*/
|
||||
using UnityEngine;
|
||||
|
||||
namespace NPlayer
|
||||
{
|
||||
/**
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* Class contains information about all players.
|
||||
*/
|
||||
public class PlayerModel
|
||||
{
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public values
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private values
|
||||
|
||||
/**
|
||||
* Array of player managers.
|
||||
*/
|
||||
private PlayerManager[] _oPlayerManagers;
|
||||
|
||||
/**
|
||||
* Array of player colors.
|
||||
*/
|
||||
private Color[] _oPlayerColors;
|
||||
|
||||
/**
|
||||
* Number of players.
|
||||
*/
|
||||
private int _iNumberOfPlayers;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public functions
|
||||
|
||||
/**
|
||||
* Sets array of player managers.
|
||||
*
|
||||
* @param NewPlayerManagers, reference to array of player managers.
|
||||
*/
|
||||
public void SetPlayerManagers(PlayerManager[] NewPlayerManagers)
|
||||
{
|
||||
_oPlayerManagers = NewPlayerManagers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets references of player managers.
|
||||
*
|
||||
* @return array of player managers.
|
||||
*/
|
||||
public PlayerManager[] GetPlayerManagers()
|
||||
{
|
||||
return _oPlayerManagers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets player colors by fetching data from NewGameDataManager.
|
||||
*/
|
||||
public void SetPlayerColors()
|
||||
{
|
||||
_oPlayerColors = new Color[NewGameDataManager.Instance.PlayerColors.Count];
|
||||
@@ -30,16 +73,31 @@ namespace NPlayer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array reference with player colors.
|
||||
*
|
||||
* @return array with player colors.
|
||||
*/
|
||||
public Color[] GetPlayerColors()
|
||||
{
|
||||
return _oPlayerColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets number of players.
|
||||
*
|
||||
* @param NewNumberOfPlayers, number to set number of players to.
|
||||
*/
|
||||
public void SetNumberOfPlayers(int NewNumberOfPlayers)
|
||||
{
|
||||
_iNumberOfPlayers = NewNumberOfPlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns number of players.
|
||||
*
|
||||
* @return number of players.
|
||||
*/
|
||||
public int GetNumberOfPlayers()
|
||||
{
|
||||
return _iNumberOfPlayers;
|
||||
|
||||
@@ -1,26 +1,45 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Aaron Moser
|
||||
*
|
||||
* @package Assets.Scripts.Player.Model
|
||||
*/
|
||||
|
||||
/**
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* Class contains attributes necessary for each player.
|
||||
*/
|
||||
public class PlayerValues
|
||||
{
|
||||
// Player id
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public values
|
||||
|
||||
/**
|
||||
* Unique player id.
|
||||
*/
|
||||
public int ID { get; set; }
|
||||
|
||||
// Player values
|
||||
/**
|
||||
* Player resources.
|
||||
*/
|
||||
public NResources.Resources Resous { get; set; }
|
||||
|
||||
private EPlayerColor _playerColor;
|
||||
/**
|
||||
* Player color.
|
||||
*/
|
||||
public EPlayerColor PlayerColor { get; set; }
|
||||
|
||||
public EPlayerColor PlayerColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return _playerColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
_playerColor = value;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private values
|
||||
|
||||
// Default constructor
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public functions
|
||||
|
||||
/**
|
||||
* Default constructor, sets player id to 0 and initializes resources.
|
||||
*/
|
||||
public PlayerValues()
|
||||
{
|
||||
this.ID = 0;
|
||||
@@ -28,11 +47,19 @@ public class PlayerValues
|
||||
Resous = new NResources.Resources();
|
||||
}
|
||||
|
||||
// Constructor to init values
|
||||
/**
|
||||
* Constructor to init values, sets id to overhanded value and clones overhanded resources.
|
||||
*
|
||||
* @param id, player id.
|
||||
* @param newResous, resources to clone for player.
|
||||
*/
|
||||
public PlayerValues(int id, NResources.Resources newResous)
|
||||
{
|
||||
this.ID = id;
|
||||
|
||||
Resous = newResous.clone();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private functions
|
||||
}
|
||||
Reference in New Issue
Block a user