// CTOR public Character( string name, int level, int maxHp) { Name = name; Level = level; Health = new HpMp(maxHp); Turn = false; }
public override DataStream Deserialize(DataStream ds) { WorldId = ds.ReadUInt32(); Hp = ds.Read <HpMp>(); return(base.Deserialize(ds)); }
void OnTriggerEnter2D(Collider2D collision) { if (((1 << collision.gameObject.layer) & whatToHit) != 0) // Checking if we want to hit the object { HpMp colliderHealth = collision.GetComponent <HpMp>(); // Getting the collided object's health script // Sometimes we want to destroy the projectile but the object doesn't have health try { colliderHealth.TakeDamage(damage); // Dealing the damage } catch (System.NullReferenceException) { } Destroy(this.gameObject); Vector2 destructionPosition = new Vector2(this.transform.position.x, this.transform.position.y); if (destroyedParticles != null) { var particle = Instantiate(destroyedParticles, destructionPosition, this.transform.rotation); ParticleSystem particleSystem = destroyedParticles.GetComponent <ParticleSystem>(); Destroy(particle.gameObject, particleSystem.main.duration); } } }
public override DataStream Deserialize(DataStream ds) { RoleId = ds.ReadUInt32(); Level = ds.ReadInt16(); Unk1 = ds.ReadByte(); Unk2 = ds.ReadByte(); Hp = ds.Read <HpMp>(); Mp = ds.Read <HpMp>(); if (ds.CanReadBytes()) { NextTarget = ds.ReadUInt32(); } return(base.Deserialize(ds)); }