-
Notifications
You must be signed in to change notification settings - Fork 0
/
LanKnifeData.cs
107 lines (92 loc) · 3.08 KB
/
LanKnifeData.cs
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Collections;
using System.Collections.Generic;
using ScriptableObjectArchitecture;
using UnityEngine;
using Random = UnityEngine.Random;
[CreateAssetMenu(menuName = "Ability/Linh Lan/Lan Knife")]
public class LanKnifeData : DamageAbilityBase
{
[Header("Normal")]
public float knifeSpeed;
public float knifeDistance;
public float knifeScale;
public GameObject bulletPrefab;
public List<LanKnifeData> upgradeDatas;
[HideInInspector] public List<GameObject> pool;
// For Upgrade
[HideInInspector] public float currentKnifeScale;
[HideInInspector] public float currentKnifeDistance;
[HideInInspector] public float currentKnifeSpeed;
// Debuff
[Header("Debuff")]
public int numToDebuff;
private int internalNumToDebuff;
public override void Initialize()
{
base.Initialize();
internalNumToDebuff = 0;
currentKnifeScale = knifeScale;
currentKnifeDistance = knifeDistance;
currentKnifeSpeed = knifeSpeed;
pool = new List<GameObject>();
GameObject abilityHolder = new GameObject(abilityName + " Holder");
GameObject bullet = Instantiate(bulletPrefab, abilityHolder.transform);
bullet.GetComponent<LanKnife>().LoadData(this);
pool.Add(bullet);
bullet.SetActive(false);
}
public override void TriggerAbility()
{
internalNumToDebuff += 1;
GameObject bullet = pool[0];
bullet.SetActive(true);
// Debuff Attack
if (internalNumToDebuff >= numToDebuff)
{
Vector2 randomDirection = new Vector2();
// Random direction
if (Random.value < 0.5f)
{
randomDirection = new Vector2(1, Random.Range(-1, 1));
}
else
{
randomDirection = new Vector2(-1, Random.Range(-1, 1));
}
bullet.GetComponent<LanKnife>().bulletDirection = randomDirection;
internalNumToDebuff = 0;
}
}
public override void UpgradeAbility()
{
LanKnifeData upgradeData = upgradeDatas[currentLevel];
// Update current
currentCooldownTime = upgradeData.cooldownTime;
currentKnifeDistance = upgradeData.knifeDistance;
currentKnifeScale = upgradeData.knifeScale;
currentKnifeSpeed = upgradeData.knifeSpeed;
currentDamage = upgradeData.damage;
GameObject bullet = pool[0];
bullet.GetComponent<LanKnife>().LoadData(this);
currentLevel += 1;
}
public override AbilityBase GetUpgradeDataInfo()
{
return upgradeDatas[currentLevel];
}
public override void ModifyDamage(float percentage, bool increase)
{
BaseModifyDamage(percentage, increase);
GameObject bullet = pool[0];
bullet.GetComponent<LanKnife>().LoadData(this);
}
public override bool IsMaxLevel()
{
if (currentLevel >= upgradeDatas.Count && currentLevel >= 1)
{
return true;
}
return false;
}
}