private void UpdateStats(float percentage) { healthPool.onDamaged -= OnDamage; // curLayer = StatLayer.Lerp(minRollLayer, maxRollLayer, percentage); statKeeper.selfStats.addLayer(PV.ViewID, curLayer); // healthPool.onDamaged += OnDamage; }
/// <summary> /// /// </summary> /// <param name="minLayer"></param> /// <param name="maxLayer"></param> /// <param name="percentage">A value between 0 and 1. 0: minLayer, 0.5: in between, 1: maxLayer</param> /// <returns></returns> public static StatLayer Lerp(StatLayer minLayer, StatLayer maxLayer, float percentage) { StatLayer layer = new StatLayer(); layer.moveSpeed = LerpStat(minLayer.moveSpeed, maxLayer.moveSpeed, percentage); layer.maxHits = LerpStat(minLayer.maxHits, maxLayer.maxHits, percentage); layer.fireRate = LerpStat(minLayer.fireRate, maxLayer.fireRate, percentage); layer.damage = LerpStat(minLayer.damage, maxLayer.damage, percentage); layer.size = LerpStat(minLayer.size, maxLayer.size, percentage); return(layer); }
public StatLayer Add(StatLayer addend) { StatLayer layer = new StatLayer(); layer.moveSpeed = AddStat(this.moveSpeed, addend.moveSpeed); layer.maxHits = AddStat(this.maxHits, addend.maxHits); layer.fireRate = AddStat(this.fireRate, addend.fireRate); layer.damage = AddStat(this.damage, addend.damage); layer.size = AddStat(this.size, addend.size); return(layer); }
public StatLayer Multiply(StatLayer multiplier) { StatLayer layer = new StatLayer(); layer.moveSpeed = MultiplyStat(this.moveSpeed, multiplier.moveSpeed); layer.maxHits = MultiplyStat(this.maxHits, multiplier.maxHits); layer.fireRate = MultiplyStat(this.fireRate, multiplier.fireRate); layer.damage = MultiplyStat(this.damage, multiplier.damage); layer.size = MultiplyStat(this.size, multiplier.size); return(layer); }
//TODO: Potentially remove this method and refactor the thing that uses it public StatLayer Charge(float multiplier, StatLayer percentage) { StatLayer layer = new StatLayer(); layer.moveSpeed = ChargeStat(this.moveSpeed, multiplier, percentage.moveSpeed); layer.maxHits = ChargeStat(this.maxHits, multiplier, percentage.maxHits); layer.fireRate = ChargeStat(this.fireRate, multiplier, percentage.fireRate); layer.damage = ChargeStat(this.damage, multiplier, percentage.damage); layer.size = ChargeStat(this.size, multiplier, percentage.size); return(layer); }
public StatLayer Add(float addend) { if (addend == 0) { throw new ArgumentException($"addend is 0! {addend}"); } StatLayer layer = new StatLayer(); layer.moveSpeed = AddStat(this.moveSpeed, addend); layer.maxHits = AddStat(this.maxHits, addend); layer.fireRate = AddStat(this.fireRate, addend); layer.damage = AddStat(this.damage, addend); layer.size = AddStat(this.size, addend); return(layer); }
public StatLayer Multiply(float multiplier) { if (multiplier < 0) { throw new ArgumentException($"multiplier is less than 0! {multiplier}"); } StatLayer layer = new StatLayer(); layer.moveSpeed = MultiplyStat(this.moveSpeed, multiplier); layer.maxHits = MultiplyStat(this.maxHits, multiplier); layer.fireRate = MultiplyStat(this.fireRate, multiplier); layer.damage = MultiplyStat(this.damage, multiplier); layer.size = MultiplyStat(this.size, multiplier); return(layer); }
void explode() { List <Rigidbody2D> rb2ds = new List <Rigidbody2D>(); RaycastHit2D[] rch2ds = Physics2D.CircleCastAll(transform.position, explodeRange, Vector2.zero); for (int i = 0; i < rch2ds.Length; i++) { Rigidbody2D rb2d = rch2ds[i].rigidbody; if (!rb2d) { continue; } if (!rb2ds.Contains(rb2d)) { rb2ds.Add(rb2d); } } foreach (Rigidbody2D rb2d in rb2ds) { HealthPool hp = rb2d.gameObject.FindComponent <HealthPool>(); if (hp && entityTypes.Contains(hp.entityType)) { Vector2 explodeDir = (rb2d.transform.position - transform.position).normalized; Vector2 explodeVector = explodeDir * explodePower; rb2d.velocity = explodeVector; //PlayerMovement PlayerMovement playerMovement = rb2d.gameObject.FindComponent <PlayerMovement>(); if (playerMovement) { //TODO: refactor this once MovementLayer has been implemented float speed = explodePower / playerMovement.MovementSpeed; playerMovement.forceMovement(explodeVector, true); int viewID = gameObject.FindComponent <PhotonView>().ViewID; StatLayer statLayer = new StatLayer(StatLayer.STAT_IGNORE) { moveSpeed = speed }; StatKeeper statKeeper = playerMovement.gameObject.FindComponent <StatKeeper>(); statKeeper.selfStats.addLayer(viewID, statLayer); TimerManager.StartTimer(forceMoveDuration, () => { playerMovement.forceMovement(false); statKeeper.selfStats.removeLayer(viewID); }); } } } }
private static object DeserializeStatLayer(StreamBuffer inStream, short length) { StatLayer sl = new StatLayer(); lock (memStatLayer) { inStream.Read(memStatLayer, 0, length);// byteArraySize); int index = 0; Protocol.Deserialize(out sl.moveSpeed, memStatLayer, ref index); Protocol.Deserialize(out sl.maxHits, memStatLayer, ref index); Protocol.Deserialize(out sl.fireRate, memStatLayer, ref index); Protocol.Deserialize(out sl.damage, memStatLayer, ref index); Protocol.Deserialize(out sl.size, memStatLayer, ref index); } return(sl); }
private static short SerializeStatLayer(StreamBuffer outStream, object customobject) { StatLayer sl = (StatLayer)customobject; lock (memStatLayer) { byte[] bytes = memStatLayer; int index = 0; Protocol.Serialize(sl.moveSpeed, bytes, ref index); Protocol.Serialize(sl.maxHits, bytes, ref index); Protocol.Serialize(sl.fireRate, bytes, ref index); Protocol.Serialize(sl.damage, bytes, ref index); Protocol.Serialize(sl.size, bytes, ref index); outStream.Write(bytes, 0, byteArraySize); } return(byteArraySize); }
void RPC_UpdateStats(StatLayer selfStats) { GetComponentInChildren <StatKeeper>().selfStats.Stats = selfStats; }
protected override void InitializeSettings() { base.InitializeSettings(); //Init layers minRollLayer = new StatLayer(1); }