public bool Shoot(int originx, int originy, int dirx, int diry, int shooterId, bool ignoreAmmo) { if (ammoCount > 0 || ignoreAmmo) { var item = new SHRLitem(app, originx, originy); item.SetBullet(); item.Launch(shooterId, dirx, diry, 1); app.AddEntity(item); if (!ignoreAmmo) { ammoCount--; } app.pendingTicks += 1; return(true); } else { if (ammoCount == 0) { ammoCount--; app.Popup("no ammo", originx, originy); return(true); } else { return(false); } } }
public override void Draw() { SHRLitem b = app.GetKillingOrStunningItem(x, y); if (b != null && b.ownerid != id) { if (b.killsOnContact) { Kill(); } b.Stop(); } char g = '@'; if (item != null) { g = item.gfx2; } if (app.shooting && isPlayer) { app.DrawCharFaded(g, x, y, (Time.realtimeSinceStartup % .2f > .1f)?('r'):('w'), true); } else { app.DrawCharFaded(g, x, y, color, true); } /* * if (item != null) { * item.x = this.x + dirx; * item.y = this.y + diry; * * item.x = this.x; * item.y = this.y; * * if (Time.realtimeSinceStartup % .4f < .1f) * item.Draw(offx, offy); * } */ }
public override void Update(int ticks) { SHRLentity e = app.GetEntity(x, y); if (e != null && !fading) { SHRLenemy E = (e as SHRLenemy); if (E != null && E.id != ownerid) { if (stunsOnContact || killsOnContact) { E.Kill(); Stop(); } } } if (flying && !fading) { SHRLitem I = app.GetShatterableItem(x, y, id); if (I != null) { I.Stop(); this.Stop(); } else { if (app.GetTile(x, y) == 3) { this.Stop(); app.SetTile(0, x, y); } } } if (!fading) { flySpeedTimer--; if (flying && flySpeedTimer <= 0) { x += dirx; y += diry; traillenght++; if (traillenght > 3) { traillenght = 3; } if (app.GetTile(x, y) == 1) { Stop(); } flySpeedTimer = flySpeed; } } else { traillenght--; if (traillenght < 0) { del = true; } } }
void LoadLevel(string levelName) { string levelString = SHGUI.current.GetASCIIartByName(levelName); level = new int[levelWidth * levelHeight]; int x = 0; int y = 0; for (int i = 0; i < levelString.Length; ++i) { if (levelString[i] == '\n') { x = 0; y++; continue; } if (levelString[i] == '#') { SetTile(1, x, y); } else if (levelString[i] == '.') { SetTile(2, x, y); } else if (levelString[i] == '=') { SetTile(3, x, y); } else if (levelString[i] == 'G') { var e = new SHRLenemy(this, x, y); e.item = new SHRLgun(this, x, y); (e.item as SHRLgun).SetPistol(); entities.Add(e); SetTile(0, x, y); } else if (levelString[i] == 'T') { var e = new SHRLenemy(this, x, y); e.item = new SHRLgun(this, x, y); (e.item as SHRLgun).SetPistol(); e.SetHorizontal(false); entities.Add(e); SetTile(0, x, y); } else if (levelString[i] == 'F') { var e = new SHRLenemy(this, x, y); entities.Add(e); SetTile(0, x, y); } else if (levelString[i] == 'R') { var e = new SHRLenemy(this, x, y); entities.Add(e); e.SetHorizontal(false); SetTile(0, x, y); } else if (levelString[i] == 'g') { SHRLgun g = new SHRLgun(this, x, y); g.SetPistol(); entities.Add(g); } else if (levelString[i] == '&') { SHRLitem g = new SHRLitem(this, x, y); g.SetThrowable(); entities.Add(g); } else if (levelString[i] == '@') { player = new SHRLenemy(this, x, y); player.color = 'w'; player.isPlayer = true; entities.Add(player); SetTile(0, x, y); } x++; } }