public void InsertSignpost(signpost toinsert) { Logger.InfoFormat("Inserting signpost {0}@{1},{2}", toinsert.map.name, toinsert.map_x, toinsert.map_y); var post = new Signpost(toinsert); World.Insert(post); Insert(post, post.X, post.Y); Signposts[new Tuple <byte, byte>(post.X, post.Y)] = post; }
private void Awake() { // There must be a starting signpost with a "Start Signpost" tag. GameObject startSignpost = GameObject.FindGameObjectWithTag(Signpost.StartSignpostTag); if (startSignpost) { targetSignpost = startSignpost.GetComponent <Signpost>(); } else { Debug.LogWarning("There is no starting signpost."); } healthBar = GetComponent <HealthBar>(); maxHealth = health; audioSource = GameObject.Find("AudioSource").GetComponent <AudioSource>(); }
public BlockBase FindBlock(Signpost signpost, BlockBase sourceBlock) { if (signpost.ID != FieldList.FieldNotFound) { return(sourceBlock.ParentNode.FindBlockBySignpost(signpost.ID)); } else if ((signpost.FrameID != null) && (signpost.Name != null)) { View target = Core.Navigation.ResolveFrameID(signpost.FrameID, sourceBlock); if ((target != null) && (target.CurrentNode != null)) { short signpostID = target.CurrentNode.FindSignpostNumber(signpost.Name); if (signpostID != FieldList.FieldNotFound) { return(target.CurrentNode.FindBlockBySignpost(signpostID)); } } } return(null); }
private void Update() { if (stuned <= 0) { if (targetSignpost != null) { LookAt(targetSignpost.transform); MoveForward(); if (targetSignpost.SingpostType == Signpost.Type.End) { passed = Vector2.Distance(transform.position, targetSignpost.transform.position) < minDistance; } if (Vector2.Distance(transform.position, targetSignpost.transform.position) < minDistance) { targetSignpost = targetSignpost.NextSignpost; } #if UNITY_EDITOR if (showPath) { ShowPath(); } #endif } else if (passed) { Pass(); } } else { stuned -= Time.deltaTime; } }
//public Dictionary<string, Xml.Spawn> Spawns { get; set; } /// <summary> /// Create a new Hybrasyl map from an XMLMap object. /// </summary> /// <param name="newMap">An XSD.Map object representing the XML map file.</param> /// <param name="theWorld">A world object where the map will be placed</param> public Map(Xml.Map newMap, World theWorld) { Init(); World = theWorld; SpawnDebug = false; // Spawns = new List<Xml.Spawn>(); // TODO: refactor Map class to not do this, but be a partial which overlays // TODO: XSD.Map Id = newMap.Id; X = newMap.X; Y = newMap.Y; Name = newMap.Name; AllowCasting = newMap.AllowCasting; EntityTree = new QuadTree <VisibleObject>(0, 0, X, Y); Music = newMap.Music; foreach (var warpElement in newMap.Warps) { var warp = new Warp(this) { X = warpElement.X, Y = warpElement.Y }; if (warpElement.MapTarget != null) { // map warp warp.DestinationMapName = warpElement.MapTarget.Value; warp.WarpType = WarpType.Map; warp.DestinationX = warpElement.MapTarget.X; warp.DestinationY = warpElement.MapTarget.Y; } else if (warpElement.WorldMapTarget != string.Empty) { // worldmap warp warp.DestinationMapName = warpElement.WorldMapTarget; warp.WarpType = WarpType.WorldMap; } if (warpElement.Restrictions?.Level != null) { warp.MinimumLevel = warpElement.Restrictions.Level.Min; warp.MaximumLevel = warpElement.Restrictions.Level.Max; } if (warpElement.Restrictions?.Ab != null) { warp.MinimumAbility = warpElement.Restrictions.Ab.Min; warp.MaximumAbility = warpElement.Restrictions.Ab.Max; } warp.MobUse = warpElement.Restrictions?.NoMobUse ?? true; Warps[new Tuple <byte, byte>(warp.X, warp.Y)] = warp; } foreach (var npcElement in newMap.Npcs) { var npcTemplate = World.WorldData.Get <Xml.Npc>(npcElement.Name); if (npcTemplate == null) { GameLog.Error("map ${Name}: NPC ${npcElement.Name} is missing, will not be loaded"); continue; } var merchant = new Merchant { X = npcElement.X, Y = npcElement.Y, Name = npcElement.Name, Sprite = npcTemplate.Appearance.Sprite, Direction = npcElement.Direction, Portrait = npcTemplate.Appearance.Portrait, AllowDead = npcTemplate.AllowDead }; if (npcTemplate.Roles != null) { if (npcTemplate.Roles.Post != null) { merchant.Jobs ^= MerchantJob.Post; } if (npcTemplate.Roles.Bank != null) { merchant.Jobs ^= MerchantJob.Bank; } if (npcTemplate.Roles.Repair != null) { merchant.Jobs ^= MerchantJob.Repair; } if (npcTemplate.Roles.Train != null) { if (npcTemplate.Roles.Train.Any(x => x.Type == "Skill")) { merchant.Jobs ^= MerchantJob.Skills; } if (npcTemplate.Roles.Train.Any(x => x.Type == "Spell")) { merchant.Jobs ^= MerchantJob.Spells; } } if (npcTemplate.Roles.Vend != null) { merchant.Jobs ^= MerchantJob.Vend; } merchant.Roles = npcTemplate.Roles; } InsertNpc(merchant); // Keep the actual spawned object around in the index for later use World.WorldData.Set(merchant.Name, merchant); } foreach (var reactorElement in newMap.Reactors) { var reactor = new Reactor(reactorElement.X, reactorElement.Y, this, reactorElement.Script, reactorElement.Description, reactorElement.Blocking); reactor.AllowDead = reactorElement.AllowDead; InsertReactor(reactor); GameLog.Debug($"{reactor.Id} placed in {reactor.Map.Name}, description was {reactor.Description}"); } foreach (var sign in newMap.Signs) { Signpost post; if (sign.Type == Xml.BoardType.Sign) { post = new Signpost(sign.X, sign.Y, sign.Message); } else { post = new Signpost(sign.X, sign.Y, sign.Message, true, sign.BoardKey); } InsertSignpost(post); } Load(); }
void Start() { _signpost = GetComponent<Signpost>(); signalPrefab = Resources.Load("Prefabs/UnreadSignal") as GameObject; CheckStatus(); }
public void InsertSignpost(signpost toinsert) { Logger.InfoFormat("Inserting signpost {0}@{1},{2}", toinsert.map.name, toinsert.map_x, toinsert.map_y); var post = new Signpost(toinsert); World.Insert(post); Insert(post, post.X, post.Y); Signposts[new Tuple<byte, byte>(post.X, post.Y)] = post; }