protected override void onFire(Vector2 direction) { active = true; instantiatedShot.Fire(this.transform.position, direction); massMod = action.mass.addModifier(99999f); sfx.Play(); }
public void Input() { foreach (string line in rawInput) { string[] split = line.Split(' '); Debug.Log(gameObject + line + split.Length.ToString()); if (split.Length == 0) { continue; } if (split[0].Equals("STAT")) { stats.Add(split[1], new FloatStat(split[1], float.Parse(split[2]))); } else if (split[0].Equals("EFFECT")) { FloatStat dfl = new FloatStat(split[1]); impactEffects[split[1]] = new FSQI(dfl, split[2], float.Parse(split[3]), float.Parse(split[4]), int.Parse(split[5]) ); } } }
public bool removeModifier(FloatStat modifier) { bool returnValue = stats.Remove(modifier); internalUpdate(); return(returnValue); }
public FloatStat addModifier(float value) { FloatStat result = new FloatStat(value, internalUpdate); stats.Add(result); internalUpdate(); return result; }
protected override void OnDeactivate() { base.OnDeactivate(); forwardShield.SetActive(false); action.mass.removeModifier(massMod); massMod = null; }
public void applyPowerup(FloatStat stat, string powName, float value = 1.0f, float duration = -0.1f, int mode = 0) { float time = Time.time + duration; int timePeriod = time_period(time); FSQI powerup, template, existing; powerup = new FSQI(stat, powName, value, time); template = new FSQI(stat, powName); Debug.Log(stat.getName() + mode); if (directAccess.ContainsKey(template)) { existing = directAccess[template]; queue[time_period(existing.time)].Remove(existing); directAccess.Remove(template); } else { queue[timePeriod] = new List <FSQI>(); } if (mode == 1) { stat.ChangeWithFactor(powName, value); return; } stat.setFactor(powName, value); if (duration > 0) { queue[timePeriod].Add(powerup); directAccess[template] = powerup; } }
public override void InitStats() { AttackData = new AttackData(15); // Main: Cooldown Main_CD.EndTime = new FloatStat(0.7f, min: 0.01f); // Main: Mana Usage Main_ManaUsage = new FloatStat(4f, min: 0); // Main: Ice Bolt Main_IceBoltData = new ProjectileData() { moveSpeed = new FloatStat(25f, min: 0f), travelDist = new FloatStat(0f, min: 0f, max: 10f) }; // Sub: Cast Time Sub_CastTime.EndTime = new FloatStat(0.2f, min: 0f); // Sub: Damage Sub_DamageTick.EndTime = new FloatStat(0.5f, min: 0f); Sub_DamagePerTick = new AttackData(2f, gameObject); // Sub: Mana Usage Sub_ManaUsageTick.EndTime = new FloatStat(0.25f, min: 0f); Sub_ManaUsagePerTick = new FloatStat(0.5f, min: 0f); // Special: Cast Time Spec_CastTime.EndTime = new FloatStat(0.15f, min: 0f); // Special: Frozen Soul Usage Spec_FrozenSoulUsage = new IntStat(5, min: 0); // Special: Ice Block Spec_IceBlockDur.EndTime = new FloatStat(5f, min: 0f); }
public FloatStat addModifier(float value) { FloatStat result = new FloatStat(value, internalUpdate); stats.Add(result); internalUpdate(); return(result); }
protected override void OnActivate() { base.OnActivate(); vfx.Play(); coll.enabled = true; effector.enabled = true; render.enabled = true; massMod = action.mass.addModifier(99999f); }
public PlayerWalkData(FloatStat walkSpeed, float walkAccelTime, float changeDirSpeed) { this.walkSpeed = walkSpeed; this.walkAccelTime = walkAccelTime; this.changeDirSpeed = changeDirSpeed; curWalkSpeed = 0; oldWalkDir = 0; time = 0; }
protected override void OnActivate() { base.OnActivate(); forwardShield.SetActive(true); foreach (Collider2D coll in ignoreCollisionList) { Physics2D.IgnoreCollision(shieldCol, coll); //ignore collision gets wiped when the collider is deactivated } massMod = action.mass.addModifier(99f); }
public ProjectileTemplate(string name, string spriteName, FloatStat damageRatio, IntStat bounces, FloatStat lifespan, FloatStat speed) { _name = name; _spriteName = spriteName; _damageRatio = damageRatio; _bounces = bounces; _lifespan = lifespan; _speed = speed; _behaviors = new Dictionary<string, List<ProjectileBehavior>>(); }
public void Setup(PlayerStats pStats) { System.Array.Copy(pStats.upgrades, upgrades, GlobalVariables.visibleTraitCount); charClass = pStats.characterClass; maxHealth = new IntStat(pStats.characterClass.maxHealth); for (int x = 0; x < pStats.upgrades[(int)PlayerStats.UpgradeIndex.Health]; x++) { maxHealth.AddModifier(GlobalVariables.healthPerUpgrade); } currentHealth = maxHealth.GetStat(); healthBar.SetMaxHealth(maxHealth.GetStat()); attackPower = new IntStat(pStats.characterClass.attackPower); for (int x = 0; x < pStats.upgrades[(int)PlayerStats.UpgradeIndex.AttackPower]; x++) { attackPower.AddModifier(GlobalVariables.attackPerUpgrade); } magicPower = new IntStat(pStats.characterClass.magicPower); for (int x = 0; x < pStats.upgrades[(int)PlayerStats.UpgradeIndex.MagicPower]; x++) { magicPower.AddModifier(GlobalVariables.magicPerUpgrade); } resistance = new FloatStat(pStats.characterClass.resistance); for (int x = 0; x < pStats.upgrades[(int)PlayerStats.UpgradeIndex.Resistance]; x++) { resistance.AddModifier(GlobalVariables.resistancePerUpgrade); } moveSpeed = new IntStat(pStats.characterClass.movespeed); for (int x = 0; x < pStats.upgrades[(int)PlayerStats.UpgradeIndex.Movespeed]; x++) { moveSpeed.AddModifier(GlobalVariables.movePerUpgrade); } knockbackAmplification = new IntStat(pStats.characterClass.knockbackApplication); knockbackResistance = new FloatStat(pStats.characterClass.knockbackResistance); jumpHeight = new IntStat(pStats.characterClass.jumpHeight); doubleJumps = new IntStat(pStats.characterClass.doubleJumps); dashCooldown = new IntStat(pStats.characterClass.dashCooldown); dodgeChance = new FloatStat(pStats.characterClass.dodgeChance); /* throws an error * for(int x = 0; x < GlobalVariables.trinketSlots; x++) * { * foreach(StatModifier statMod in ((Trinket)pStats.equippedItems[x + GlobalVariables.weaponSlots]).modifiers) * { * ApplyModifier(statMod.stat, statMod.percent, statMod.amount); * } * } */ UpdateStatText(); }
protected override void OnDeactivate() { base.OnDeactivate(); vfx.Stop(); vfx.Clear(); coll.enabled = false; effector.enabled = false; render.enabled = false; action.mass.removeModifier(massMod); massMod = null; }
public override void InitStats() { // Init Cooldown CooldownTimer.EndTime = 10f; // Init Mana Usage ManaUsage = new FloatStat(20, min: 0); // Init Duration durationTimer.EndTime = 10f; durationTimer .SetTick(gameObject) .SetAction( onEnd: () => { corutine_CheckAllCorpseAbsorbed = StartCoroutine(CheckAllCorpseAbsorbed()); PlayerActionEventManager.RemoveEvent(PlayerActions.Kill, onKill); }) .SetActive(false); IEnumerator CheckAllCorpseAbsorbed() { while (true) { // Check if All Corpses all Absorbed if (IsActive && durationTimer.IsEnded && corpsesToAbsorb == 0) { PlayerStats.Inst.Heal(PlayerStats.Inst.GetShieldAt(shieldIndex).Value *healMultiplier); // TODO // 시체 블록 풀링하기 때문에 소환할때 리셋 해야함!!! //for (int i = 0; i < Mathf.FloorToInt(PlayerStats.Inst.GetShieldAt(shieldIndex).Value / shieldGainPerKill); i++) //{ // coprsePrefabs[i]. // GetComponent<PoolingObj>().Spawn(GM.PlayerPos). // GetComponent<Rigidbody2D>().AddForce(Vector2.right * GM.Player.Data.Dir * 50f, ForceMode2D.Impulse); //} Deactivate(); corutine_CheckAllCorpseAbsorbed = null; yield return(null); } yield return(new WaitForEndOfFrame()); } } // Init Shield HP shieldHealth = new FloatStat(0, min: 0, max: 40); }
// Update is called once per frame public void Update() { health = (int)parentScript.stats["health"].getCompoundValue(); armor = (int)parentScript.stats["armor"].getCompoundValue(); FloatStat MD = parentScript.stats["damage"]; MD.removeFactor("isDangerous"); meleeDamage = (int)MD.getCompoundValue(); myAi = parent.GetComponent <AiScriptBase>(); MD.setFactor("isDangerous", myAi.isDangerous() ? 1 : 0); //if (start) Start(); //parent.GetComponent<Rigidbody2D>().GetVector(); direction = direction.normalized; }
public override void InitStats() { // Init Cooldown CooldownTimer.EndTime = 5f; // Init Duration durationTimer.EndTime = 2.5f; durationTimer .SetTick(gameObject) .SetAction(onEnd: Deactivate) .SetActive(false); // Init Shield HP shieldHealth = new FloatStat(40, min: 0, max: 40); }
public int AddShield(FloatStat shieldHealth) { // Trigger Event PlayerActionEventManager.Trigger(PlayerActions.ShieldGained); shields.Add(shieldCount, new ShieldHealth() { shieldHealth = shieldHealth }); // Trigger Event PlayerActionEventManager.Trigger(PlayerActions.ShieldChanged); return(shieldCount++); }
IEnumerator Boost(Vector2 direction) { if (speedMod == null) { speedMod = action.maxSpeedTracker.addModifier(speedMultiplier); } else { speedMod.value = speedMultiplier; } if (accelMod == null) { accelMod = action.accel.addModifier(baseAccelDebuff); } else { accelMod.value = baseAccelDebuff; } if (massMod == null) { massMod = action.mass.addModifier(massBuff); } else { massMod.value = massBuff; } rigid.velocity = action.maxSpeedTracker * direction.normalized; active = true; float duration = 0; while (active) { yield return(new WaitForFixedUpdate()); duration += Time.fixedDeltaTime; if (duration > maxDuration) { active = false; } } StartCoroutine(DecaySpeed()); StartCoroutine(DecayAccel()); }
private void InitStats() { // Health health = new FloatStat(100, min: 0, max: 100); // Mana mana = new FloatStat(150, min: 0, max: 150); manaRegen = new FloatStat(2f, min: 0); // Stamina stamina = new FloatStat(3, min: 0, max: 3); staminaRegen = new FloatStat(0.3f, min: 0); // Walk walkData = new PlayerWalkData(new FloatStat(7, min: 0), 0.2f, 0.2f); }
IEnumerator DecayAccel() { float time = 0; while (!active) { time += Time.fixedDeltaTime; accelMod.value = Mathf.Lerp(baseAccelDebuff, 1, time / accelNerfDecayTime); if (time > boostDecayTime) { action.accel.removeModifier(accelMod); accelMod = null; yield break; } yield return(new WaitForFixedUpdate()); } }
IEnumerator DecaySpeed() { float time = 0; while (!active) { time += Time.fixedDeltaTime; float lerpValue = time / boostDecayTime; speedMod.value = Mathf.Lerp(speedMultiplier, 1, lerpValue); massMod.value = Mathf.Lerp(massBuff, 1, lerpValue); if (time > boostDecayTime) { action.maxSpeedTracker.removeModifier(speedMod); action.mass.removeModifier(massMod); speedMod = null; massMod = null; yield break; } yield return(new WaitForFixedUpdate()); } }
public override void InitStats() { AttackData = new AttackData(10); // Basic Basic_Dur.EndTime = new FloatStat(1f, min: 0.01f); Basic_CD.EndTime = new FloatStat(0.5f, min: 0.01f); // Heavy Heavy_AttackData = new AttackData(30); Heavy_StaminaUsage = new FloatStat(1f, min: 0f); Heavy_FullChargeTime = 3f; Heavy_Dur.EndTime = new FloatStat(0.6f, min: 0.01f); // Slam Slam_AttackData = new AttackData(20); Slam_StaminaUsage = new FloatStat(1f, min: 0f); Slam_Dur.EndTime = new FloatStat(0.35f, min: 0.01f); // Dash Dash_AttackData = new AttackData(10); }
public bool removeModifier(FloatStat modifier) { bool returnValue = stats.Remove(modifier); internalUpdate(); return returnValue; }
public void removeModifier(FloatStat modifier) { stats.Remove(modifier); internalUpdate(); }
protected override void OnDeactivate() { base.OnDeactivate(); action.mass.removeModifier(massMod); massMod = null; }
public override void Bind(Unit unit) { base.Bind(unit); moveSpeed = owner.Movement.MoveSpeed; }
public FSQI(FloatStat stat, string modifier, float value = 0.0f, float time = 0.0f, int mode = 0) { this.stat = stat; this.modifier = modifier; this.value = value; this.time = time; this.mode = mode; }
// Damage Type // Absorb Corpse // Penetration // Etc... public AttackData(float damage = 0, GameObject damageDealer = null, bool playHitAnim = false) { this.damage = new FloatStat(damage, min: 0); this.damageDealer = damageDealer; this.playHitAnim = playHitAnim; }
private void OnTriggerStay2D(Collider2D collision) { GameObject other = collision.gameObject; EntityScript otherES = other.GetComponent <EntityScript>(); //Debug.Log(gameObject + "-->" + other); if (gameObject.CompareTag(GameDefaults.Projectile()) && (other.CompareTag(GameDefaults.Obstruction()))) { Destroy(gameObject); return; } if (gameObject.CompareTag(GameDefaults.Projectile()) && other.CompareTag(GameDefaults.Projectile())) { return; } if (gameObject.CompareTag(GameDefaults.Powerup()) && !other.CompareTag(GameDefaults.Player())) { return; } if (other.CompareTag(GameDefaults.Powerup())) { return; } if (other.CompareTag(GameDefaults.Obstruction())) { return; } if (otherES != null) { if (parent != null) { if (other.gameObject.CompareTag(parent.tag) || otherES.parent != null && otherES.parent.gameObject.CompareTag(gameObject.tag)) { return; } } foreach (string effect in impactEffects.Keys) { //Debug.Log(effect); if (effect.Equals("damage")) { if (gameObject.CompareTag(GameDefaults.Enemy())) { if (!gameObject.GetComponent <AiScriptBase>().isDangerous()) { continue; } else { gameObject.GetComponent <AiScriptBase>().setDanger(false); } } if (!otherES.stats.ContainsKey("health")) { continue; } float x = impactEffects["damage"].value; if (otherES.stats.ContainsKey("armor")) { FloatStat FSA = otherES.stats["armor"]; if (FSA.getCompoundValue() >= 100) { x = 0; } else { x = Mathf.Max(x - FSA.getCompoundValue(), 1f); } } FloatStat FSH = otherES.stats["health"]; otherES.controller.damage((int)x); FSH.ChangeWithFactor("baseValue", 0 - x); FSH = new FloatStat("health", Mathf.RoundToInt(FSH.getCompoundValue())); } else if (effect.Equals("healthBoost")) { if (!otherES.stats.ContainsKey("health")) { continue; } float x = impactEffects["health"].value; FloatStat FSH = otherES.stats["health"]; FSH.ChangeWithFactor("baseValue", x); } else { FSQI effectData = impactEffects[effect]; Debug.Log(otherES.stats.ContainsKey(effect).ToString() + effect); if (!otherES.stats.ContainsKey(effect)) { continue; } effectData.ApplyTo(otherES); } } } if (gameObject.CompareTag(GameDefaults.Powerup()) && other.CompareTag(GameDefaults.Player())) { Destroy(gameObject); return; } //Stari kod if (true) //Unity ima ugrađene tagove i layere, zasto si stvarao svoje? { //Projectile collisions if (gameObject.CompareTag(GameDefaults.Projectile())) { //Obstruction if (other.CompareTag(GameDefaults.Obstruction())) { Destroy(gameObject); return; } if (parent != null && !parent.CompareTag(other.gameObject.tag)) { controller.OnTriggerEnter2D(collision); GameObject.Destroy(gameObject); // Wake up any script that is attached to the enemy + navmesh var otherChaser = other.GetComponent <AiScriptBase>(); if (otherChaser != null && !otherChaser.enabled) { otherChaser.enabled = true; other.GetComponent <NavMeshAgent>().enabled = true; } } } //Enemy coll else if (gameObject.CompareTag(GameDefaults.Enemy())) { //Obstruction if (other.CompareTag(GameDefaults.Obstruction())) { //Zid } //Enemy else if (other.CompareTag(GameDefaults.Enemy())) { //var es = other.gameObject.GetComponent<EntityScript>(); } //Player else if (other.gameObject.CompareTag(GameDefaults.Player())) { if (controller != null && collision != null) { controller.OnTriggerEnter2D(collision); } } } else if (gameObject.CompareTag(GameDefaults.Player())) { if (other.gameObject.CompareTag(GameDefaults.LevelExit())) { if (controller != null && collision != null) { controller.OnTriggerEnter2D(collision); } } } } }