Skip to content

Commit

Permalink
Define IMechanism interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
mogoson committed May 24, 2018
1 parent a7c07c3 commit 093d07b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 27 deletions.
69 changes: 43 additions & 26 deletions Assets/MGS-CommonCode/Machinery/Mechanism.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
* Version : 0.1.0
* Date : 4/17/2018
* Description : Initial development version.
*
* Author : Mogoson
* Version : 0.1.0
* Date : 5/24/2018
* Description : Define mechanism interface.
*************************************************************************/

using System;
Expand All @@ -16,41 +21,21 @@
namespace Mogoson.Machinery
{
/// <summary>
/// Mechanism unit.
/// Mechanism interface.
/// </summary>
[Serializable]
public struct MechanismUnit
public interface IMechanism
{
#region Field and Property
/// <summary>
/// Mechanism to drive.
/// </summary>
public Mechanism mechanism;

/// <summary>
/// Coefficient of velocity.
/// </summary>
public float coefficient;
#endregion

#region Public Method
/// <summary>
/// Constructor.
/// Drive mechanism.
/// </summary>
/// <param name="mechanism">Mechanism to drive.</param>
/// <param name="coefficient">Coefficient of velocity.</param>
public MechanismUnit(Mechanism mechanism, float coefficient)
{
this.mechanism = mechanism;
this.coefficient = coefficient;
}
#endregion
/// <param name="velocity">Drive velocity.</param>
void Drive(float velocity);
}

/// <summary>
/// Base mechanism.
/// </summary>
public abstract class Mechanism : MonoBehaviour
public abstract class Mechanism : MonoBehaviour, IMechanism
{
#region Protected Method
protected virtual void Awake()
Expand All @@ -72,4 +57,36 @@ public virtual void Initialize() { }
public abstract void Drive(float velocity);
#endregion
}

/// <summary>
/// Mechanism unit.
/// </summary>
[Serializable]
public struct MechanismUnit
{
#region Field and Property
/// <summary>
/// Mechanism to drive.
/// </summary>
public Mechanism mechanism;

/// <summary>
/// Coefficient of velocity.
/// </summary>
public float coefficient;
#endregion

#region Public Method
/// <summary>
/// Constructor.
/// </summary>
/// <param name="mechanism">Mechanism to drive.</param>
/// <param name="coefficient">Coefficient of velocity.</param>
public MechanismUnit(Mechanism mechanism, float coefficient)
{
this.mechanism = mechanism;
this.coefficient = coefficient;
}
#endregion
}
}
2 changes: 1 addition & 1 deletion Assets/MGS-CommonCode/Machinery/Transmission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Transmission : Mechanism
{
#region Field and Property
/// <summary>
/// Mechanism drive by this Transmission.
/// Mechanism drive by this transmission.
/// </summary>
public List<MechanismUnit> mechanismUnits = new List<MechanismUnit>();
#endregion
Expand Down

0 comments on commit 093d07b

Please sign in to comment.