예제 #1
0
    public override void Initialize(LDBlock _data)
    {
        GridPos            = (Vector2Int)Grid.WorldToCell(transform.position);
        transform.position = Grid.CellToWorld((Vector3Int)GridPos);
        Grid.setOccupied((Vector3Int)GridPos, true);

        Animator      = GetComponentInChildren <Animator>();
        AbilitySystem = new AbilitySystem(this);

        CharacterDataTemplate Data = CharacterDataTemplate.Load();

        Data.GetMonsterStartingAttributes(Role)
        .ForEach(Entry => AbilitySystem.RegisterAttribute(Entry.Attribute, Entry.Value));
        Data.GetMonsterAbilities(Role)
        .ForEach(Ability => AbilitySystem.GrantAbility(Ability));
        Data.GetMonsterStartingEffects(Role)
        .ForEach(Effect => AbilitySystem.TryApplyEffectToSelf(Effect));


        AbilitySystem.RegisterOnAttributeChanged(Attribute.Health, OnDamageTaken);
        CurrentHealth = AbilitySystem.GetAttributeValue(Attribute.Health).Value;

        AbilitySystem.RegisterOnAttributeChanged(Attribute.MaxHealth, UpdateMaxHealth);
        MaxHealth = AbilitySystem.GetAttributeValue(Attribute.MaxHealth).Value;

        AbilitySystem
        .GetGrantedAbilityTypes()
        .ForEach(Ability =>
        {
            if (!Ability.Is(TypeTag.MoveAbility))
            {
                MainAbility = Ability;
            }
        });
    }
예제 #2
0
    public override void Initialize(LDBlock data)
    {
        bool found = false;
        LDCharacter OwningCharacter = new LDCharacter();
        foreach (LDCharacter Character in data.characters)
        {
            if (Character.role == (byte)Role)
            {
                OwningCharacter = Character;
                found = true;
            }
        }
        if(!found)
        {
            DestroyImmediate(gameObject);
            return;
        }

        GridPos = (Vector2Int)GameStateManager.Instance.GetGridManager().WorldToCell(transform.position);
        transform.position = GameStateManager.Instance.GetGridManager().CellToWorld((Vector3Int)GridPos);
        GameStateManager.Instance.GetGridManager().setOccupied((Vector3Int)GridPos, true);

        Animator = GetComponentInChildren<Animator>();
        AbilitySystem = new AbilitySystem(this);
        Name = OwningCharacter.name;
        Color = (CharacterColor)OwningCharacter.color;
        if (OwningCharacter.timeLine != null)
        {
            TimeLine = OwningCharacter.timeLine.ToList();
        }
        else
        {
            TimeLine = new List<LDInputFrame>();
        }

        CharacterDataTemplate Data = CharacterDataTemplate.Load();

        if (OwningCharacter.attributes == null || OwningCharacter.attributes.Length == 0)
        {
            // NOTE: First time, Playing from start!
            Data.GetStartingAttributes(Role)
                .ForEach(Entry => AbilitySystem.RegisterAttribute(Entry.Attribute, Entry.Value));
        }
        else
        {
            AbilitySystem.RegisterLDAttributes(OwningCharacter.attributes);
        }

        Data.GetAbilities(Role)
            .ForEach(Ability => AbilitySystem.GrantAbility(Ability));

        Data.GetStartingEffects(Role)
            .ForEach(Effect => AbilitySystem.TryApplyEffectToSelf(Effect));

        AbilitySystem.RegisterOnAttributeChanged(Attribute.Health, OnDamageTaken);
        CurrentHealth = AbilitySystem.GetAttributeValue(Attribute.Health).Value;

        AbilitySystem.RegisterOnAttributeChanged(Attribute.MaxHealth, UpdateMaxHealth);
        MaxHealth = AbilitySystem.GetAttributeValue(Attribute.MaxHealth).Value;
    }