/// <summary> /// Code for the action that gets called in OldMan's update /// </summary> /// <param name="om">The Old Man script</param> public override void ExecuteAction(OldMan om) { if (!Active || Completed) { return; } //State control switch (state) { case StandState.Walking: if (!om.Agent.pathPending && om.Agent.remainingDistance < 0.3f) { state = StandState.Standing; } break; case StandState.Standing: //Infinite stand if (standLength <= 0) { return; } //Timed stand timer += Time.deltaTime; if (timer > standLength) { CompleteAction(); } break; } }
/// <summary> /// Stop this action /// </summary> /// <param name="om">The OldMan's object</param> public virtual void StopAction(OldMan om) { Active = false; if (thoughtItem != null) { om.EndThought(); } }
/// <summary> /// Start this action /// </summary> /// <param name="om">The OldMan object</param> public override void StartAction(OldMan om) { base.StartAction(om); if (state == MoveToState.WalkingTo) { SetNextPoint(om, goalPoint); } }
/// <summary> /// Start this stand action /// </summary> /// <param name="om">The OldMan object</param> public override void StartAction(OldMan om) { base.StartAction(om); if (standPoint != null) { om.Agent.autoBraking = true; om.Agent.destination = standPoint.Value; } }
void addEnemy(String line) { String[] split = line.Split(','); IEnemy enemy; float x = ((Int32.Parse(split[1]) - 1) * blockBaseDimension * blockSizeMod) + screenX + (2 * blockBaseDimension * blockSizeMod); float y = ((Int32.Parse(split[2]) - 1) * blockBaseDimension * blockSizeMod) + screenY + (2 * blockBaseDimension * blockSizeMod); switch (split[0]) { case "aquamentus": enemy = new AquamentusEnemy(sprites["aquamentus"], new Vector2(x, y)); break; case "gel": enemy = new GelEnemy(sprites["basicenemy"], new Vector2(x, y)); break; case "goriya": enemy = new GoriyaEnemy(sprites["goriya"], sprites["PlayerProjectiles"], new Vector2(x, y)); break; case "keese": enemy = new KeeseEnemy(sprites["basicenemy"], new Vector2(x, y)); break; case "oldman": enemy = new OldMan(sprites["oldman"], new Vector2(x + 8, y)); break; case "stalfos": enemy = new StalfosEnemy(sprites["basicenemy"], new Vector2(x, y)); break; case "trap": enemy = new TrapEnemy(sprites["basicenemy"], new Vector2(x, y)); break; case "wallmaster": enemy = new WallmasterEnemy(sprites["wallmasters"], new Vector2(x, y)); break; default: enemy = null; break; } Enemies.Add(enemy); //Store into temp Variables for ESpawner tempWord = split[0]; tempX = x; tempY = y; }
void SetNextPoint(OldMan om, OM_MoveData point) { //Only slow down the Old Man if they have to wait at the point if (point.WaitAfterReaching > 0) { om.Agent.autoBraking = true; } else { om.Agent.autoBraking = false; } // Send the NavMesh agent to that point om.Agent.destination = point.Point; }
/// <summary> /// Start this action /// </summary> /// <param name="om">The OldMan object</param> public virtual void StartAction(OldMan om) { Active = true; Fresh = false; //Set the correct thought bubble status if (thoughtItem != null) { om.thoughtItem.sprite = thoughtItem; om.StartThought(); } else { om.EndThought(); } }
public override void Paint(Level level) { var c = GetTileCenter(); var stand = new ItemStand(); level.Area.Add(stand); stand.Center = c * 16 + new Vector2(8, 16); stand.SetItem(Items.CreateAndAdd(Items.Generate(ItemPool.Secret), level.Area), null); var npc = new OldMan { RickRoll = Rnd.Chance(5) }; level.Area.Add(npc); npc.BottomCenter = c * 16 + new Vector2(8, -8); }
/// <summary> /// Code for the action that gets called in OldMan's update /// </summary> /// <param name="om">The Old Man script</param> public override void ExecuteAction(OldMan om) { if (!Active || Completed) { return; } //State control switch (state) { //Wait for a set amount of seconds before walking to the point case MoveToState.WaitingBefore: waitTimer += Time.deltaTime; if (waitTimer > waitBeforeMoving) { state = MoveToState.WalkingTo; SetNextPoint(om, goalPoint); } break; //Walk to the point case MoveToState.WalkingTo: if (!om.Agent.pathPending && om.Agent.remainingDistance < 0.3f) { //Wait if there is a value passed in, otherwise start walking back if (goalPoint.WaitAfterReaching > 0) { waitTimer = 0; state = MoveToState.WaitingAt; } else { CompleteAction(); } } break; //Wait for a set amount of seconds before walking back case MoveToState.WaitingAt: waitTimer += Time.deltaTime; if (waitTimer > goalPoint.WaitAfterReaching) { CompleteAction(); } break; } }
/// <summary> /// Code for the action that gets called in OldMan's update /// </summary> /// <param name="om">The Old Man script</param> public override void ExecuteAction(OldMan om) { if (!Active || Completed || animLength == 0) { return; } //Wait till animation is over if (timer < animLength) { timer += Time.deltaTime; } else { CompleteAction(); } }
/// <summary> /// Code for the action that gets called in OldMan's update /// </summary> /// <param name="om">The Old Man script</param> public override void ExecuteAction(OldMan om) { if (!Active || Completed || GameManager.Instance.OldManDead) { return; } timer += Time.deltaTime; if (!GameManager.Instance.player.IsNearOldMan) { CompleteAction(); PuzzleManager.Instance.OM_inDanger = false; } if (timer >= deathTotal) { GameManager.Instance.KillOldMan(); } }
void SetNextPoint(OldMan om, bool incrementTarget = true) { //Increment target, but keep it in bounds if (incrementTarget) { target = (target + 1) % points.Length; } //Only slow down the Old Man if they have to wait at the point if (points[target].WaitAfterReaching > 0) { om.Agent.autoBraking = true; } else { om.Agent.autoBraking = false; } // Send the NavMesh agent to that point om.Agent.destination = points[target].Point; }
/// <summary> /// Code for the action that gets called in OldMan's update /// </summary> /// <param name="om">The Old Man script</param> public override void ExecuteAction(OldMan om) { if (!Active || Completed) { return; } //State control switch (state) { case PathState.Walking: if (!om.Agent.pathPending && om.Agent.remainingDistance < 0.3f) { //Wait if there is a value passed in, otherwise go to the next point if (points[target].WaitAfterReaching > 0) { waitTimer = 0; state = PathState.Waiting; } else { SetNextPoint(om); } } break; //Wait for a set amount of seconds case PathState.Waiting: waitTimer += Time.deltaTime; if (waitTimer > points[target].WaitAfterReaching) { state = PathState.Walking; SetNextPoint(om); } break; } }
private static void SpawnFromString(IRoom room, SpriteBatch spriteBatch, string spawnType, int offsetX, int offsetY, int gridX, int gridY) { int posX = offsetX + gridX * RoomConstants.TileLength; int posY = offsetY + gridY * RoomConstants.TileLength; Point position = new Point(posX, posY); IBlock blockType; INpc npcType; IItem itemType; IBackground backgroundType; switch (spawnType) { //Blocks case RoomConstants.Block: blockType = new Square(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.BrickTile: blockType = new BrickTile(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.GapTile: blockType = new GapTile(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.Fire: position.X += RoomConstants.TileLength / 2; blockType = new Fire(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.LadderTile: backgroundType = new LadderTile(spriteBatch, position); room.AllObjects.Spawn(backgroundType); break; case RoomConstants.Stairs: blockType = new Stairs(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.FishStatue: blockType = new FishStatues(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.DragonStatue: blockType = new DragonStatues(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.BlueGrass: backgroundType = new TileBlueGrass(spriteBatch, position); room.AllObjects.Spawn(backgroundType); break; case RoomConstants.Water: blockType = new TileWater(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.MovableBlock: blockType = new MovableSquare(spriteBatch, position); ((RoomWithMovableSquare)room).AddMovableSquare((MovableSquare)blockType); room.AllObjects.Spawn(blockType); break; //Npcs case RoomConstants.Aquamentus: position.Y += RoomConstants.TileLength / 2; npcType = new Aquamentus(spriteBatch, position, room.AllObjects); room.AllObjects.Spawn(npcType); break; case RoomConstants.Bat: npcType = new Bat(spriteBatch, position); room.AllObjects.Spawn(npcType); break; case RoomConstants.Goriya: npcType = new Goriya(spriteBatch, position, room.AllObjects); room.AllObjects.Spawn(npcType); break; case RoomConstants.Hand: npcType = new Hand(spriteBatch, position, ((RoomWallMaster)room).GetWallMasterRoomToJumpTo()); room.AllObjects.Spawn(npcType); break; case RoomConstants.Jelly: npcType = new Jelly(spriteBatch, position); room.AllObjects.Spawn(npcType); break; case RoomConstants.OldMan: position.X += RoomConstants.TileLength / 2; npcType = new OldMan(spriteBatch, position); room.AllObjects.Spawn(npcType); break; case RoomConstants.Skeleton: npcType = new Skeleton(spriteBatch, position); room.AllObjects.Spawn(npcType); break; case RoomConstants.SpikeTrap: npcType = new SpikeTrap(spriteBatch, position, room.AllObjects.GetPlayer(0)); room.AllObjects.Spawn(npcType); break; //Items case RoomConstants.Compass: itemType = new CompassItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; case RoomConstants.Heart: position.X += (int)(4 * RoomConstants.SpriteMultiplier); position.Y += (int)(4 * RoomConstants.SpriteMultiplier); itemType = new HeartItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; case RoomConstants.Key: itemType = new KeyItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; case RoomConstants.Map: itemType = new MapItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; case RoomConstants.Triforce: position.X += (int)(12 * RoomConstants.SpriteMultiplier); position.Y += (int)(2 * RoomConstants.SpriteMultiplier); itemType = new TriforceItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; case RoomConstants.HeartContainer: itemType = new HeartContainerItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; case RoomConstants.Bow: itemType = new BowItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; default: break; } }
/// <summary> /// Start this near player action /// </summary> /// <param name="om">The OldMan object</param> public override void StartAction(OldMan om) { base.StartAction(om); om.Agent.ResetPath(); }
/// <summary> /// Code for the action that gets called in OldMan's update /// </summary> /// <param name="om">The Old Man object</param> public virtual void ExecuteAction(OldMan om) { }
public override void StartAction(OldMan om) { base.StartAction(om); SetNextPoint(om, false); }
/// <summary> /// Start this stand action /// </summary> /// <param name="om">The OldMan object</param> public override void StartAction(OldMan om) { base.StartAction(om); om.animator.Play(animName); timer = 0; }
// Use this for initialization void Start() { oldMan = GetComponentInParent <OldMan> (); }
/// <summary> /// Stop this action /// </summary> /// <param name="om">The OldMan's object</param> public override void StopAction(OldMan om) { base.StopAction(om); }