public DirChange(Entity entity, Dir9 from, Dir9 to, bool isSmooth) { this.entity = entity; this.from = from; this.to = to; this.isSmooth = isSmooth; }
public Talk(Entity from, Entity to, Dir9 dir, string text) { this.from = from; this.to = to; this.dir = dir; this.text = text; }
public ITweenable turn(Entity e, Dir9 to) { var body = e.get <Body>(); if (body.facing == to) { return(null); } var anim = new Tw.Turn(e, to, EaseType.Linear, ViewPreferences.turnDirDuration); return(anim); }
public ITween <Vector2>[] swing(Entity entity, Dir9 to, float duration) { var body = entity.get <Body>(); var offset = new Vector2(0, 0); var deltaPos = body.facing.vector2 * posUtil.tileSize / 2; var ease = EaseType.QuintOut; var chip = entity.get <CharaView>().chipAnim; var first = chip.tweenLocalOffset(offset + deltaPos, duration, ease); var second = chip.tweenLocalOffset(offset, duration, ease); return(new ITween <Vector2>[] { first, second }); }
/// <summary> Walk animations (made before actually walking) </summary> public ITweenable walk(Entity entity, Vec2i to) { var body = entity.get <Body>(); var from = body.pos; var nextDir = (Dir9)Dir9.fromVec2i(to - from); // FIXME: lazily change facing or outsource it this.changeDir(entity, nextDir); var nextPosWorld = posUtil.gridToWorldCentered(to); var tween = new Tw.Walk(entity.Transform, ViewPreferences.walkDuration, nextPosWorld, ViewPreferences.walkEase); return(tween); }
public void genStair(StaticGod god) { var posUtil = god.posUtil; var entities = god.gameCx.entities; var stairGen = EntityFactory.begin(god.scene, EntityNames.stair, posUtil); stairGen.entity.SetParent(god.scene.FindEntity(EntityNames.tiled)); entities.Add(stairGen .body(gen.randomPosInRoom(god.gameCx), Dir9.random(), false, false) .viewWodi8(Content.Chips.Wodi8.Cook_a) .add(new Stair(Stair.Kind.Downstair)) .entity ); }
/// <summary> Maps directional input to events depending on mode </summary> RlEvent handleDir(Dir9 dir) { if (this.diaMode.isOn && dir.isCardinal) { return(null); // filtered } var body = this.controller.actor.get <Body>(); // TODO: remove game logic from the controller if (!this.dirMode.isOn && new RlLogic(this.gameCtx).canWalkIn(this.controller.actor, dir)) { return(new RlEv.Walk(this.controller.actor, dir)); } else { return(RlEv.DirChange.smooth(this.controller.actor, dir).noConsumeTurn()); } }
public void genEnemies(StaticGod god) { var posUtil = god.posUtil; var entities = god.gameCx.entities; int N = Nez.Random.Range(3, 7); for (int i = 0; i < N; i++) { var enemyGen = EntityFactory.begin(god.scene, $"actor_{i}", posUtil); enemyGen.entity.SetParent(god.scene.FindEntity(EntityNames.tiled)); entities.Add(enemyGen .body(gen.randomPosInRoom(god.gameCx), Dir9.random(), true, false) .actor(new Beh.RandomWalk(enemyGen.entity), 3) .viewWodi8(Content.Chips.Pochi.Animals.Usagi02) .performance(50, 10, 5) .entity ); continue; } }
/// <summary> Updates input mode and maybe creates directional modification for the player controllerd </summary> RlEvent updateModes(VInput input) { this.diaMode.update(input); var result = this.dirMode.update(input); if (result != KeyMode.Switch.TurnOn) { return(null); } if (PlayerControl.findOnlyNeighbor(this.controller.actor, this.gameCtx) is Entity neighbor) { var entity = this.controller.actor; var dir = Dir9.fromVec2i(neighbor.get <Body>().pos - entity.get <Body>().pos); return(RlEv.DirChange.smooth(entity, dir).noConsumeTurn()); } else { return(null); } }
public CharaView setDir(Dir9 dir) { return(this.setDir(dir.toEDir8())); }
public static CharaView wodi8(Entity entity, PosUtil posUtil, Texture2D texture, Vec2i pos, Dir9 dir) { var chip = Charachip.wodi8(entity, posUtil, texture); return(entity.add(new CharaView(chip)).snapToGridPos(pos).setDir(dir)); }
public static void rm(this Adjacency8 self, Dir9 dir) { self &= (Adjacency8)dir.asIndexClockwise; }
RlEvent iBehavior.make() { var dir = Dir9.random(); return(new RlEv.Walk(entity, dir)); }
VKeyResult(Kind kind, VKey?key, Dir9 dir) { this.kind = kind; this.dir = dir; this.key = key; }
public static VKeyResult newDir(Dir9 dir) { return(new VKeyResult(Kind.Dir, null, dir)); }
public JustSwing(Entity entity, Dir9?dir = null) { this.entity = entity; this.dir = dir ?? entity.get <Body>().facing; }
public static DirChange smooth(Entity entity, Dir9 to) { return(new DirChange(entity, entity.get <Body>().facing, to, isSmooth: true)); }
public Interact(Entity e, Dir9 d) { (this.entity, this.dir) = (e, d); }
public static DirChange quick(Entity entity, Dir9 to) { return(new DirChange(entity, entity.get <Body>().facing, to, isSmooth: false)); }
/// <summary> Changes the direction of image of the entity </summary> public void changeDir(Entity entity, Dir9 dir) { entity.get <CharaView>().setDir(dir); }
public WalkInObstacle(Entity e, Dir9 d) { (this.entity, this.dir) = (e, d); }
public Walk(Entity e, Dir9 d) { (this.entity, this.dir) = (e, d); }
public EntityFactory body(Vec2i pos, Dir9 dir, bool isBlocker, bool isDiagonalBlocker) { this.entity.add(new Body(pos, dir, isBlocker, isDiagonalBlocker)); return(this); }
public MeleeAttack(Entity entity, Dir9?dir = null) { this.entity = entity; this.dir = dir ?? entity.get <Body>().facing; }