public override void PickupEffects(Player player) { AbilityHandler ah = player.GetHandler(); ah.Shards.Add(Parent.frameX); if (ah.ShardCount % 3 == 0) { UILoader.GetUIState <TextCard>().Display("Stamina Vessel", "Your maximum stamina has increased by 1", null, 240, 0.8f); } else { UILoader.GetUIState <TextCard>().Display("Stamina Vessel Shard", "Collect " + (3 - ah.ShardCount % 3) + " more to increase your maximum stamina", null, 240, 0.6f); } player.GetModPlayer <Core.StarlightPlayer>().MaxPickupTimer = 1; Helper.UnlockEntry <StaminaShardEntry>(Main.LocalPlayer); }
public override void AI() { projectile.timeLeft = 2; projectile.rotation = projectile.velocity.ToRotation() + (float)Math.PI / 2; projectile.velocity *= 1.004f; Player player = Main.LocalPlayer; AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); if (projectile.Hitbox.Intersects(player.Hitbox) && mp.dashcd > 1) { projectile.localAI[0] = 1; projectile.hostile = false; } if (!Main.npc.Any(npc => npc.type == mod.NPCType("VitricBoss") && npc.active)) { projectile.timeLeft = 0; } }
public override void Collision(Player player) { AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); if (projectile.ai[0] == 0 && projectile.Hitbox.Intersects(player.Hitbox) && mp.StatStamina < mp.StatStaminaMax && mp.Abilities.Any(a => a.Active)) { mp.StatStamina++; if (mp.wisp.Active) { mp.wisp.Timer = 60 * mp.StatStamina - 1; } projectile.ai[0] = 300; Main.PlaySound(SoundID.Shatter, projectile.Center); Main.PlaySound(SoundID.Item112, projectile.Center); CombatText.NewText(player.Hitbox, new Color(255, 170, 60), "+1"); for (float k = 0; k <= 6.28; k += 0.1f) { Dust.NewDustPerfect(projectile.Center, DustType <Dusts.Stamina>(), new Vector2((float)Math.Cos(k), (float)Math.Sin(k)) * (Main.rand.Next(50) * 0.1f), 0, default, 3f);
public override void AI() { npc.TargetClosest(true); Player player = Main.player[npc.target]; AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); if (npc.Hitbox.Intersects(player.Hitbox) && mp.ability[1] == 0) { mp.ability[1] = 1; animate = 300; Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Pickups/get")); } if (animate >= 1) { player.position = new Vector2(npc.position.X, npc.position.Y - 16); if (animate > 100 && animate < 290) { float rot = Main.rand.NextFloat(0, (float)Math.PI * 2); Dust.NewDustPerfect(player.Center + new Vector2((float)Math.Cos(rot), (float)Math.Sin(rot)) * -1000, mod.DustType("Void3"), new Vector2((float)Math.Cos(rot), (float)Math.Sin(rot)) * 15, 0, default, 3f);
public override void AI() { npc.TargetClosest(true); Player player = Main.player[npc.target]; AbilityHandler mp = player.GetHandler(); Vector2 distance = player.Center - npc.Center; Dust.NewDustPerfect(npc.Center, DustType <Dusts.Air>(), Vector2.Zero); if (distance.Length() <= 180 && !mp.Unlocked <Whip>() || Main.dayTime) { npc.ai[3] = 1; } if (npc.ai[3] == 1) { npc.velocity.Y = 10; npc.velocity.X = 0; } }
public override bool UseItem(Player player) { AbilityHandler mp = Main.LocalPlayer.GetModPlayer <AbilityHandler>(); for (int k = 0; k < mp.unlock.Length; k++) { mp.unlock[k] = 0; } for (int k = 0; k < mp.upgradeUnlock.Length; k++) { mp.upgradeUnlock[k] = 0; } for (int k = 0; k < mp.upgrade.Length; k++) { mp.upgrade[k] = 0; } mp.permanentstamina = 0; mp.HasSecondSlot = false; return(true); }
public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) { AbilityHandler mp = Main.LocalPlayer.GetModPlayer <AbilityHandler>(); timer += (float)(Math.PI * 2) / 120; if (timer >= Math.PI * 2) { timer = 0; } if (mp.ability[0] == 0) { spriteBatch.Draw(wind, npc.position - Main.screenPosition + new Vector2(0, (float)Math.Sin(timer) * 16), Color.White); Dust.NewDust(npc.position + new Vector2(0, (float)Math.Sin(timer) * 16), npc.width, npc.height, mod.DustType("Air")); } if (mp.ability[0] == 1 && animate == 0) { spriteBatch.DrawString(Main.fontItemStack, "Left Shift + A/W/S/D: Dash", npc.position - Main.screenPosition + new Vector2(-90, -32), Color.White); } }
public override void AI() { npc.TargetClosest(true); Player player = Main.player[npc.target]; AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); if (npc.Hitbox.Intersects(player.Hitbox) && mp.dash.Locked) { mp.dash.Locked = false; mp.StatStaminaMaxPerm += 1; animate = 300; Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Pickups/get")); } if (animate >= 1) { player.position = new Vector2(npc.position.X, npc.position.Y - 16); player.immune = true; player.immuneTime = 5; player.immuneNoBlink = true; if (animate > 100 && animate < 290) { float rot = Main.rand.NextFloat(0, (float)Math.PI * 2); Dust dus = Dust.NewDustPerfect(player.Center, mod.DustType("Air2"), new Vector2((float)Math.Cos(rot) * 5, (float)Math.Sin(rot) * 5)); dus.customData = animate - 50; } if (animate == 1) { player.AddBuff(BuffID.Featherfall, 120); Achievements.Achievements.QuickGive("Stormcaller", player); StarlightRiver.Instance.abilitytext.Display("Forbidden Winds", "Press " + StarlightRiver.Dash.GetAssignedKeys()[0] + " + A/W/S/D to dash", mp.dash); Helper.UnlockEntry <WindsEntry>(player); } } if (animate > 0) { animate--; } }
public override void AI() { npc.TargetClosest(true); Player player = Main.player[npc.target]; AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); if (AbilityHelper.CheckDash(player, npc.Hitbox)) { if (shielded) { shielded = false; npc.velocity += player.velocity * 0.5f; mp.dash.Active = false; player.velocity *= (player.velocity.X == 0) ? -0.4f : -0.2f; player.immune = true; player.immuneTime = 10; Main.PlaySound(SoundID.Shatter, npc.Center); for (int k = 0; k <= 20; k++) { Dust.NewDust(npc.position, 48, 32, mod.DustType("Glass2"), Main.rand.Next(-3, 2), -3, 0, default, 1.7f);
public override void UpdateEquip(Player player) { AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); if (!(mp.wisp is WispHoming) && !(mp.wisp is WispCombo)) { if (mp.wisp is WispWIP) { mp.wisp = new WispCombo(player) { Locked = false }; } else { mp.wisp = new WispHoming(player) { Locked = false }; } } }
public override void AI() { npc.TargetClosest(true); Player player = Main.player[npc.target]; AbilityHandler mp = player.GetHandler(); if (AbilityHelper.CheckDash(player, npc.Hitbox) && Shield == 1) { Shield = 0; npc.velocity += player.velocity * 0.5f; mp.ActiveAbility?.Deactivate(); player.velocity = Vector2.Normalize(player.velocity) * -10f; player.immune = true; player.immuneTime = 10; Main.PlaySound(SoundID.Shatter, npc.Center); for (int k = 0; k <= 20; k++) { Dust.NewDust(npc.position, 48, 32, DustType <Dusts.GlassGravity>(), Main.rand.Next(-3, 2), -3, 0, default, 1.7f);
private void Select(UIMouseEvent evt, UIElement listeningElement) { Player player = Main.LocalPlayer; AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); if (listeningElement == wind && mp.ability[0] == 1) { select = 1; } if (listeningElement == wisp && mp.ability[3] == 1) { select = 2; } if (listeningElement == smash && mp.ability[2] == 1) { select = 3; } if (listeningElement == shadow && mp.ability[1] == 1) { select = 4; } }
public override void AI() { npc.TargetClosest(true); Player player = Main.player[npc.target]; AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); if (npc.Hitbox.Intersects(player.Hitbox) && mp.unlock[1] == 0) { mp.unlock[1] = 1; animate = 300; Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Pickups/get")); rot = (float)(Math.PI * 2); } if (animate >= 1) { player.position = new Vector2(npc.position.X, npc.position.Y - 16); player.immune = true; player.immuneTime = 5; player.immuneNoBlink = true; if (animate > 100 && animate < 290) { if (animate % 10 == 0) { Dust dus = Dust.NewDustPerfect(player.Center, mod.DustType("Gold3"), new Vector2((float)Math.Cos(rot), (float)Math.Sin(rot)) * 10); dus.customData = animate - 50; rot -= (float)(Math.PI * 2) / 18; } } if (animate == 1) { player.AddBuff(BuffID.Featherfall, 120); } for (int k = 0; k <= 6000; k++) { if (Main.dust[k].type == mod.DustType("Gold3")) { Dust.NewDustPerfect(Main.dust[k].position, mod.DustType("Gold"), null, 0, default, 0.5f);
private void DrawOverhead(SpriteBatch spriteBatch) { Player player = Main.LocalPlayer; AbilityHandler mp = player.GetHandler(); Vector2 basepos = player.Center - Main.screenPosition - Vector2.UnitY * 48; var flagTex = GetTexture("StarlightRiver/Assets/GUI/StaminaFlag"); var emptyTex = GetTexture("StarlightRiver/Assets/GUI/StaminaSmallEmpty"); var fillTex = GetTexture("StarlightRiver/Assets/GUI/StaminaSmall"); var width = mp.StaminaMax * (fillTex.Width / 2 + 1); spriteBatch.Draw(flagTex, basepos + new Vector2(-width / 2 - 9, -3), Color.White * fade); if (mp.StaminaMax % 2 == 1) { spriteBatch.Draw(flagTex, basepos + new Vector2(width / 2 - 9, -3), Color.White * fade); } else { spriteBatch.Draw(flagTex, basepos + new Vector2(width / 2 - 9, -5), null, Color.White * fade, 0, Vector2.Zero, 1, SpriteEffects.FlipVertically, 0); } for (int k = 0; k < mp.StaminaMax; k++) { var x = k * (fillTex.Width / 2 + 1) - width / 2; var y = k % 2 == 0 ? -4 : 2; var pos = basepos + new Vector2(x, y); spriteBatch.Draw(emptyTex, pos, null, Color.White * fade, 0, fillTex.Size() / 2, 1, 0, 0); if (mp.Stamina >= k) { var scale = MathHelper.Clamp(mp.Stamina - k, 0, 1); spriteBatch.Draw(fillTex, pos, null, Color.White * scale * fade, 0, fillTex.Size() / 2, scale, 0, 0); } } }
public override void AI() { npc.TargetClosest(true); Player player = Main.player[npc.target]; AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); if (npc.Hitbox.Intersects(player.Hitbox) && mp.smash.Locked) { mp.smash.Locked = false; mp.StatStaminaMaxPerm += 1; animate = 300; Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Pickups/get")); } if (animate >= 1) { player.position = new Vector2(npc.position.X, npc.position.Y - 16); player.immune = true; player.immuneTime = 5; player.immuneNoBlink = true; if (animate > 100 && animate < 290) { float rot = (animate - 100) / 190f * 6.28f; } if (animate == 1) { player.AddBuff(BuffID.Featherfall, 120); Achievements.Achievements.QuickGive("Shatterer", player); StarlightRiver.Instance.abilitytext.Display("Gaia's Fist", "Press " + StarlightRiver.Smash.GetAssignedKeys()[0] + " in the air to dive downwards", mp.smash); } } if (animate > 0) { animate--; } }
// Update is called once per frame void Update() { if (!paused) { //snap to players position transform.position = Player.transform.position; //move the particles toward their target MoveParticles(); if (Input.GetMouseButton(0) && AbilityHandler.IsUnlocked(0)) { partRend.sortingLayerID = playerRend.sortingLayerID; partRend.sortingOrder = playerRend.sortingOrder - 1; hbPower.RemoveBPM(heartrateUsed * Time.deltaTime); } } else { part.Pause(); //reset the color } }
public AbilityProgress(int fromWho, AbilityHandler handler) { this.fromWho = fromWho; shards = handler.Shards.ToList().ToArray(); if (handler.Unlocked <Dash>()) { unlocks |= 0b10000000; } if (handler.Unlocked <Whip>()) { unlocks |= 0b01000000; } if (handler.Unlocked <Pure>()) { unlocks |= 0b00100000; } if (handler.Unlocked <Smash>()) { unlocks |= 0b00010000; } }
public override void PreUpdate() { AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); for (int j = (int)(player.position.Y / 16) - 3; j <= (int)(player.position.Y / 16) + 3; j++) { for (int i = (int)(player.position.X / 16) - 3; i <= (int)(player.position.X / 16) + 3; i++) { if ((Main.tile[i, j].type == mod.TileType("VitricOre") || Main.tile[i, j].type == mod.TileType("VitricOreFloat")) && Main.tile[i, j].frameX == 0 && Main.tile[i, j].frameY == 0) { for (float f = 0; f <= 1; f += 1 / 30f) { Vector2 lerped = Vector2.Lerp(player.position, player.oldPosition, f); if (Collision.CheckAABBvAABBCollision(lerped, new Vector2(32, 48), new Vector2(i * 16, j * 16), new Vector2(32, 48)) && mp.dashcd >= 1) { f = 2; WorldGen.KillTile(i, j); } } } } } }
/// <summary> /// Initializes the HUD /// </summary> public void InitializeHUD(PlayerCore player) { // Initialize all HUD elements if (initialized) { DeinitializeHUD(); } GetComponentInChildren <HealthBarScript>().Initialize(player); abilityHandler = GetComponentInChildren <AbilityHandler>(); if (abilityHandler) { abilityHandler.Initialize(player); } if (!initialized) { InitializeConstantHUD(player); } Camera.main.GetComponent <CameraScript>().Focus(player.transform.position); initialized = true; instance = this; }
protected override void Receive() { Player player = Main.player[fromWho]; AbilityHandler handler = player.GetHandler(); for (int k = 0; k < shards.Length; k++) { if (!handler.Shards.Has(shards[k])) { handler.Shards.Add(shards[k]); } } //Part of me really wants to change this to some sort of string matching but that would make the packet like 11x larger if ((unlocks & 0b10000000) == 0b10000000) { handler.Unlock <Dash>(); } if ((unlocks & 0b01000000) == 0b01000000) { handler.Unlock <Whip>(); } if ((unlocks & 0b00100000) == 0b00100000) { handler.Unlock <Pure>(); } if ((unlocks & 0b00010000) == 0b00010000) { handler.Unlock <Smash>(); } if (Main.netMode == Terraria.ID.NetmodeID.Server && fromWho != -1) { Send(-1, fromWho, false); } }
protected override void DrawSelf(SpriteBatch spriteBatch) { CalculatedStyle dimensions = GetDimensions(); Player player = Main.LocalPlayer; AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); for (int k = 0; k < Copies; k++) { if (k == Copies - 1 && color == Color.White) { spriteBatch.Draw(Texture, new Vector2((int)dimensions.X, (int)dimensions.Y + k * 24) + new Vector2(dimensions.Width / 2, dimensions.Height / 2), null, color, 0f, new Vector2(dimensions.Width / 2, dimensions.Height / 2), 1f + ((float)Math.Sin(LegendWorld.rottime * 2) / 8), SpriteEffects.None, 0f); spriteBatch.Draw(Texture, new Vector2((int)dimensions.X, (int)dimensions.Y + (k + 1) * 24) + new Vector2(dimensions.Width / 2, dimensions.Height / 2), null, Color.White * (1 - (mp.StatStaminaRegen / (float)mp.StatStaminaRegenMax)), 0f, new Vector2(dimensions.Width / 2, dimensions.Height / 2), (1 - (mp.StatStaminaRegen / (float)mp.StatStaminaRegenMax)), SpriteEffects.None, 0f); } else { spriteBatch.Draw(Texture, new Rectangle((int)dimensions.X, (int)dimensions.Y + k * 24, (int)dimensions.Width, (int)dimensions.Height), color); } } //special case to draw the first crystal regenerating if (color == Color.White && mp.StatStamina == 0) { spriteBatch.Draw(Texture, new Vector2((int)dimensions.X, (int)dimensions.Y) + new Vector2(dimensions.Width / 2, dimensions.Height / 2), null, Color.White * (1 - (mp.StatStaminaRegen / (float)mp.StatStaminaRegenMax)), 0f, new Vector2(dimensions.Width / 2, dimensions.Height / 2), (1 - (mp.StatStaminaRegen / (float)mp.StatStaminaRegenMax)), SpriteEffects.None, 0f); } }
public override void Collision(Player player) { AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); if (AbilityHelper.CheckDash(player, projectile.Hitbox)) { mp.dash.Active = false; if (player.velocity.Length() != 0) { player.velocity = Vector2.Normalize(player.velocity) * -18f; player.wingTime = player.wingTimeMax; player.rocketTime = player.rocketTimeMax; player.jumpAgainCloud = true; player.jumpAgainBlizzard = true; player.jumpAgainSandstorm = true; player.jumpAgainFart = true; player.jumpAgainSail = true; } Main.PlaySound(SoundID.Shatter, projectile.Center); for (int k = 0; k <= 30; k++) { int dus = Dust.NewDust(projectile.position, 48, 32, mod.DustType("Glass"), Main.rand.Next(-16, 15), Main.rand.Next(-16, 15), 0, default, 1.3f);
public override void Collision(Player player) { AbilityHandler mp = player.GetHandler(); if (AbilityHelper.CheckDash(player, projectile.Hitbox)) { mp.ActiveAbility?.Deactivate(); if (player.velocity.Length() != 0) { player.velocity = Vector2.Normalize(player.velocity) * -18f; player.wingTime = player.wingTimeMax; player.rocketTime = player.rocketTimeMax; player.jumpAgainCloud = true; player.jumpAgainBlizzard = true; player.jumpAgainSandstorm = true; player.jumpAgainFart = true; player.jumpAgainSail = true; } Main.PlaySound(SoundID.Shatter, projectile.Center); for (int k = 0; k <= 30; k++) { int dus = Dust.NewDust(projectile.position, 48, 32, Terraria.ModLoader.ModContent.DustType <Dusts.GlassAttracted>(), Main.rand.Next(-16, 15), Main.rand.Next(-16, 15), 0, default, 1.3f);
public override void AI() { npc.TargetClosest(true); Player player = Main.player[npc.target]; AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); if (npc.Hitbox.Intersects(player.Hitbox) && mp.unlock[0] == 0) { mp.unlock[0] = 1; animate = 300; Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Pickups/get")); } if (animate >= 1) { player.position = new Vector2(npc.position.X, npc.position.Y - 16); player.immune = true; player.immuneTime = 5; player.immuneNoBlink = true; if (animate > 100 && animate < 290) { float rot = Main.rand.NextFloat(0, (float)Math.PI * 2); Dust dus = Dust.NewDustPerfect(player.Center, mod.DustType("Air2"), new Vector2((float)Math.Cos(rot) * 5, (float)Math.Sin(rot) * 5)); dus.customData = animate - 50; } if (animate == 1) { player.AddBuff(BuffID.Featherfall, 120); } } if (animate > 0) { animate--; } }
public AbilityHandler swapAbilities(Ability ability) { this.preparedAbility = ability; this.activeAbilityHandler = new AbilityHandler(this, ability); return(activeAbilityHandler); }
/// <summary> /// Initialization of the ability handler that is tied to the player /// </summary> public void Initialize(PlayerCore player, Ability[] displayAbilities = null) { instance = this; core = player; if (displayAbilities == null) { abilities = core.GetAbilities(); // Get the core's ability array } else { abilities = displayAbilities; } displayAbs = displayAbilities; visibleAbilities.Clear(); foreach (Ability ab in abilities) { switch (currentVisibles) { case AbilityTypes.Skills: if (ab as Ability && !(ab as SpawnDrone) && !(ab as WeaponAbility) && !(ab as PassiveAbility)) { visibleAbilities.Add(ab); } break; case AbilityTypes.Passive: if (ab as PassiveAbility) { visibleAbilities.Add(ab); } break; case AbilityTypes.Spawns: if (ab as SpawnDrone) { visibleAbilities.Add(ab); } break; case AbilityTypes.Weapons: if (ab as WeaponAbility) { visibleAbilities.Add(ab); } break; } } keybindList = new string[10]; for (int i = 0; i < 9; i++) { keybindList[i] = PlayerPrefs.GetString("AbilityHandler_abilityKeybind" + i, (i + 1) + ""); } betterBGboxArray = new Dictionary <string, AbilityButtonScript>(); tileSpacing = betterBGbox.GetComponent <Image>().sprite.bounds.size.x * 30; // Used to space out the abilities on the GUI for (int i = 0; i < visibleAbilities.Count; i++) { // iterate through to display all the abilities if (visibleAbilities[i] == null) { break; } // position them all, do not keep the world position var id = (AbilityID)visibleAbilities[i].GetID(); var key = id != AbilityID.SpawnDrone ? $"{(int)id}" : GetAHSpawnData((visibleAbilities[i] as SpawnDrone).spawnData.drone); if (!betterBGboxArray.ContainsKey(key)) { Vector3 pos = new Vector3(GetAbilityPos(betterBGboxArray.Count), tileSpacing * 0.8F, this.transform.position.z); // find where to position the images betterBGboxArray.Add(key, Instantiate(betterBGbox, pos, Quaternion.identity).GetComponent <AbilityButtonScript>()); betterBGboxArray[key].transform.SetParent(transform, false); // set parent (do not keep world position) betterBGboxArray[key].Init(visibleAbilities[i], i < 9 && currentVisibles != AbilityTypes.Passive ? keybindList[betterBGboxArray.Count - 1] + "" : null, core, KeyName.Ability0 + i); } else { betterBGboxArray[key].AddAbility(visibleAbilities[i]); } } var HUDbgrectTransform = HUDbg.GetComponent <RectTransform>(); if (visibleAbilities.Count > 0) { var y = HUDbgrectTransform.anchoredPosition; y.x = 0.5f * tileSpacing - 1F * tileSpacing; HUDbgrectTransform.anchoredPosition = y; var x = HUDbgrectTransform.sizeDelta; x.x = GetAbilityPos(betterBGboxArray.Count - 1) + GetAbilityPos(0) - y.x; HUDbgrectTransform.sizeDelta = x; } else { HUDbgrectTransform.sizeDelta = new Vector2(0, HUDbgrectTransform.sizeDelta.y); } if (image) { Destroy(image.gameObject); } if (displayAbilities == null) { initialized = true; } // handler completely initialized, safe to update now // if display abilities were passed the handler must not update since it is merely representing // some abilities visibleAbilityOrder = player.cursave.abilityHotkeys; if (visibleAbilityOrder.skills == null) { visibleAbilityOrder = new AbilityHotkeyStruct() { skills = new List <AbilityID>(), spawns = new List <string>(), weapons = new List <AbilityID>(), passive = new List <AbilityID>() }; } if (visibleAbilityOrder.GetList((int)currentVisibles) == null || visibleAbilityOrder.GetList((int)currentVisibles).Count == 0) { visibleAbilityOrder.GetList((int)currentVisibles).Clear(); foreach (var i in instance.betterBGboxArray.Keys) { if (currentVisibles == AbilityTypes.Spawns) { (visibleAbilityOrder.GetList((int)currentVisibles) as List <string>).Add(i); } else { (visibleAbilityOrder.GetList((int)currentVisibles) as List <AbilityID>).Add((AbilityID)int.Parse(i)); } } } else { Rearrange(); } }
private void Update() { if (dragging) { var xPos = Input.mousePosition.x; AbilityHandler.RearrangeID(xPos, (AbilityID)abilities[0].GetID(), (AbilityID)abilities[0].GetID() == AbilityID.SpawnDrone ? (abilities[0] as SpawnDrone).spawnData.drone : null); } // update the number of off-CD abilities if (offCDCountText) { offCDCountText.text = abilities.FindAll(a => a && !a.IsDestroyed() && a.GetCDRemaining() == 0).Count + ""; } if (tooltip) { tooltip.transform.position = Input.mousePosition; } if (!entity || (entity as PlayerCore).GetIsInteracting()) { return; } // there's no point in running Update if there is no ability if (!abilities.Exists(ab => ab && !ab.IsDestroyed()) || entity.GetIsDead()) { if (offCDCountText) { offCDCountText.text = ""; } if (image) { image.color = new Color(.1f, .1f, .1f); // make the background dark } if (gleam) { Destroy(gleam.gameObject); // remove other sprites; destroying makes them irrelevant } if (cooldown) { Destroy(cooldown.gameObject); } return; } abilities.Sort((a, b) => { if (!a.IsDestroyed() && b.IsDestroyed()) { return(-1); } else if (a.IsDestroyed() && !b.IsDestroyed()) { return(1); } if (a.GetCDRemaining() > b.GetCDRemaining()) { return(1); } else if (a.GetCDRemaining() < b.GetCDRemaining()) { return(-1); } else if (a.GetTier() > b.GetTier()) { return(-1); } else if (a.GetTier() < b.GetTier()) { return(1); } else { return(0); } }); ReflectDescription(abilities[0]); ReflectTier(abilities[0]); ReflectName(abilities[0]); if (entity.GetHealth()[2] < abilities[0].GetEnergyCost()) { image.color = new Color(0, 0, 0.3F); // make the background dark blue } else { image.color = abilities[0].GetActiveTimeRemaining() != 0 ? Color.green : Color.white; } cooldown.fillAmount = abilities[0].GetCDRemaining() / abilities[0].GetCDDuration(); if (!entity.GetIsDead()) { bool hotkeyAccepted = (InputManager.GetKeyDown(keycode) && !InputManager.GetKey(KeyName.TurretQuickPurchase)); if (abilities[0] is WeaponAbility) { foreach (var ab in abilities) { ab.Tick(hotkeyAccepted || (clicked && Input.mousePosition == oldInputMousePos) ? 1 : 0); } } else { abilities[0].Tick(hotkeyAccepted || (clicked && Input.mousePosition == oldInputMousePos) ? 1 : 0); for (int i = 1; i < abilities.Count; i++) { abilities[i].Tick(0); } } } clicked = false; // gleam (ability temporarily going white when cooldown refreshed) stuff if (gleaming) { Gleam(); } if (abilities[0].GetCDRemaining() != 0) { gleamed = false; } else if (!gleamed && !gleaming) { gleamed = true; gleaming = true; gleam.color = Color.white; } }
public override void PreUpdate() { if (PickupTarget != null) { PickupTimer++; player.immune = true; player.immuneTime = 5; player.immuneNoBlink = true; player.Center = PickupTarget.Center; if (PickupTimer >= MaxPickupTimer) { PickupTarget = null; } } else { PickupTimer = 0; } platformTimer--; if (Main.netMode != NetmodeID.Server) { var staminaState = UILoader.GetUIState <Stamina>(); var infusionState = UILoader.GetUIState <Infusion>(); var codexState = UILoader.GetUIState <Content.GUI.Codex>(); var collectionState = UILoader.GetUIState <Collection>(); AbilityHandler mp = player.GetHandler(); staminaState.Visible = false; infusionState.Visible = false; if (mp.AnyUnlocked) { staminaState.Visible = true; } if (Main.playerInventory) { if (player.chest == -1 && Main.npcShop == 0) { collectionState.Visible = true; Content.GUI.Codex.ButtonVisible = true; if (mp.AnyUnlocked) { infusionState.Visible = true; } } else { collectionState.Visible = false; Content.GUI.Codex.ButtonVisible = false; if (mp.AnyUnlocked) { infusionState.Visible = false; } } } else { collectionState.Visible = false; Collection.ActiveAbility = null; Content.GUI.Codex.ButtonVisible = false; Content.GUI.Codex.Open = false; infusionState.Visible = false; } } if (DarkSlow) { player.velocity.X *= 0.8f; } DarkSlow = false; if (!player.immune) { VitricSpike.CollideWithSpikes(player, out int damage); if (damage > 0) { player.Hurt(PlayerDeathReason.ByCustomReason(player.name + " was impaled by glass shards."), damage, 0); } } }
protected override void DrawSelf(SpriteBatch spriteBatch) { Player player = Main.LocalPlayer; AbilityHandler mp = player.GetModPlayer <AbilityHandler>(); if (Main.hardMode) { charm.ImageScale = 1; } else { charm.ImageScale = 0; } if (select != 0) { stamina.ImageScale = 1; } else { stamina.ImageScale = 0; } if (!Main.playerInventory) { select = 0; } if (mp.unlock[0] == 1) { wind.SetImage(ModContent.GetTexture("StarlightRiver/NPCs/Pickups/Wind1")); } else { wind.SetImage(ModContent.GetTexture("StarlightRiver/GUI/blank")); } if (mp.unlock[1] == 1) { wisp.SetImage(ModContent.GetTexture("StarlightRiver/NPCs/Pickups/Wisp1")); } else { wisp.SetImage(ModContent.GetTexture("StarlightRiver/GUI/blank")); } if (mp.unlock[2] == 1) { pure.SetImage(ModContent.GetTexture("StarlightRiver/NPCs/Pickups/Purity1")); } else { pure.SetImage(ModContent.GetTexture("StarlightRiver/GUI/blank")); } if (mp.unlock[3] == 1) { smash.SetImage(ModContent.GetTexture("StarlightRiver/NPCs/Pickups/Smash1")); } else { smash.SetImage(ModContent.GetTexture("StarlightRiver/GUI/blank")); } if (mp.unlock[4] == 1) { shadow.SetImage(ModContent.GetTexture("StarlightRiver/NPCs/Pickups/Cloak1")); } else { shadow.SetImage(ModContent.GetTexture("StarlightRiver/GUI/blank")); } if (!mp.HasSecondSlot) { up2.Remove(); up1.Left.Set(50, 0); } else { back.Append(up2); up1.Left.Set(25, 0); } switch (mp.upgrade[0]) { case 0: up1.SetImage(ModContent.GetTexture("StarlightRiver/GUI/blank2")); break; case 1: up1.SetImage(ModContent.GetTexture("StarlightRiver/GUI/Wind2")); break; case 2: up1.SetImage(ModContent.GetTexture("StarlightRiver/GUI/Wind3")); break; } switch (mp.upgrade[1]) { case 0: up2.SetImage(ModContent.GetTexture("StarlightRiver/GUI/blank2")); break; case 1: up2.SetImage(ModContent.GetTexture("StarlightRiver/GUI/Wind2")); break; case 2: up2.SetImage(ModContent.GetTexture("StarlightRiver/GUI/Wind3")); break; } switch (select) { case 0: Name.SetText(""); Line1.SetText(""); Line2.SetText(""); Line3.SetText(""); break; case 1: Name.SetText("Forbidden Winds x1"); Line1.SetText("Press Shift"); Line2.SetText("Dash forward A short"); Line3.SetText("distance, breaks crystals"); break; case 2: Name.SetText("Faeflame 1/s"); Line1.SetText("Hold F"); Line2.SetText("Shrink and float in the air,"); Line3.SetText("using your mouse to steer"); break; case 3: Name.SetText("Corona of Purity x4"); Line1.SetText("Press N"); Line2.SetText("Temporarily purify the area"); Line3.SetText("around you, resist the darkness"); break; case 4: Name.SetText("Gaia's Fist x2"); Line1.SetText("Press Z"); Line2.SetText("Dive downwards, shattering"); Line3.SetText("solid rock and steel"); break; case 5: Name.SetText("Zzelera's Cloak x3"); Line1.SetText("Press Q"); Line2.SetText("Become invincible and quickly"); Line3.SetText("fly to a targeted location"); break; } }
protected override void DrawSelf(SpriteBatch spriteBatch) { Rectangle dimensions = GetDimensions().ToRectangle(); Player player = Main.LocalPlayer; AbilityHandler mp = player.GetHandler(); Texture2D emptyTex = GetTexture("StarlightRiver/Assets/GUI/StaminaEmpty"); Texture2D fillTex = overrideTexture is null?GetTexture("StarlightRiver/Assets/GUI/Stamina") : overrideTexture; int row = 0; for (int k = 0; k <= mp.StaminaMax; k++) { if (k % 7 == 0 && k != 0) { row++; } Vector2 pos = row % 2 == 0 ? dimensions.TopLeft() + new Vector2(row * -18, k % 7 * 28) : dimensions.TopLeft() + new Vector2(row * -18, 14 + k % 7 * 28); if (k >= mp.StaminaMax) //draws the incomplete vessel { Texture2D shard1 = GetTexture("StarlightRiver/Assets/Abilities/Stamina1"); Texture2D shard2 = GetTexture("StarlightRiver/Assets/Abilities/Stamina2"); if (mp.ShardCount % 3 >= 1) { spriteBatch.Draw(shard1, pos, shard1.Frame(), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0); } if (mp.ShardCount % 3 >= 2) { spriteBatch.Draw(shard2, pos, shard2.Frame(), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0); } continue; } var slotTex = emptyTex; //if (k < specialVesselTextures.Count) //slotTex = GetTexture(specialVesselTextures[k]); if (k >= mp.StaminaMax - specialVesselTextures.Count) { slotTex = GetTexture(specialVesselTextures[(int)mp.StaminaMax - k - 1]); } spriteBatch.Draw(slotTex, pos, emptyTex.Frame(), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0); // If on a filled stamina vessel if (k < mp.Stamina - 1) { spriteBatch.Draw(fillTex, pos + Vector2.One * 4, Color.White); } // If on the last stamina vessel else if (k <= mp.Stamina) { float scale = mp.Stamina - k; spriteBatch.Draw(fillTex, pos + Vector2.One * 4 + fillTex.Size() / 2, fillTex.Frame(), Color.White, 0, fillTex.Size() / 2, scale, 0, 0); } } switch (GetInstance <GUIConfig>().OverheadStaminaState) { case OverlayState.AlwaysOn: time = 120; break; case OverlayState.WhileNotFull: if (mp.Stamina < mp.StaminaMax) { time = 120; } break; case OverlayState.WhileUsing: if (mp.ActiveAbility != null) { time = 120; } break; case OverlayState.Never: time = 0; break; } if (time > 0) { fade += 0.1f; time--; } else { fade -= 0.1f; } fade = MathHelper.Clamp(fade, 0, 1); DrawOverhead(spriteBatch); overrideTexture = null; specialVesselTextures.Clear(); }