protected override void Awake() { base.Awake(); //get components pathUnit = GetComponent <Unit2D> (); //get the children biteDamager = transform.GetChild(0).gameObject; //internal stuff behaviour = Behaviour.NORMAL; durability.maxHealthPoints = 4; durability.healthPoints = 4; durability.invincibleWindow = 0.5f; //set callbacks Durability.callback onDmg = durability.onDamaged; durability.onDamaged = (int diff) => { if (onDmg != null) { onDmg(diff); } FlashColor(1, 0, 0, 0.1f); }; Durability.callback onHld = durability.onHealed; durability.onHealed = (int diff) => { if (onHld != null) { onHld(diff); } FlashColor(0, 1, 0, 0.1f); }; }
// Use this for initialization void Awake() { animator = GetComponent <Animator> (); boxCollider = GetComponent <BoxCollider2D> (); durability = GetComponent <Durability> (); rigidBody = GetComponent <Rigidbody2D> (); spriteRenderer = GetComponent <SpriteRenderer> (); unit2D = GetComponent <Unit2D> (); unit2D.speed = 0.4f; durability.maxHealthPoints = 3; durability.healthPoints = 3; durability.onDamaged = (int diff) => { GameObject.Find("GamePlay").GetComponent <AudioPlayer>().PlayHurtSound(); FlashColor(0.5f, 0, 0, 0.1f); }; durability.onHealed = (int diff) => { FlashColor(0, 1, 0, 0.1f); }; durability.onDestruction = (int diff) => { GameObject.Find("GamePlay").GetComponent <AudioPlayer>().PlayKillSound(); GameObject treasure = Instantiate(treasurePrefab); treasure.transform.position = transform.position; Destroy(gameObject); }; StartCoroutine(ShootFireball()); StartCoroutine(ResetPath()); }
public CharacterEnemyBase() { if (ready) { // caracter = new caracter("enemy", game); unit = new Unit2D("enemy", game); } }
public static void colision(Unit2D player) { foreach (var item in list) { if (item.unit.rectangle.Intersects(player.rectangle)) { item.ifcolide(1); } } }
public void init(string entity) { if (ready) { unit = new Unit2D(entity, game); management.register(this); } else { Error.error.basicError(4); } }
public virtual void draw() { Vars.spriteBatch.Draw(Unit2D.getTexture("grass", game) /*ShaderResourceView.FromFile(device, "accel_world_007.jpg")*/, pos, Color.Beige); }