private void Update() { RaycastHit hit; Ray ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward); if (Physics.Raycast(ray, out hit, m_InteractDistance)) { Transform ObjectHit = hit.transform; if (ObjectHit.name.Contains("Barricade")) // Repair Barricade { Barricade Barricade = ObjectHit.GetComponent <Barricade>(); if (Barricade.Repairable()) { m_RepairText.text = "Press E To Repair Barricade"; if (Input.GetKeyDown(KeyCode.E)) { Barricade.StartRepair(); } } else { m_RepairText.text = null; } } if (ObjectHit.name.Contains("Weapon")) // Buy Weapon { if (ObjectHit.name.Contains("Pistol")) { BuyPistol BuyPistol = ObjectHit.GetComponent <BuyPistol>(); if (GetComponent <Pistol>() == null) { m_BuyText.text = "Press E To Buy Pistol $" + BuyPistol.m_GunCost; if (Input.GetKeyDown(KeyCode.E) && m_Points >= BuyPistol.m_GunCost) { m_Points -= BuyPistol.m_GunCost; gameObject.AddComponent <Pistol>(); } } else { m_BuyText.text = "Press E To Buy Pistol Ammo $" + BuyPistol.m_AmmoCost; if (Input.GetKeyDown(KeyCode.E) && m_Points >= BuyPistol.m_AmmoCost) { m_Points -= BuyPistol.m_AmmoCost; Pistol Pistol = GetComponent <Pistol>(); Pistol.m_Ammo = Pistol.m_MaxAmmo; Pistol.m_AmmoText.text = Pistol.m_Clip + "/" + Pistol.m_Ammo; } } } } Debug.DrawLine(ray.origin, hit.point, Color.blue); } else { m_RepairText.text = null; m_BuyText.text = null; } }
private void OnDeployBarricadeRequested(Barricade barricade, ItemBarricadeAsset asset, Transform hit, ref Vector3 point, ref float angleX, ref float angleY, ref float angleZ, ref ulong owner, ref ulong @group, ref bool shouldAllow) { var rot = Quaternion.Euler(angleX, angleY, angleZ); var @event = new UnturnedBarricadeDeployingEvent(asset, hit, point, rot, owner, group) { IsCancelled = !shouldAllow }; Emit(@event); point = @event.Point; var eulerAngles = @event.Rotation.eulerAngles; angleX = eulerAngles.x; angleY = eulerAngles.y; angleZ = eulerAngles.z; owner = @event.Owner; group = @event.Group; shouldAllow = [email protected]; }
private void Update() { if (m_Barricade != null && m_Barricade.m_Health > 0) { m_Agent.destination = m_Barricade.transform.position; m_Target = "Barricade"; } else { m_Agent.destination = m_Player.transform.position; m_Barricade = null; m_Target = "Player"; } if (!m_Agent.pathPending) { if (m_Agent.remainingDistance <= m_Agent.stoppingDistance) { if (!m_Agent.hasPath || m_Agent.velocity.sqrMagnitude == 0f) { if (!m_Attacking) { m_Attacking = true; StartCoroutine(Attack()); } } } else { //Moving Towards Object m_Attacking = false; } } }
// Use this for initialization void Start() { m_Animator = GetComponent <Animator>(); m_audioSource = GetComponent <AudioSource>(); barricade = frontDoor.GetComponentInParent <Barricade>(); }
IEnumerator BreakBoards(Barricade currentBarricade) { //stop all navigation; m_navMeshAgent.enabled = false; //tp zombie yield return(new WaitForSeconds(0.5f)); gameObject.transform.position = currentBarricade.nodePostion.position; gameObject.transform.rotation = currentBarricade.nodePostion.rotation; while (IsAlive && !currentBarricade.allBoardsRemoved) { //pick a random board int boardIndex = Random.Range(1, 6); //barricade is already removed pick a new one (should be quick enough only five options) if (currentBarricade.boards[boardIndex - 1].isRemoved) { continue; } else { //tell barricade to remove the board and player zombie animation anim.Play(string.Format("zomb_destroy_{0}", boardIndex)); currentBarricade.RemoveBoard(boardIndex); //wait before picking the next one yield return(new WaitForSeconds(barricadeTimer)); } } //resume AI pathing m_navMeshAgent.enabled = true; anim.SetBool("atBarricade", false); //IsAtBarricade = false; }
private void OnPlayerDeath(UnturnedPlayer player, EDeathCause cause, ELimb limb, CSteamID murderer) { List <ItemJar> droppedInventory = new List <ItemJar>(); UnityEngine.Vector3 deathlocation = player.Position + new UnityEngine.Vector3(0, (float)0.60, 0); moveInventoryItems(player, droppedInventory); if (Instance.Configuration.Instance.StoreClothes) { removeClothing(player, droppedInventory); } // use the specified unturned storage asset Barricade deathBag = new Barricade(Instance.Configuration.Instance.DeathBagId); UnityEngine.Transform barricadeTransform = new UnityEngine.GameObject().transform; barricadeTransform.localPosition = deathlocation; // create the physical bag to be dropped into the scene InteractableStorage deathBagStorage = BarricadeManager.dropBarricade(deathBag, barricadeTransform, deathlocation, 0, 0, 0, 0, 0).GetComponent <InteractableStorage>(); foreach (ItemJar itemjar in droppedInventory) { // add the inventory into the bag deathBagStorage.items.tryAddItem(itemjar.item); } TaskDispatcher.QueueOnMainThread(() => { DamageTool.damage(deathBagStorage.transform, false, 100000, 1, out EPlayerKill kill); }, (float)Instance.Configuration.Instance.Delay); }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { if (barricade == null) { barricade = other.GetComponent <Barricade> (); } if (GetComponent <Monster_Basic> () != null && GetComponent <Monster_Basic> ().audioSource != null && GetComponent <Monster_Basic> ().sound.Length != 0) { GetComponent <Monster_Basic> ().PlayAudioSource(GetComponent <Monster_Basic> ().sound [0].audioClip); } barricade.GetHurt(damage, cameraShakeMultiplier, cameraShakeLength); if (destroyParticle != null) { GameObject particle = Instantiate(destroyParticle, this.transform.position, this.transform.rotation) as GameObject; Destroy(particle, 3f); } anim.SetBool("Dead", true); if (GetComponent <Monster_Basic> () != null) { GameMaster.gameMaster.remainingEnemies.Remove(this.gameObject); GameMaster.gameMaster.StartCheckFinished(0.1f); } Destroy(this.gameObject, destroytime); } }
public BarricadeToSpawn(Barricade barricade, Vector3 point, Quaternion rotation, ulong owner, ulong @group) { Barricade = barricade; Point = point; Rotation = rotation; Owner = owner; Group = @group; }
public void AddBarricade(Barricade inputBarricade) { currentSequence++; if (UISequences.Count - 1 >= currentSequence) { UISequences[currentSequence].SetActive(true); } barricade = inputBarricade; }
/// <summary> /// 当たり判定 /// </summary> /// <param name="collision"></param> private void OnCollisionEnter(Collision collision) { // バリケードまで行きついたら攻撃を開始する if (collision.gameObject.layer == Layer.BARRICADE) { barricade = collision.gameObject.GetComponent <Barricade>(); State = ZOMBIE_STATUS.ATTACK; } }
// Use this for initialization void Start() { Movement.SetActive(false); Turret.SetActive(false); MeleeAtack.SetActive(false); Barricade.SetActive(false); Shoot.SetActive(false); WeaponChange.SetActive(false); }
void Awake() { rangeFireRateTemp = rangeFireRate; attackTime = Time.time + rangeFireRateTemp; anim = GetComponent <Animator> (); monsterBasic = GetComponent <Monster_Basic> (); barricade = Castle.castle.transform.GetComponent <Barricade> (); partialDestruction = GetComponent <PartialDestruction> (); }
IEnumerator DestroyBarricadeCoroutine(Barricade b) { while (b.alive) { yield return(new WaitForSeconds(3f)); b.DestroyBarricade(); } SeekPlayer(); }
public void Setup(Barricade t) { this.target = t; base.transform.SetParent(this.target.transform, false); base.gameObject.layer = 18; BoxCollider npcDoorTriggerSize = base.gameObject.AddComponent <BoxCollider>(); npcDoorTriggerSize.isTrigger = true; npcDoorTriggerSize.center = Vector3.zero; npcDoorTriggerSize.size = (Vector3.one * AI.npc_door_trigger_size) + (Vector3.right * this.target.bounds.size.x); }
public void Setup(Barricade t) { this.target = t; ((Component)this).get_transform().SetParent(((Component)this.target).get_transform(), false); ((Component)this).get_gameObject().set_layer(18); M0 m0 = ((Component)this).get_gameObject().AddComponent <BoxCollider>(); ((Collider)m0).set_isTrigger(true); ((BoxCollider)m0).set_center(Vector3.get_zero()); ((BoxCollider)m0).set_size(Vector3.op_Addition(Vector3.op_Multiply(Vector3.get_one(), AI.npc_door_trigger_size), Vector3.op_Multiply(Vector3.get_right(), (float)((Bounds) ref this.target.bounds).get_size().x))); }
private void OnBarricadeDeploy(Barricade barricade, ItemBarricadeAsset asset, Transform hit, ref Vector3 point, ref float angleX, ref float angleY, ref float angleZ, ref ulong owner, ref ulong group, ref bool shouldAllow) { if (!shouldAllow) { return; } shouldAllow = CheckValidDeployPosAndOwner(point, owner, group); }
public Transform SummonBarricade(Transform hit) { var barricade = new Barricade(Id, Health, State, (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, Id)); if (hit != null) { return(BarricadeManager.dropPlantedBarricade(hit, barricade, Position.ToVector3(), Quaternion.Euler(Rotation.x, Rotation.y, Rotation.z), Owner, Group)); } else { return(BarricadeManager.dropNonPlantedBarricade(barricade, Position.ToVector3(), Quaternion.Euler(Rotation.x, Rotation.y, Rotation.z), Owner, Group)); } }
public static void askRepair(this Barricade barricade, ushort amount) { // Set the variables bool cancel = false; // Run the events BarricadeEvents.RunBarricadeRepair(UnturnedBarricade.FindBarricade(barricade), ref amount, ref cancel); // Run the original function if (!cancel) { DetourManager.CallOriginal(typeof(Barricade).GetMethod("askRepair", BindingFlags.Instance | BindingFlags.Public), barricade, amount); } }
private static void DropBarricade(BarricadeRegion region, Barricade barricade, Vector3 point, Quaternion rotation, ulong owner, ulong group, BarricadeData data, ref Transform result, ref uint instanceID) { if (result != null) { BarricadeDrop drop = region.drops.LastOrDefault(); if (drop?.instanceID == instanceID) { OnBarricadeDeployed?.Invoke(data, drop); } } }
private void OnDeployBarricade(Barricade barricade, ItemBarricadeAsset asset, Transform hit, ref Vector3 point, ref float angle_x, ref float angle_y, ref float angle_z, ref ulong owner, ref ulong group, ref bool shouldAllow) { var z = owner; shouldAllow = true; AsyncHelper.RunSync(async() => { var user = (UnturnedUser)await ro_UserManager.FindUserAsync(KnownActorTypes.Player, z.ToString(), UserSearchMode.FindById); var x = PlayerManager.InBuilderMode; if (x.Contains(user.Id)) { var c = new Item(asset.id, true); user.Player.inventory.tryAddItem(c, true); } }); }
IEnumerator Attack(Barricade barricade) { speed = 0; while (true) { GetComponent <Animator>().SetTrigger("Attack"); yield return(new WaitForSeconds(0.5f)); if (!barricade.GetComponent <MeshRenderer>().enabled || !alive) { break; } barricade.Damage(attackDamage); yield return(new WaitForSeconds(0.5f)); } }
public void HitByPill() { CancelInvoke("PacmanBehaviour"); AudioSource.PlayClipAtPoint(pacmanHit, Camera.main.transform.position); Barricade barricade = FindObjectOfType <Barricade>(); if (barricade) { GetComponent <Transform>().position = new Vector3(barricade.transform.position.x, transform.position.y, transform.position.z); StartCoroutine(WaitAndLoadHit()); } else { GetComponent <Transform>().position = new Vector3(1.60f, transform.position.y, transform.position.z); StartCoroutine(WaitAndLoadHit()); } }
private void Update() { if (dep < 0 && !rightFace) { Flip(); } else if (dep > 0 && rightFace) { Flip(); } if (health <= 0 && !isDead) { isDead = true; dep = left ? -1f : 1f; if (barricade != null) { barricade.nbEnemy--; } if (tree != null) { tree.nbEnemy--; } tree = null; barricade = null; GetComponent <CapsuleCollider2D>().enabled = false; } if (Input.GetKeyDown(KeyCode.A) && health > 0 && !isDead && playerIsIn && player.timeToAttack <= 0f) { soundScript.PlaySound(TYPE_AUDIO.Cris); health = 0; playerIsIn = false; player.ResetAttack(); if (!animator.GetBool("Scared")) { animator.SetBool("Running", false); animator.SetBool("Cutting", false); animator.SetBool("Scared", true); //soundScript.PlaySound(TYPE_AUDIO.Peur); } } }
public BarricadeTag(Barricade barricade) { for (byte x = 0; x < Regions.WORLD_SIZE; x++) { for (byte y = 0; y < Regions.WORLD_SIZE; y++) { BarricadeRegion region = BarricadeManager.regions[x, y]; for (int i = 0; i < region.barricades.Count; i++) { if (barricade == region.barricades[i].barricade) { Internal = region.drops[i].model; InternalData = region.barricades[i]; return; } } } } }
public BarricadeTag(Barricade barricade) { for (byte x = 0; x < Regions.WORLD_SIZE; x++) { for (byte y = 0; y < Regions.WORLD_SIZE; y++) { BarricadeRegion region = BarricadeManager.regions[x, y]; for (int i = 0; i < region.barricades.Count; i++) { if (barricade == region.barricades[i].barricade) { Internal = region.models[i]; InternalData = region.barricades[i]; return; } } } } }
private void FixedUpdate() { if (tree == null && barricade == null) { if (health > 0) { if (!animator.GetBool("Running")) { animator.SetBool("Cutting", false); animator.SetBool("Running", true); } } else { if (!animator.GetBool("Walking")) { animator.SetBool("Scared", false); animator.SetBool("Cutting", false); animator.SetBool("Walking", true); } } rig.velocity = new Vector2(dep * 10f * speed * Time.deltaTime, rig.velocity.y); } else if (rig.velocity.x > 0.1f || rig.velocity.x < -0.1f) { rig.velocity = new Vector2(0f, rig.velocity.y); } if (tree != null) { tree = tree.IsAlive(); IsCutting(); } if (barricade != null) { timer += Time.fixedDeltaTime; AttackBarricade(); barricade = barricade.IsAlive(); IsCutting(); } }
public Transform SeekBarricade() { Barricade[] barricade = FindObjectsOfType <Barricade>(); float distance = 99999; Barricade nearestBarricade = null; foreach (Barricade b in barricade) { float distanceFromBarricade = Vector2.Distance(b.transform.position, transform.position); if (distanceFromBarricade < distance) { distance = distanceFromBarricade; nearestBarricade = b; } } return(nearestBarricade.transform); }
public static bool BarricadeDamaged(Barricade barricade, ref ushort amount) { // TODO: causes? BarricadeTag barricadeTag = new BarricadeTag(barricade); if (amount >= barricade.health) { BarricadeDestroyedEventArgs deathevt = new BarricadeDestroyedEventArgs(); deathevt.Barricade = barricadeTag; deathevt.Amount = new NumberTag(amount); UnturnedFreneticEvents.OnBarricadeDestroyed.Fire(deathevt); amount = (ushort)deathevt.Amount.Internal; return deathevt.Cancelled || EntityDestroyed(barricadeTag, ref amount); } BarricadeDamagedEventArgs evt = new BarricadeDamagedEventArgs(); evt.Barricade = barricadeTag; evt.Amount = new NumberTag(amount); UnturnedFreneticEvents.OnBarricadeDamaged.Fire(evt); amount = (ushort)evt.Amount.Internal; return evt.Cancelled || EntityDamaged(barricadeTag, ref amount); }
//change what room you are in public void ChangeLevel(int oldLevel, int newLevel) { for (int i = Components.Count() - 1; i > -1; i--) { IGameComponent g = Components[i]; if (g is Enemy) { Enemy e = (Enemy)g; Components.Remove(e); } if (g is Bullet) { Bullet bu = (Bullet)g; Components.Remove(bu); } if (g is Barricade) { Barricade b = (Barricade)g; Components.Remove(b); } if (g is Door) { Door d = (Door)g; Components.Remove(d); } if (g is NPC) { NPC n = (NPC)g; Components.Remove(n); } if (g is itemDrop) { itemDrop item = (itemDrop)g; Components.Remove(item); } } Components.Remove(GetRoom(oldLevel)); Components.Add(GetRoom(newLevel)); }
public static bool BarricadeDamaged(Barricade barricade, ref ushort amount) { // TODO: causes? BarricadeTag barricadeTag = new BarricadeTag(barricade); if (amount >= barricade.health) { BarricadeDestroyedEventArgs deathevt = new BarricadeDestroyedEventArgs(); deathevt.Barricade = barricadeTag; deathevt.Amount = new NumberTag(amount); UnturnedFreneticEvents.OnBarricadeDestroyed.Fire(deathevt); amount = (ushort)deathevt.Amount.Internal; return(deathevt.Cancelled || EntityDestroyed(barricadeTag, ref amount)); } BarricadeDamagedEventArgs evt = new BarricadeDamagedEventArgs(); evt.Barricade = barricadeTag; evt.Amount = new NumberTag(amount); UnturnedFreneticEvents.OnBarricadeDamaged.Fire(evt); amount = (ushort)evt.Amount.Internal; return(evt.Cancelled || EntityDamaged(barricadeTag, ref amount)); }
private static void GiveBox(UnturnedPlayer player, string steamID, string boxName) { Block block = Functions.ReadBlock(Plugin.Instance.pathTemp + $@"\{steamID}\{boxName}.dat", 0); ushort id = block.readUInt16(); ushort he = block.readUInt16(); //Vector3 point = block.readSingleVector3(); block.readSingleVector3(); float x = (player.Player.look.aim.forward.x - player.Position.x < 5) ? player.Player.look.aim.forward.x : player.Position.x + 4; float y = (player.Player.look.aim.forward.y - player.Position.y < 5) ? player.Player.look.aim.forward.y : player.Position.y + 4; float z = (player.Player.look.aim.forward.z - player.Position.z < 5) ? player.Player.look.aim.forward.z : player.Position.z + 4; Vector3 point = new Vector3(x, y, z); float angle_x = block.readByte(); float angle_y = block.readByte(); float angle_z = block.readByte(); ulong owner = block.readUInt64(); ulong group = block.readUInt64(); byte[] state = block.readByteArray(); Asset asset1 = Assets.find(EAssetType.ITEM, id); ItemBarricadeAsset asset2 = asset1 as ItemBarricadeAsset; Barricade barricade = new Barricade(id, he, state, asset2); //Transform hit = BarricadeTool.getBarricade(region.parent, 100, owner, group, point, Quaternion.Euler((float)((int)angle_x * 2), (float)((int)angle_y * 2), (float)((int)angle_z * 2)), id, state, asset2); BarricadeManager.dropBarricade(barricade, null, player.Position, angle_x, angle_y, angle_z, owner, group); //block.writeUInt16(bdata.barricade.id); //block.writeUInt16(bdata.barricade.health); //block.writeSingleVector3(bdata.point); //block.writeByte(bdata.angle_x); //block.writeByte(bdata.angle_y); //block.writeByte(bdata.angle_z); //block.writeUInt64(bdata.owner); //block.writeUInt64(bdata.group); //block.writeByteArray(bdata.barricade.state); System.Console.WriteLine("box was spawned!"); }
// Applies damage to the given <target>. private void AttackTarget(Transform target) { // Trigger the attack animation. thisNetworkAnimator.SetTrigger("Attack"); if (target.tag == "Barricade") { Barricade targetBarricade = target.GetComponent <Barricade>(); // Damage the Barricade over the Network. targetBarricade.CmdDamageBarricade(attackDamage); } else { NetworkUser targetPlayer = target.GetComponent <NetworkUser>(); // Damage the Player over the Network. targetPlayer.CmdDamagePlayer(attackDamage); } // Reset the attack timer so we can attack again. attackTimer = 0f; }
public override void Execute(CommandQueue queue, CommandEntry entry) { try { TemplateObject spawned = null; LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1)); if (loc == null) { queue.HandleError(entry, "Invalid location!"); return; } string targetAssetType = entry.GetArgument(queue, 0).ToLowerFast(); EntityType etype = EntityType.ValueOf(targetAssetType); if (etype == null) { queue.HandleError(entry, "Invalid entity type!"); return; } if (etype.Type == EntityAssetType.ZOMBIE) { Vector3 vec3 = loc.ToVector3(); byte reg = 0; // TODO: Optionally specifiable float closest = float.MaxValue; for (int r = 0; r < LevelZombies.zombies.Length; r++) { for (int i = 0; i < LevelZombies.zombies[r].Count; i++) { float dist = (LevelZombies.zombies[r][i].point - vec3).sqrMagnitude; if (dist < closest) { closest = dist; reg = (byte)r; } } } ZombieManager.manager.addZombie(reg, 0, 0, 0, 0, 0, 0, 0, 0, vec3, 0, false); Zombie zombie = ZombieManager.regions[reg].zombies[ZombieManager.regions[reg].zombies.Count - 1]; // TODO: Make this actually work! (See complaints file!) /* foreach (SteamPlayer player in PlayerTool.getSteamPlayers()) { ZombieManager.manager.channel.openWrite(); ZombieManager.manager.channel.write(reg); ZombieManager.manager.channel.write((ushort)1); ZombieManager.manager.channel.write(new object[] { zombie.type, (byte)zombie.speciality, zombie.shirt, zombie.pants, zombie.hat, zombie.gear, zombie.move, zombie.idle, zombie.transform.position, MeasurementTool.angleToByte(zombie.transform.rotation.eulerAngles.y), zombie.isDead }); ZombieManager.manager.channel.closeWrite("tellZombies", player.playerID.steamID, ESteamPacket.UPDATE_RELIABLE_CHUNK_BUFFER); } */ if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully spawned a zombie at " + TagParser.Escape(loc.ToString()) + "! (WARNING: IT WILL BE INVISIBLE CURRENTLY - SEE THE COMPLAINTS FILE)"); } spawned = new ZombieTag(zombie); } else if (etype.Type == EntityAssetType.ANIMAL) { AnimalAssetTag asset = AnimalAssetTag.For(targetAssetType); if (asset == null) { queue.HandleError(entry, "Invalid animal type!"); return; } // TODO: Make this bit optional! RaycastHit rch; while (Physics.Raycast(loc.ToVector3(), new Vector3(0, 1, 0), out rch, 5)) { loc.Y += 3; } // END TODO AnimalManager.manager.addAnimal(asset.Internal.id, loc.ToVector3(), 0, false); Animal animal = AnimalManager.animals[AnimalManager.animals.Count - 1]; foreach (SteamPlayer player in PlayerTool.getSteamPlayers()) { AnimalManager.manager.channel.openWrite(); AnimalManager.manager.channel.write((ushort)1); AnimalManager.manager.channel.write(new object[] { animal.id, animal.transform.position, MeasurementTool.angleToByte(animal.transform.rotation.eulerAngles.y), animal.isDead }); AnimalManager.manager.channel.closeWrite("tellAnimals", player.playerID.steamID, ESteamPacket.UPDATE_RELIABLE_CHUNK_BUFFER); } if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "! (" + animal.gameObject.GetInstanceID() + ")"); } spawned = new AnimalTag(animal); } else if (etype.Type == EntityAssetType.VEHICLE) { VehicleAssetTag asset = VehicleAssetTag.For(targetAssetType); if (asset == null) { queue.HandleError(entry, "Invalid vehicle type!"); return; } // TODO: Make this bit optional! RaycastHit rch; while (Physics.Raycast(loc.ToVector3(), new Vector3(0, 1, 0), out rch, 5)) { loc.Y += 3; } // END TODO VehicleManager.spawnVehicle(asset.Internal.id, loc.ToVector3(), Quaternion.identity); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!"); } // TODO: Get the vehicle entity! } else if (etype.Type == EntityAssetType.WORLD_OBJECT) { WorldObjectAssetTag asset = WorldObjectAssetTag.For(targetAssetType); if (asset == null) { queue.HandleError(entry, "Invalid world object type!"); return; } LevelObjects.addObject(loc.ToVector3(), Quaternion.identity, asset.Internal.id); // TODO: Network! entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) +"! (WARNING: IT WILL BE INVISIBLE CURRENTLY - SEE THE COMPLAINTS FILE)"); // TODO: Get the world entity! } else if (etype.Type == EntityAssetType.ITEM) { ItemAssetTag asset = ItemAssetTag.For(targetAssetType); if (asset == null) { queue.HandleError(entry, "Invalid item type!"); return; } byte x; byte y; if (Regions.tryGetCoordinate(loc.ToVector3(), out x, out y)) { Item item = new Item(asset.Internal.id, 1, asset.Internal.quality); ItemData data = new ItemData(item, ++ItemManager.instanceCount, loc.ToVector3(), Dedicator.isDedicated); ItemManager.regions[x, y].items.Add(data); ItemModelTracker.Track(data, loc.ToVector3()); ItemManager.manager.channel.send("tellItem", ESteamCall.CLIENTS, x, y, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { x, y, item.id, item.amount, item.quality, item.state, loc.ToVector3() }); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!"); } // TODO: Get the item entity! } else { queue.HandleError(entry, "Trying to spawn item outside any valid item regions!"); } } else if (etype.Type == EntityAssetType.BARRICADE) { ItemAssetTag asset = ItemAssetTag.For(targetAssetType.Substring("barricade_".Length)); if (asset == null || !(asset.Internal is ItemBarricadeAsset)) { queue.HandleError(entry, "Invalid item barricade type!"); return; } Barricade barric = new Barricade(asset.Internal.id); BarricadeManager.dropBarricade(barric, null, loc.ToVector3(), 0f, 0f, 0f, CSteamID.Nil.m_SteamID, CSteamID.Nil.m_SteamID); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!"); } // TODO: Get the game object! } else if (etype.Type == EntityAssetType.STRUCTURE) { ItemAssetTag asset = ItemAssetTag.For(targetAssetType.Substring("structure_".Length)); if (asset == null || !(asset.Internal is ItemStructureAsset)) { queue.HandleError(entry, "Invalid item structure type!"); return; } StructureManager.dropStructure(new Structure(asset.Internal.id), loc.ToVector3(), 0f, CSteamID.Nil.m_SteamID, CSteamID.Nil.m_SteamID); if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!"); } // TODO: Get the game object! } else { queue.HandleError(entry, "Invalid or unspawnable entity type!"); return; } if (spawned != null) { queue.SetVariable("spawned", spawned); } } catch (Exception ex) // TODO: Necessity? { queue.HandleError(entry, "Failed to spawn entity: " + ex.ToString()); } }
private void ParseXML() { XmlElement root = _xmlFile.DocumentElement; XmlNodeList xmlRows = root.SelectNodes("row"); foreach (XmlNode xmlRow in xmlRows) { XmlNodeList xmlFields = xmlRow.SelectNodes("IField"); foreach (XmlNode xmlField in xmlFields) { IField field = CastToIField(xmlField.Attributes["type"].Value, xmlField.SelectSingleNode("CoordX").InnerText, xmlField.SelectSingleNode("CoordY").InnerText, xmlField.SelectSingleNode("IsFirstRow").InnerText, xmlField.SelectSingleNode("IsVillage").InnerText); field.Moveables = new List<IMoveable>(); List<IField> connectedFields = new List<IField>(); XmlNodeList xmlConnectedFields = xmlField.SelectNodes("connectedfields"); // Check if barricade if (xmlField.Attributes["isBarricade"] != null && xmlField.Attributes["isBarricade"].Value != null && xmlField.Attributes["isBarricade"].Value == "true") { IMoveable barricade = new Barricade { Position=field }; field.Moveables.Add(barricade); } // First add connected fields from CSV data foreach (XmlNode xmlConnectedField in xmlConnectedFields) { XmlNodeList xmlSubFields = xmlConnectedField.SelectNodes("IField"); foreach (XmlNode xmlSubField in xmlSubFields) { IField connectedField = CastToIField(xmlSubField.Attributes["type"].Value, xmlSubField.SelectSingleNode("CoordX").InnerText, xmlSubField.SelectSingleNode("CoordY").InnerText, xmlSubField.SelectSingleNode("IsFirstRow").InnerText, xmlSubField.SelectSingleNode("IsVillage").InnerText); connectedFields.Add(connectedField); } } // Connect siblings if no startfield if (xmlField.Attributes["type"].Value == "startfield") { switch (xmlField.Attributes["playerid"].Value) { case "1": StartFieldsPlayerOne.Add((StartField)field); break; case "2": StartFieldsPlayerTwo.Add((StartField)field); break; case "3": StartFieldsPlayerThree.Add((StartField)field); break; case "4": StartFieldsPlayerFour.Add((StartField)field); break; default: StartFieldsPlayerOne.Add((StartField)field); break; } } else { XmlNode prevSibling = xmlField.PreviousSibling; XmlNode nextSibling = xmlField.NextSibling; if (prevSibling != null) { IField prevField = CastToIField(prevSibling.Attributes["type"].Value, prevSibling.SelectSingleNode("CoordX").InnerText, prevSibling.SelectSingleNode("CoordY").InnerText, prevSibling.SelectSingleNode("IsFirstRow").InnerText, prevSibling.SelectSingleNode("IsVillage").InnerText); connectedFields.Add(prevField); } if (nextSibling != null) { IField nextField = CastToIField(nextSibling.Attributes["type"].Value, nextSibling.SelectSingleNode("CoordX").InnerText, nextSibling.SelectSingleNode("CoordY").InnerText, nextSibling.SelectSingleNode("IsFirstRow").InnerText, nextSibling.SelectSingleNode("IsVillage").InnerText); connectedFields.Add(nextField); } } // Add connected fields to IField object field.ConnectedFields = connectedFields; AllFields.Add(field); } } }
/// <summary> /// Plaatst een barricade op het veld /// </summary> /// <param name="bar">barricade</param> /// <returns>ja of nee</returns> public bool Plaats(Barricade bar) { if (!MagBarricade) return false; Barricade = bar; return true; }
void OnTriggerExit(Collider other) { //print("Player: Exit " + other.name); switch (other.tag) { case "Barricade": barricade = null; PlayerMessage.HideMessage(); break; } }
void OnTriggerEnter(Collider other) { //print("Player: Enter " + other.name); switch (other.tag) { case "Barricade": barricade = other.GetComponent<Barricade>(); if (barricade.NeedsRepair) { PlayerMessage.DisplayMessage("Press 'E' to repair the barricade"); } break; } }
public BarricadeVerplaatsException(Veld veld, Barricade barricade) { Veld = veld; Barricade = barricade; }
void OnTriggerExit(Collider other) { switch (other.tag) { case "Barricade": barricade = null; break; } }
void OnTriggerEnter(Collider other) { switch (other.tag) { case "Barricade": if (isInside) return; barricade = other.GetComponent<Barricade>(); if (barricade.targetTransform != barricadeTarget) { // wrong target agent.ResetPath(); // recompute path return; } if (barricade.Destroyed) { TransitionChasePlayer(); } else { TransitionAttackBarricade(); } break; case "InsideTrigger": if (isInside) return; isInside = true; TransitionChasePlayer(); break; } }