Created
April 1, 2021 20:17
-
-
Save Jakz/0ac31bfab706d2924e1863fbea535e3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Test | |
{ | |
enum EffectType | |
{ | |
Freeze, Stun, Slow | |
}; | |
class EffectList | |
{ | |
class EffectTimer | |
{ | |
public EffectType type; | |
public float speedMultiplier; | |
public float timer; | |
}; | |
private List<EffectTimer> effects; | |
public EffectList() | |
{ | |
effects = new List<EffectTimer>(); | |
} | |
public void Update(float dt) | |
{ | |
foreach (EffectTimer effect in effects) | |
effect.timer -= dt; | |
effects.RemoveAll(effect => effect.timer < 0.0f); | |
} | |
public void Clear() | |
{ | |
effects.Clear(); | |
} | |
public void AddEffect(EffectType type, float seconds) | |
{ | |
Clear(); | |
foreach(EffectTimer leffect in effects) | |
{ | |
if (leffect.type == type && leffect.timer < seconds) | |
{ | |
leffect.timer = seconds; | |
return; | |
} | |
} | |
EffectTimer effect = new EffectTimer(); | |
effect.type = type; | |
effect.timer = seconds; | |
effects.Add(effect); | |
} | |
public bool HasEffect(EffectType type) | |
{ | |
EffectTimer result = effects.Find(effect => effect.type == type); | |
return result != null; | |
} | |
} | |
class EffectSpec | |
{ | |
EffectType type; | |
float timer; | |
public EffectSpec(EffectType type, float timer) { this.timer = timer; } | |
public static EffectSpec STUN = new EffectSpec(EffectType.Freeze, 5.0f); | |
public static | |
}; | |
class Player | |
{ | |
EffectType type; | |
float effectTimer; | |
void updateEffect(float dt) | |
{ | |
if (type != null) | |
{ | |
effectTimer -= dt; | |
if (effectTimer < 0) | |
EffectSpec.STUN | |
} | |
} | |
void hurt(float amount, DamageType type) | |
{ | |
} | |
void heal(float amount) | |
{ | |
} | |
bool isDead() | |
{ | |
return false; | |
} | |
} | |
enum BulletType { Fireball } | |
enum DamageType { }; | |
class DamageSpec | |
{ | |
public float amount; | |
DamageType type; | |
} | |
class Bullet | |
{ | |
//BulletType type; | |
private EffectSpec potentialEffect; | |
DamageSpec potentialDamage; | |
public Bullet() | |
{ | |
} | |
public void setEffect(EffectSpec effect) | |
{ | |
potentialEffect = effect; | |
} | |
public void OnPlayerCollision(Player player) | |
{ | |
if (potentialEffect != null) | |
{ | |
player.effects.addEffect(potentialEffect.type, potentialEffect.timer); | |
if (player.effects.hasEffect(EffectType.Freeze)) | |
{ | |
} | |
} | |
if (potentialDamage != null) | |
player.damage(potentialDamage.amount); | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Bullet bullet; | |
bullet.setEffect(null); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment