chenxin
2020-11-05 d6161eec964b2eeb23bd93c84c29f8ffd3a2d06f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Collections.Generic;
using UnityEngine;
 
namespace Core.Health
{
    /// <summary>
    /// A simple scriptable object that defines which other alignments it can harm. It can never harm
    /// any other alignment that's not a SimpleAlignment
    /// </summary>
    [CreateAssetMenu(fileName = "Alignment.asset", menuName = "StarterKit/Simple Alignment", order = 1)]
    public class SimpleAlignment : ScriptableObject, IAlignmentProvider
    {
        /// <summary>
        /// A collection of other alignment objects that we can harm
        /// </summary>
        public List<SimpleAlignment> opponents;
 
        /// <summary>
        /// Gets whether the given alignment is in our known list of opponents
        /// </summary>
        public bool CanHarm(IAlignmentProvider other)
        {
            if (other == null)
            {
                return true;
            }
            
            var otherAlignment = other as SimpleAlignment;
            
            return otherAlignment != null && opponents.Contains(otherAlignment);
        }
    }
}