/// <summary> /// Callback for the timer completing. /// </summary> /// <param name="timerName">Timer that was completed.</param> public override void OnTimerDone(string timerName) { // Return if the quick build isn't complete. var quickBuildComponent = this.GameObject.AddComponent <QuickBuildComponent>(); if (quickBuildComponent.State != RebuildState.Completed) { return; } // Drop the item. if (timerName == "DropLife") { // Drop a life and prepare the next timer. var loot = InstancingUtilities.InstantiateLoot(Lot.Health, this._player, this.GameObject, this.GameObject.Transform.Position + Vector3.UnitY * 3); Start(loot); this.AddTimerWithCancel(DropLifeTime, "DropLife"); } else if (timerName == "DropImagination") { // Drop an imagination and prepare the next timer. var loot = InstancingUtilities.InstantiateLoot(Lot.Imagination, this._player, this.GameObject, this.GameObject.Transform.Position + Vector3.UnitY * 3); Start(loot); this.AddTimerWithCancel(DropImaginationTime, "DropImagination"); } else if (timerName == "DropArmor") { // Drop an armor and prepare the next timer. var loot = InstancingUtilities.InstantiateLoot(Lot.Armor, this._player, this.GameObject, this.GameObject.Transform.Position + Vector3.UnitY * 3); Start(loot); this.AddTimerWithCancel(DropArmorTime, "DropArmor"); } }
/// <summary> /// Creates the object script. /// </summary> /// <param name="gameObject">Game object to control with the script.</param> public TikiTorch(GameObject gameObject) : base(gameObject) { StartFXEffect("tikitorch", "fire", 611); // Listen to the tiki torch being interacted with. Listen(gameObject.OnInteract, player => { // Play the animation. this.PlayAnimation("interact"); this.SetNetworkVar("bIsInUse", true); // Drop the imagination. for (var i = 0; i < 2; i++) { var loot = InstancingUtilities.InstantiateLoot(Lot.Imagination, player, gameObject, gameObject.Transform.Position + Vector3.UnitY); Start(loot); } // Reset the torch. this.AddTimerWithCancel(0.5f, "ResetTikiTorch"); }); Listen(Zone.OnPlayerLoad, player => { Listen(player.OnSkillEvent, async(target, effectHandler) => { if (effectHandler == "waterspray" && IsBurning && target == gameObject) { IsBurning = false; this.PlayAnimation("water"); StopFXEffect("tikitorch"); PlayFXEffect("water", "water", 611); PlayFXEffect("steam", "steam", 611); Zone.Schedule(() => { if (!IsBurning) { IsBurning = true; StopFXEffect("water"); StopFXEffect("steam"); StartFXEffect("tikitorch", "fire", 611); } }, 7000); if (player.TryGetComponent <MissionInventoryComponent>(out var missionInventoryComponent)) { missionInventoryComponent.ScriptAsync(702, gameObject.Lot); } } }); });
/// <summary> /// Creates the object script. /// </summary> /// <param name="gameObject">Game object to control with the script.</param> public Altar(GameObject gameObject) : base(gameObject) { // Listen to players interacting with altars Listen(gameObject.OnInteract, player => { if (gameObject.GetComponent <QuickBuildComponent>().State != RebuildState.Completed) { return; } // Drop imagination for (var i = 0; i < ImaginationCount; i++) { var loot = InstancingUtilities.InstantiateLoot(ImaginationLot, player, gameObject, gameObject.Transform.Position + Vector3.UnitY * 3); Start(loot); } }); }
/// <summary> /// Creates the object script. /// </summary> /// <param name="gameObject">Game object to control with the script.</param> public ArmorSpawner(GameObject gameObject) : base(gameObject) { Listen(gameObject.OnInteract, player => { // Drop armor for (var i = 0; i < ArmorCount; i++) { var loot = InstancingUtilities.InstantiateLoot(Lot.ThreeArmor, player, gameObject, gameObject.Transform.Position + Vector3.UnitY * 3); Start(loot); } // Terminate interaction so the player can interact again. player.Message(new TerminateInteractionMessage { Associate = player, Terminator = gameObject, Type = TerminateType.FromInteraction, }); }); }
private async void spawnPowerups(GameObject gameObject) { if (Active) { //so the lua script appears to only spawn the powerups for the activating player, //but i think that's a little unfair, and i made it spawn powerups for everyone //should i make it spawn for only the activating player? for (var h = 0; h < 2; h++) { foreach (var player in gameObject.Viewers) { var loot = InstancingUtilities.InstantiateLoot(Lot.Imagination, player, gameObject, gameObject.Transform.Position); Start(loot); } } await Task.Delay(1500); spawnPowerups(gameObject); } }
protected async void SpawnPowerups(GameObject gameObject, int numCycles, float secPerCycle, float delayToFirstCycle, float deathDelay, int numberOfPowerups, Lot lootLOT) { await Task.Delay((int)(delayToFirstCycle * 1000)); for (var i = 0; i < numCycles; i++) { //spawn the powerups for (var h = 0; h < numberOfPowerups; h++) { foreach (var player in gameObject.Viewers) { var loot = InstancingUtilities.InstantiateLoot(lootLOT, player, gameObject, gameObject.Transform.Position + Vector3.UnitY); Start(loot); } } await Task.Delay((int)(secPerCycle * 1000)); } await Task.Delay((int)(deathDelay * 1000)); gameObject.GetComponent <DestructibleComponent>().SmashAsync(gameObject); }
/// <summary> /// Creates the object script. /// </summary> /// <param name="gameObject">Game object to control with the script.</param> public ImaginationSmashable(GameObject gameObject) : base(gameObject) { if (!gameObject.TryGetComponent <DestructibleComponent>(out var destructibleComponent)) { return; } // Listen to the object being smashed. Listen(destructibleComponent.OnSmashed, (killer, owner) => { // Manually spawn imagination if a user has the prerequisite mission as it's not in the crate loot table. var missionInventory = owner.GetComponent <MissionInventoryComponent>(); if (missionInventory != default && missionInventory.HasMission((int)MissionId.UnlockYourImagination)) { for (var i = 0; i < _random.Next(1, 3); i++) { var loot = InstancingUtilities.InstantiateLoot(Lot.Imagination, owner, gameObject, gameObject.Transform.Position); Start(loot); } } // Spawn the crate chicken. var random = _random.Next(0, 26); if (random != 1) { return; } var chicken = GameObject.Instantiate(Zone, 8114, gameObject.Transform.Position); Start(chicken); Construct(chicken); Task.Run(async() => { await Task.Delay(4000); Destroy(chicken); }); }); }
/// <summary> /// Creates the object script. /// </summary> /// <param name="gameObject">Game object to control with the script.</param> public PicnicBlanket(GameObject gameObject) : base(gameObject) { Listen(gameObject.OnInteract, async player => { player.Message(new TerminateInteractionMessage { Associate = player, Terminator = gameObject, Type = TerminateType.FromInteraction, }); if (player.TryGetComponent <CharacterComponent>(out var character) && !Active) { Active = true; for (var i = 0; i < 3; i++) { var loot = InstancingUtilities.InstantiateLoot(935, player, gameObject, gameObject.Transform.Position + Vector3.UnitY); Start(loot); } await Task.Delay(5000); Active = false; } }); }