private void OnWinnersDetermined(Fight fight, FightTeam winners, FightTeam losers, bool draw) { fight.WinnersDetermined -= new Fight.FightWinnersDelegate(this.OnWinnersDetermined); if (!draw && (winners is FightPlayerTeam && losers is FightMonsterTeam)) { MonsterGroup group = ((MonsterFighter)losers.Leader).Monster.Group; if (!this.m_groupsSpawn.ContainsKey(group)) { DungeonSpawningPool.logger.Error <int, int>("Group {0} (Map {1}) has ended his fight but is not register in the pool", group.Id, base.Map.Id); } else { MonsterDungeonSpawn monsterDungeonSpawn = this.m_groupsSpawn[group]; if (monsterDungeonSpawn.TeleportEvent) { ObjectPosition teleportPosition = monsterDungeonSpawn.GetTeleportPosition(); foreach (CharacterFighter current in winners.GetAllFighters <CharacterFighter>()) { current.Character.NextMap = teleportPosition.Map; current.Character.Cell = teleportPosition.Cell; current.Character.Direction = teleportPosition.Direction; this.m_groupsSpawn.Remove(group); } } } } }
public virtual BaseObject GetSibling(ObjectPosition objectPosition) { // throw new NotImplementedException("You must override in inherited class!"); var parentCollection = this.Parent as IEnumerable <BaseObject>; if (parentCollection == null) { return(null); } int index = -1; switch (objectPosition) { case ObjectPosition.First: return(parentCollection.FirstOrDefault()); case ObjectPosition.Next: index = parentCollection.IndexOf(this); return(parentCollection.ElementAt(index + 1)); case ObjectPosition.Previous: index = parentCollection.IndexOf(this); return(parentCollection.ElementAt(index - 1)); case ObjectPosition.Last: return(parentCollection.LastOrDefault()); default: break; } return(null); }
public void SetResults(MaskType type, MaskResult result, ObjectPosition op) { this.DynamicThresholdCount = op.Counter; this.PercentMatch = op.LastPercentMatch; this.SetResults(type, result); }
public override void Execute(TriggerBase trigger) { var template = trigger.Get <NpcTemplate>("npc"); ObjectPosition position = null; if (trigger.IsArgumentDefined("map") && trigger.IsArgumentDefined("cell") && trigger.IsArgumentDefined("direction")) { var map = trigger.Get <Map>("map"); var cell = trigger.Get <short>("cell"); var direction = trigger.Get <DirectionsEnum>("direction"); position = new ObjectPosition(map, cell, direction); } else if (trigger is GameTrigger) { position = (trigger as GameTrigger).Character.Position; } if (position == null) { trigger.ReplyError("Position of npc is not defined"); return; } var npc = position.Map.SpawnNpc(template, position, template.Look); trigger.Reply("Npc {0} spawned", npc.Id); }
public IEnumerator createArrow() { yield return(new WaitForSeconds(3)); float lat_d = GameManager.Instance.playerGeoPosition.lat_d; float lon_d = GameManager.Instance.playerGeoPosition.lon_d; Transform pa = Instantiate(playerArrowContainer); pa.gameObject.SetActive(true); ObjectPosition opPlayer = pa.gameObject.AddComponent <ObjectPosition>(); GeoPoint gpPlayer = new GeoPoint(lat_d, lon_d); opPlayer.setPositionOnMap(gpPlayer); MeshRenderer mrPlayer = pa.Find("PlayerArrow").GetComponent <MeshRenderer> (); foreach (Material m in mrPlayer.materials) { m.color = new Color32(159, 239, 72, 200); } MeshRenderer mrPlayerInternal = pa.Find("PlayerArrow/Mesh").GetComponent <MeshRenderer> (); foreach (Material m in mrPlayerInternal.materials) { m.color = new Color32(159, 239, 72, 200); } StopCoroutine(createArrow()); }
public MonsterGroup(int id, ObjectPosition position, SpawningPoolBase spawningPool = null) { ContextualId = id; Position = position; CreationDate = DateTime.Now; SpawningPool = spawningPool; }
public InteractiveObject(Map map, InteractiveSpawn spawn) { Spawn = spawn; Position = new ObjectPosition(map, spawn.CellId); GenerateSkills(); }
public void movePlayerToInitialPosition() { ObjectPosition opPlayer = player.gameObject.GetComponent <ObjectPosition>(); GeoPoint gpPlayer = new GeoPoint(initialLat, initialLon); opPlayer.setPositionOnMap(gpPlayer); }
public virtual bool Teleport(MapNeighbour mapNeighbour) { var neighbour = Position.Map.GetNeighbouringMap(mapNeighbour); if (neighbour == null) { return(false); } var cell = Position.Map.GetCellAfterChangeMap(Position.Cell.Id, mapNeighbour); if (cell < 0 || cell >= 560) { logger.Error("Cell {0} out of range, current={1} neighbour={2}", cell, Cell.Id, mapNeighbour); return(false); } var destination = new ObjectPosition(neighbour, cell, Position.Direction); if (!destination.Cell.Walkable) { var cells = MapPoint.GetBorderCells(mapNeighbour).Select(x => neighbour.Cells[x.CellId]).Where(x => x.Walkable); var walkableCell = cells.Select(x => new MapPoint(x)).OrderBy(x => x.EuclideanDistanceTo(destination.Point)).FirstOrDefault(); if (walkableCell != null) { destination.Cell = neighbour.Cells[walkableCell.CellId]; } } return(Teleport(destination)); }
public void Test3CharacterMoveLimit() { game.EnqueDebug(new MessageInitCharacter { UserId = gameClient1.UserId, Faction = TeamFaction.Ciri, CharType = CharacterType.Innfi, SenderUserId = gameClient1.UserId }); var answer = (AnswerInitCharacter)gameClient1.LastAnswer; Assert.AreEqual(answer.Character.Pos, new ObjectPosition(0.0f, 0.0f, 0.0f)); var characterMoveSpeed = answer.Character.MoveSpeed; var distantPos = new ObjectPosition(500.0f, 0.0f, 500.0f); game.EnqueDebug(new MessageMoveCharacter { UserId = gameClient1.UserId, BeforePos = answer.Character.Pos, TargetPos = distantPos, SenderUserId = gameClient1.UserId }); var answerMove = (AnswerMoveCharacter)(gameClient1.LastAnswer); var resultPos = answerMove.ResultPos; Assert.AreEqual(resultPos.PosX < distantPos.PosX, true); Assert.AreEqual(resultPos.PosZ < distantPos.PosZ, true); }
public void Test4Character2DMove() { game.EnqueDebug(new MessageInitCharacter { UserId = gameClient1.UserId, Faction = TeamFaction.Ciri, CharType = CharacterType.Innfi, SenderUserId = gameClient1.UserId }); var answer = (AnswerInitCharacter)gameClient1.LastAnswer; var targetPos2D = new ObjectPosition(5.0f, 5.0f); game.EnqueDebug(new MessageMoveCharacter { UserId = gameClient1.UserId, BeforePos = answer.Character.Pos, TargetPos = targetPos2D, SenderUserId = gameClient1.UserId }); var answerMove = (AnswerMoveCharacter)(gameClient1.LastAnswer); var resultPos = answerMove.ResultPos; Assert.AreEqual(resultPos, targetPos2D); }
public override void Execute(TriggerBase trigger) { NpcTemplate npcTemplate = trigger.Get <NpcTemplate>("npc"); ObjectPosition objectPosition = null; if (trigger.IsArgumentDefined("map") && trigger.IsArgumentDefined("cell") && trigger.IsArgumentDefined("direction")) { Map map = trigger.Get <Map>("map"); short cellId = trigger.Get <short>("cell"); DirectionsEnum direction = trigger.Get <DirectionsEnum>("direction"); objectPosition = new ObjectPosition(map, cellId, direction); } else { if (trigger is GameTrigger) { objectPosition = (trigger as GameTrigger).Character.Position; } } if (objectPosition == null) { trigger.ReplyError("Position of npc is not defined"); } else { Npc npc = objectPosition.Map.SpawnNpc(npcTemplate, objectPosition, npcTemplate.Look); trigger.Reply("Npc {0} spawned", new object[] { npc.Id }); } }
public virtual void NotifyStopMoving(bool canceled) { if (Movement == null) { throw new InvalidOperationException("Entity was not moving"); } if (canceled) { Movement.Cancel(); var element = Movement.TimedPath.GetCurrentElement(); Position = new ObjectPosition(Map, element.CurrentCell, element.Direction); } else { Position = MovementPath.EndPosition.Clone(); } var movement = Movement; Movement = null; var handler = StopMoving; if (handler != null) { handler(this, movement, canceled); } }
void OnPositionChanged(ContextActor actor, ObjectPosition position) { // compare if the last cell is the same in case the actor moved by itself if (!actor.IsMoving() && Owner.Fight.State == FightState.Fighting) { RegisterEntry(position.Cell); } }
/// <summary> /// Exports this game object to file /// </summary> /// <param name="BW">Open Writer</param> public override void Export(BinaryWriter BW) { base.Export(BW); BW.Write(UnknownInt); BW.Write(UnknownBytes); ObjectPosition.Export(BW); BW.Write(UnknownHeaderEnd); }
public void SetTargetPosition(CommandParams param) { int layer = param.GetNumber(); int x = param.GetNumber(); int y = param.GetNumber(); TargetObject = new ObjectPosition(layer, x, y); }
private static void SpawnNpcs() { foreach (NpcSpawn current in Singleton <NpcManager> .Instance.GetNpcSpawns()) { ObjectPosition position = current.GetPosition(); position.Map.SpawnNpc(current); } }
public override void Execute(TriggerBase trigger) { var template = trigger.Get <MonsterTemplate>("monster"); ObjectPosition position = null; MonsterGroup group; if (template.Grades.Count <= trigger.Get <sbyte>("grade")) { trigger.ReplyError("Unexistant grade '{0}' for this monster", trigger.Get <sbyte>("grade")); return; } MonsterGrade grade = template.Grades[trigger.Get <sbyte>("grade")]; if (grade.Template.EntityLook == null) { trigger.ReplyError("Cannot display this monster"); return; } if (trigger.IsArgumentDefined("map") && trigger.IsArgumentDefined("cell") && trigger.IsArgumentDefined("direction")) { var map = trigger.Get <Map>("map"); var cell = trigger.Get <short>("cell"); var direction = trigger.Get <DirectionsEnum>("direction"); position = new ObjectPosition(map, cell, direction); } else if (trigger is GameTrigger) { position = (trigger as GameTrigger).Character.Position; } if (position == null) { trigger.ReplyError("Position of monster is not defined"); return; } if (trigger.IsArgumentDefined("id")) { group = position.Map.GetActor <MonsterGroup>(trigger.Get <sbyte>("id")); if (group == null) { trigger.ReplyError("Group with id '{0}' not found", trigger.Get <sbyte>("id")); return; } group.AddMonster(new Monster(grade, group)); } else { group = position.Map.SpawnMonsterGroup(grade, position); } trigger.Reply("Monster '{0}' added to the group '{1}'", template.Id, group.Id); }
private ObjectPosition GetPlayerPosition() { var playerPosition = new ObjectPosition(); playerPosition.x = _player.transform.position.x; playerPosition.y = _player.transform.position.y; playerPosition.z = _player.transform.position.z; return(playerPosition); }
private void OnPositionChanged(ContextActor actor, ObjectPosition position) { var fighter = actor as FightActor; if (!CanTrigger(fighter) && !ContainsCell(actor.Cell)) { Leave(fighter); } }
protected override void OnPositionChanged(ObjectPosition position) { base.OnPositionChanged(position); if (m_initialized) { Die(); } }
protected virtual void OnTeleported(ObjectPosition position) { Action <ContextActor, ObjectPosition> teleported = this.Teleported; if (teleported != null) { teleported(this, position); } }
protected virtual void OnTeleported(ObjectPosition position) { var handler = Teleported; if (handler != null) { handler(this, position); } }
public Npc(int id, NpcTemplate template, ObjectPosition position, ActorLook look) { this.Id = id; this.Template = template; this.Position = position; this.Look = look; this.m_gameContextActorInformations = new ObjectValidator <GameContextActorInformations>(new Func <GameContextActorInformations>(this.BuildGameContextActorInformations)); this.m_actions.AddRange(this.Template.Actions); }
protected override void OnPositionChanged(ObjectPosition position) { if (m_initialized && Position != null && Fight.State == FightState.Fighting) { CheckAndBuildWalls(); } base.OnPositionChanged(position); }
public WorldObjectItem(int id, Map map, Cell cell, ItemTemplate template, List <EffectBase> effects, int quantity) { Id = id; Position = new ObjectPosition(map, cell); Quantity = quantity; Item = template; Effects = effects; SpawnDate = DateTime.Now; }
protected virtual void OnPositionChanged(ObjectPosition position) { Action <ContextActor, ObjectPosition> positionChanged = this.PositionChanged; if (positionChanged != null) { positionChanged(this, position); } }
protected virtual void OnPositionChanged(ObjectPosition position) { Action <ContextActor, ObjectPosition> handler = PositionChanged; if (handler != null) { handler(this, position); } }
public ObjectData(ObjectPosition[] walls, Enemy[] enemies, InteractableObject[] interactableObjects, MissionTrigger[] missionTriggers, ObjectPosition playerPosition) { this.walls = walls; this.enemies = enemies; this.interactableObjects = interactableObjects; this.missionTriggers = missionTriggers; this.playerPosition = playerPosition; }
public void CutPath(int index) { if (index > m_cellsPath.Length - 1) { return; } m_cellsPath = m_cellsPath.Take(index).ToArray(); m_endPathPosition = new ObjectPosition(Map, End, GetEndCellDirection()); }
public void CutPath(int index) { if (index > m_cellsPath.Length - 1) return; m_cellsPath = m_cellsPath.Take(index).ToArray(); m_endPathPosition = new ObjectPosition(Map, End, GetEndCellDirection()); }