public void TestAdd() { var buffManager = new BuffManager(); var buff = new Buff { Type = 1 }; buffManager.Add(buff); var getBuff = buffManager.GetById(buff.Id); Assert.AreSame(buff, getBuff); }
internal static bool GotBuff(string name) { if (!BuffManager.Contains(name)) { string LuaStatement = "finalresult = hasBuff('" + name + "');"; if (Calls.GetText(LuaStatement, "finalresult", 5).Trim() == "true") { BuffManager.Add(name); return(true); } else { return(false); } } return(true); }
public void init() { parry = new Ability() { name = "parry", cooldownsec = 1, cb = () => { buffs.Add(new Buff(1, "parry")); buffs.Add(new Buff(0.5f, "perfectparry")); } }; var blinkenergycost = 10; blink = new Ability() { name = "blink", cooldownsec = 0.2f, cb = () => { var range = 5; transform.position += transform.forward * range; energy -= blinkenergycost; }, }; blink.rules.Add(new Rule() { message = "out of energy", cb = () => { return(energy >= blinkenergycost); } }); regen = new Ability() { name = "regen", cooldownsec = 1, cb = () => { energy = 100; }, }; melee = new Ability() { name = "melee", cooldownsec = 1, cb = () => { var center = transform.position + transform.forward * 1; var radius = 1; var hits = Physics.BoxCastAll(center, new Vector3(10, 10, 10), Vector3.up, Quaternion.identity, 100, enemymask, QueryTriggerInteraction.Collide); hits = Physics.SphereCastAll(center, radius, transform.forward, 1, enemymask, QueryTriggerInteraction.Collide); if (hits.Length > 0) { var hit = hits.First(); var enemy = hit.transform.gameObject.GetComponent <Enemycontroller>(); enemy.TakeDamage(50); } else { //miss } }, }; ranged = new Ability() { name = "ranged", cooldownsec = 1, cb = () => { var missile = Instantiate(missilePrefab, gameObject.transform.position + gameObject.transform.forward * 1, Quaternion.LookRotation(gameObject.transform.forward, Vector3.up)); //var range = 8; //var hits = Physics.RaycastAll(transform.position, transform.position, range, enemymask.value); //foreach (var hit in hits) //{ // var enemy = hit.transform.gameObject.GetComponent<Enemycontroller>(); // enemy.TakeDamage(50); //} }, }; finisher = new Ability() { name = "finisher", }; abilitys = new List <Ability>() { parry, blink, regen, melee, ranged, finisher }; }