Advertisement
Pro_Unit

Game

Jun 10th, 2023
581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System.Linq;
  2.  
  3. using UnityEngine;
  4.  
  5. namespace CompositeWithScriptableObject
  6. {
  7.     using Abilities;
  8.  
  9.     using Strategies;
  10.  
  11.     public class Game : MonoBehaviour
  12.     {
  13.         public Ability[] Abilities;
  14.  
  15.         public void Start()
  16.         {
  17.             IDamageStrategy[] strategies = Abilities.Cast<IDamageStrategy>().ToArray();
  18.  
  19.             var damageStrategy = new DebugDamageStrategy(new CompositeDamageStrategy(strategies));
  20.  
  21.             var character = new Character(100, damageStrategy);
  22.  
  23.             character.TakeDamage(20);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement