This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StrongWeapon : Weapon | |
{ | |
public override double Damage => 5.0; | |
} | |
public class Player | |
{ | |
private Weapon _weapon; | |
public double Damage => _weapon.Damage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PlayerTest | |
{ | |
[Test] | |
public void GetDamageFromWeapon() | |
{ | |
var weapon = Substitute.For<Weapon>(); | |
weapon.Damage.Returns(5.0); | |
Assert.AreEqual(5.0, new Player(weapon).Damage); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StrongWeapon : Weapon | |
{ | |
public double Damage => 4.0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Powerup : IPowerup | |
{ | |
public double Multiplier { get; } | |
} | |
public class Player : IPlayer | |
{ | |
private const int MaxPowerups = 3; | |
private Weapon _weapon; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PlayerTest | |
{ | |
private Weapon _weapon; | |
private IPowerup _powerup; | |
[SetUp] | |
public void Init() | |
{ | |
_weapon = Substitute.For<Weapon>(); | |
_weapon.Damage.Returns(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PlayerTest | |
{ | |
private Weapon _weapon; | |
private IPowerup _powerup; | |
[SetUp] | |
public void Init() | |
{ | |
_weapon = Substitute.For<Weapon>(); | |
_weapon.Damage.Returns(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Powerup : IPowerup | |
{ | |
public double Multiplier { get; } | |
} | |
public class Player | |
{ | |
private const int MaxPowerups = 4; | |
private Weapon _weapon; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Player | |
{ | |
private const double MaxPowerups = 2; | |
private Weapon _weapon; | |
public List<IPowerup> Powerups { get; } = new List<IPowerup>(); | |
public double Damage => _weapon.Damage * Powerups.Take(MaxPowerups).Sum(p => p.Multiplier); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.Events; | |
public class Goal : MonoBehaviour { | |
public Players scoresTo; | |
public IScoreEvent scoreEvent; | |
public void Construct(Players scoresTo, IScoreEvent scoreEvent) { | |
this.scoresTo = scoresTo; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyCollaborator : MonoBehaviour | |
{ | |
private void OnCollisionEnter(Collision collision) | |
{ | |
foreach (ContactPoint contact in collision.contacts) | |
{ | |
Debug.DrawRay(contact.point, contact.normal, Color.white); | |
} | |
} | |
} |
OlderNewer