Made little target enemies and updated more collision logic for everything.

This commit is contained in:
JoshuaNavarro 2019-07-22 16:50:49 -07:00
parent a75a156757
commit 1a629e5b47
13 changed files with 394 additions and 31 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.Interfaces
{
public interface ICollider
{
void onCollision(object other);
}
}

View File

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
{
public class EnemyManager
{
public List<SSCEnemy> enemies;
private List<SSCEnemy> garbageCollection;
/// <summary>
/// Constructor.
/// </summary>
public EnemyManager()
{
this.enemies = new List<SSCEnemy>();
this.garbageCollection = new List<SSCEnemy>();
}
/// <summary>
/// Adds an enemy to the game.
/// </summary>
/// <param name="enemy"></param>
public void addEnemy(SSCEnemy enemy)
{
this.enemies.Add(enemy);
}
/// <summary>
/// Removes an enemy from the game.
/// </summary>
/// <param name="enemy"></param>
public void removeEnemy(SSCEnemy enemy)
{
this.garbageCollection.Add(enemy);
}
/// <summary>
/// Update all enemies.
/// </summary>
/// <param name="time"></param>
public void update(GameTime time)
{
foreach(SSCEnemy enemy in this.garbageCollection)
{
this.enemies.Remove(enemy);
}
foreach(SSCEnemy enemy in this.enemies)
{
enemy.update(time);
if (enemy.shouldDie) this.removeEnemy(enemy);
}
}
/// <summary>
/// Draw all enemies to the screen.
/// </summary>
/// <param name="b"></param>
public void draw(SpriteBatch b)
{
foreach (SSCEnemy enemy in this.enemies)
{
enemy.draw(b);
}
}
}
}

View File

@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles;
using StardustCore.Animations;
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
{
public class SSCE_Target:SSCEnemies.SSCEnemy
{
private bool targetHit;
public SSCE_Target():base()
{
}
public SSCE_Target(AnimatedSprite Sprite, int MoveSpeed, int MaxHealth, Vector2 HitBoxDimensions,float Scale):base(Sprite,MoveSpeed,MaxHealth,HitBoxDimensions,Scale)
{
}
public override void die()
{
this.playDeathAnimation();
}
public void playDeathAnimation()
{
this.sprite.animation.playAnimationOnce("Die");
this.targetHit = true;
}
public override void update(GameTime time)
{
base.update(time);
if(this.sprite.animation.currentAnimationName=="None" && this.targetHit)
{
this.shouldDie = true;
}
}
public override void onCollision(SSCProjectile other)
{
if (other is SSCProjectiles.SSCProjectile)
{
this.CurrentHealth -= other.damage;
this.die();
}
}
public static void Spawn_SSCE_Target(Vector2 Position,Color Color)
{
SSCE_Target target = new SSCE_Target(new AnimatedSprite("TargetPractice", Position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Enemies", "Target"), new Animation(0, 0, 16, 16), new Dictionary<string, List<Animation>>() {
{ "None",new List<Animation>(){
new Animation(0,0,16,16)
} },
{"Die",new List<Animation>()
{
new Animation(0,0,16,16,20),
new Animation(16,0,16,16,20),
new Animation(32,0,16,16,20)
}
}
},"None"), Color), 0, 1, new Vector2(16,16),4f);
SeasideScramble.self.enemies.addEnemy(target);
}
}
}

View File

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Revitalize.Framework.Minigame.SeasideScrambleMinigame.Interfaces;
using StardustCore.Animations;
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCEnemies
{
public class SSCEnemy : ISSCLivingEntity
{
public float MovementSpeed { get; set; }
public int CurrentHealth { get; set; }
public int MaxHealth { get; set; }
public Rectangle HitBox { get; set; }
public AnimatedSprite sprite;
public bool shouldDie;
public float scale;
public SSCStatusEffects.StatusEffectManager statusEffects;
public Vector2 Position
{
get
{
return this.sprite.position;
}
}
public SSCEnemy()
{
}
public SSCEnemy(AnimatedSprite Sprite,int MoveSpeed, int MaxHealth,Vector2 hitBoxDimensions,float Scale)
{
this.sprite = Sprite;
this.MovementSpeed = MoveSpeed;
this.MaxHealth = MaxHealth;
this.HitBox = new Rectangle((int)this.sprite.position.X, (int)this.sprite.position.Y, (int)(hitBoxDimensions.X * Scale),(int)(hitBoxDimensions.Y * Scale));
this.CurrentHealth = MaxHealth;
this.scale = Scale;
this.statusEffects = new SSCStatusEffects.StatusEffectManager(this);
}
public virtual void update(GameTime time)
{
}
public virtual void draw(SpriteBatch b)
{
this.sprite.draw(b, SeasideScramble.GlobalToLocal(SeasideScramble.self.camera.viewport, this.Position), this.scale,0f);
}
public virtual void draw(SpriteBatch b, Vector2 Position, float Scale)
{
this.sprite.draw(b,Position, Scale, 0f);
}
public virtual void die()
{
}
public virtual void onCollision(SSCProjectiles.SSCProjectile other)
{
}
}
}

View File

@ -468,8 +468,12 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCMenus
foreach(SSCPlayer p in SeasideScramble.self.players.Values)
{
p.HUD.displayHUD();
p.statusEffects.addStatusEffect(SE_Burn.SpawnBurnEffect(new Vector2(p.HUD.xPositionOnScreen,p.HUD.yPositionOnScreen),10*1000,1000,1.00d,1));
//p.statusEffects.addStatusEffect(SE_Burn.SpawnBurnEffect(new Vector2(p.HUD.xPositionOnScreen,p.HUD.yPositionOnScreen),10*1000,1000,1.00d,1));
}
SSCEnemies.SSCE_Target.Spawn_SSCE_Target(new Vector2(100, 100), Color.Blue);
SSCEnemies.SSCE_Target.Spawn_SSCE_Target(new Vector2(200, 100), Color.Red);
SSCEnemies.SSCE_Target.Spawn_SSCE_Target(new Vector2(300, 100), Color.Green);
}
/// <summary>

View File

@ -13,11 +13,8 @@ using Revitalize.Framework.Minigame.SeasideScrambleMinigame.Interfaces;
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
{
public class SSCPlayer:ISSCLivingEntity
public class SSCPlayer : ISSCLivingEntity
{
//TODO: Add movement speed variable
//TODO: Add in health
//TODO: Add in player HUD
public AnimationManager characterSpriteController;
public bool flipSprite;
public SSCEnums.FacingDirection facingDirection;
@ -55,10 +52,10 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
}
}
public float MovementSpeed { get => this.movementSpeed; set => this.movementSpeed=value; }
public int CurrentHealth { get => this.currentHealth; set => this.currentHealth=value; }
public int MaxHealth { get => this.maxHealth; set => this.maxHealth=value; }
public Rectangle HitBox { get => this.hitBox; set => this.hitBox=value; }
public float MovementSpeed { get => this.movementSpeed; set => this.movementSpeed = value; }
public int CurrentHealth { get => this.currentHealth; set => this.currentHealth = value; }
public int MaxHealth { get => this.maxHealth; set => this.maxHealth = value; }
public Rectangle HitBox { get => this.hitBox; set => this.hitBox = value; }
public SSCPlayer(SSCEnums.PlayerID PlayerID)
{
@ -148,7 +145,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
}
this.mouseSensitivity = new Vector2(3f, 3f);
this.gun=new SSCGuns.SSCGun(new StardustCore.Animations.AnimatedSprite("MyFirstGun",this.position,new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Guns","BasicGun"),new Animation(0,0,16,16)),Color.White), SeasideScramble.self.projectiles.getDefaultProjectile(this, this.position, Vector2.Zero, 1f, new Rectangle(0, 0, 16, 16), Color.White, 4f, 300),10,1000,3000);
this.gun = new SSCGuns.SSCGun(new StardustCore.Animations.AnimatedSprite("MyFirstGun", this.position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Guns", "BasicGun"), new Animation(0, 0, 16, 16)), Color.White), SeasideScramble.self.projectiles.getDefaultProjectile(this, this.position, Vector2.Zero, 1f, new Rectangle(0, 0, 16, 16), Color.White, 4f, 300), 10, 1000, 3000);
this.hitBox = new Rectangle((int)this.position.X, (int)this.position.Y, 64, 64);
@ -211,7 +208,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
public void draw(SpriteBatch b, Vector2 position)
{
this.characterSpriteController.draw(b, SeasideScramble.GlobalToLocal(SeasideScramble.self.camera.viewport, position), this.playerColor, 4f, this.flipSprite == true ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (this.position.Y) / 10000f));
this.gun.draw(b, SeasideScramble.GlobalToLocal(SeasideScramble.self.camera.viewport, position),2f);
this.gun.draw(b, SeasideScramble.GlobalToLocal(SeasideScramble.self.camera.viewport, position), 2f);
}
public void drawMouse(SpriteBatch b)
{
@ -220,7 +217,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
public void drawHUD(SpriteBatch b)
{
this.HUD.draw(b);
this.statusEffects.draw(b,4f);
this.statusEffects.draw(b, 4f);
}
/// <summary>
@ -347,7 +344,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
{
if (state.ThumbSticks.Right.X != 0 || state.ThumbSticks.Right.Y != 0)
{
this.moveMouseCursor(new Vector2(state.ThumbSticks.Right.X,state.ThumbSticks.Right.Y*-1));
this.moveMouseCursor(new Vector2(state.ThumbSticks.Right.X, state.ThumbSticks.Right.Y * -1));
this.showMouseCursor = true;
}
}
@ -361,15 +358,15 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
{
if (SeasideScramble.self.camera.positionInsideViewport(this.mouseCursor.position + new Vector2(direction.X * this.mouseSensitivity.X, direction.Y * this.mouseSensitivity.Y)))
{
this.mouseCursor.position += new Vector2(direction.X*this.mouseSensitivity.X,direction.Y*this.mouseSensitivity.Y);
this.mouseCursor.position += new Vector2(direction.X * this.mouseSensitivity.X, direction.Y * this.mouseSensitivity.Y);
}
else if (SeasideScramble.self.camera.positionInsideViewport(this.mouseCursor.position + new Vector2(direction.X*this.mouseSensitivity.X, 0)))
else if (SeasideScramble.self.camera.positionInsideViewport(this.mouseCursor.position + new Vector2(direction.X * this.mouseSensitivity.X, 0)))
{
this.mouseCursor.position += new Vector2(direction.X * this.mouseSensitivity.X, 0);
}
else if (SeasideScramble.self.camera.positionInsideViewport(this.mouseCursor.position + new Vector2(0, direction.Y*this.mouseSensitivity.Y)))
else if (SeasideScramble.self.camera.positionInsideViewport(this.mouseCursor.position + new Vector2(0, direction.Y * this.mouseSensitivity.Y)))
{
this.mouseCursor.position += new Vector2(0, direction.Y*this.mouseSensitivity.Y);
this.mouseCursor.position += new Vector2(0, direction.Y * this.mouseSensitivity.Y);
}
}
@ -393,7 +390,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
Vector2 pos = this.mouseCursor.position - SeasideScramble.GlobalToLocal(this.position);
return pos;
}
/// <summary>
/// Checks when the player presses a key on the keyboard.
@ -525,13 +522,14 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
//SeasideScramble.self.projectiles.spawnDefaultProjectile(this, this.position, direction, 1f, new Rectangle(0, 0, 16, 16), Color.White, 4f, 300);
this.gun.tryToShoot(this.position, direction);
}
public void takeDamage(int amount)
{
this.currentHealth -= amount;
if (this.currentHealth < 0) {
if (this.currentHealth < 0)
{
this.currentHealth = 0;
}
}
@ -546,5 +544,33 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
this.currentHealth = this.maxHealth;
}
public void onCollision(SSCProjectiles.SSCProjectile projectile)
{
if (projectile is SSCProjectiles.SSCProjectile)
{
if (projectile.hasOwner())
{
if (projectile.owner == this)
{
//ModCore.log("Can't get hit by own projectile.");
return;
}
/*if projectile.owner is player and friendly fire is off do nothing.
*
*
*/
}
ModCore.log("Big oof. Player hit by projectile.");
this.CurrentHealth -= projectile.damage;
this.statusEffects.addStatusEffect(projectile.effect);
}
}
public void onCollision(SSCEnemies.SSCEnemy enemy)
{
}
}
}

View File

@ -56,11 +56,13 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles
}
}
public SSCStatusEffects.StatusEffect effect;
public SSCProjectile()
{
}
public SSCProjectile(object Owner,AnimatedSprite Sprite,Rectangle HitBox ,Vector2 Position,Vector2 Direction, float Speed, int LifeSpan ,float Scale,int damage)
public SSCProjectile(object Owner,AnimatedSprite Sprite,Rectangle HitBox ,Vector2 Position,Vector2 Direction, float Speed, int LifeSpan ,float Scale,int damage,SSCStatusEffects.StatusEffect Effect=null)
{
this.sprite = Sprite;
this.hitBox = HitBox;
@ -72,6 +74,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles
this.currentLifeSpan = LifeSpan;
this.owner = Owner;
this.damage = damage;
this.effect = Effect;
}
/// <summary>
@ -142,14 +145,18 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles
return this.hitBox.Intersects(rec);
}
/// <summary>
/// What happens to this projectile when it collides with something.
/// </summary>
public virtual void collisionLogic()
{
//Do something I guess.
//Do something I guess like play an animation.
this.die();
}
public virtual void onCollision(object other)
{
//Move this if to the player class.????
if(other is SSCPlayer)
{
if (this.hasOwner())
@ -159,10 +166,14 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles
//ModCore.log("Can't get hit by own projectile.");
return;
}
/*if projectile.owner is player and friendly fire is off do nothing.
*
*
*/
}
ModCore.log("Big oof. Player hit by projectile.");
this.collisionLogic();
}
this.collisionLogic();
}
/// <summary>

View File

@ -48,6 +48,15 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCProjectiles
if (p.collidesWith(player.hitBox))
{
p.onCollision(player);
player.onCollision(p);
}
}
foreach(SSCEnemies.SSCEnemy enemy in SeasideScramble.self.enemies.enemies)
{
if (p.collidesWith(enemy.HitBox))
{
p.onCollision(enemy); //What happens to the projectile.
enemy.onCollision(p); //What happens to the entity.
}
}
}

View File

@ -11,8 +11,7 @@ using StardewValley;
namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCStatusEffects
{
/// <summary>
/// TODO: Maybe figure out a way to add immunity/resistences/weaknesses later???
/// Add in a reference to the owner of this and have the manager apply effects to entities.
/// TODO: Have it so that this determines where to draw the status effects.
/// </summary>
public class StatusEffectManager
{
@ -55,7 +54,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame.SSCStatusEffects
/// <param name="effect"></param>
public void addStatusEffect(StatusEffect effect, bool ignoreEffectChance = false)
{
if (effect == null) return;
if (ignoreEffectChance == false)
{
double rng = this.random.NextDouble();

View File

@ -50,6 +50,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
public Vector2 oldMousePosition;
public SSCProjectiles.SSCProjectileManager projectiles;
public SSCEnemies.EnemyManager enemies;
public SSCFonts.SSCFont gameFont;
@ -79,6 +80,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
this.oldMousePosition = new Vector2(Game1.getMousePosition().X, Game1.getMousePosition().Y);
this.gameFont = new SSCFonts.SSCFont(new SSCFonts.SSCFontCharacterSheet());
this.enemies = new SSCEnemies.EnemyManager();
}
public SSCPlayer getPlayer(SSCEnums.PlayerID id)
@ -97,20 +99,21 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
playerManager.searchForTextures(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Minigames", "SeasideScramble", "Graphics", "Player"));
TextureManager mapTextureManager = new TextureManager("SSCMaps");
mapTextureManager.searchForTextures(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Minigames", "SeasideScramble", "Maps", "Backgrounds"));
TextureManager UIManager = new TextureManager("SSCUI");
UIManager.searchForTextures(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Minigames", "SeasideScramble", "Graphics", "UI"));
TextureManager projectileManager = new TextureManager("Projectiles");
projectileManager.searchForTextures(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Minigames", "SeasideScramble", "Graphics", "Projectiles"));
TextureManager gunManager = new TextureManager("Guns");
gunManager.searchForTextures(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Minigames", "SeasideScramble", "Graphics", "Guns"));
TextureManager enemies = new TextureManager("Enemies");
enemies.searchForTextures(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Minigames", "SeasideScramble", "Graphics", "Enemies"));
this.textureUtils.addTextureManager(playerManager);
this.textureUtils.addTextureManager(mapTextureManager);
this.textureUtils.addTextureManager(UIManager);
this.textureUtils.addTextureManager(projectileManager);
this.textureUtils.addTextureManager(gunManager);
this.textureUtils.addTextureManager(enemies);
}
private void LoadMaps()
@ -180,6 +183,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
p.drawMouse(b);
}
}
this.enemies.draw(b);
this.menuManager.drawAll(b);
@ -349,6 +353,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
GamePadState state = this.getGamepadState((PlayerIndex)i);
this.receiveGamepadInput(state,(SSCEnums.PlayerID)i);
}
if (this.quitGame)
@ -372,6 +377,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame
{
player.update(time);
}
this.enemies.update(time);
}
else
{

View File

@ -65,10 +65,14 @@
<Compile Include="Framework\Illuminate\FakeLightSource.cs" />
<Compile Include="Framework\Illuminate\LightManager.cs" />
<Compile Include="Framework\Menus\SimpleItemGrabMenu.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ICollider.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ISSCLivingEntity.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SeasideScramble.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SeasideScrambleMap.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCCamera.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEnemies\EnemyManager.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEnemies\SSCEnemy.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEnemies\SSCE_Target.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCEnums.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCFonts\SSCFontCharacterSheet.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCFonts\SSCFont.cs" />
@ -141,6 +145,9 @@
<Content Include="Content\Graphics\Furniture\Tables\Oak Table.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Minigames\SeasideScramble\Graphics\Enemies\Target.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Content\Minigames\SeasideScramble\Graphics\Guns\BasicGun.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@ -18,6 +18,7 @@ namespace StardustCore.Animations
public Animation defaultDrawFrame;
public Animation currentAnimation;
public bool enabled;
public bool loopAnimation;
public string animationDataString;
@ -95,12 +96,20 @@ namespace StardustCore.Animations
}
}
/// <summary>Get the next animation in the list of animations.</summary>
/// <summary>Get the next animation frame in the list of animations.</summary>
public void getNextAnimation()
{
this.currentAnimationListIndex++;
if (this.currentAnimationListIndex == this.currentAnimationList.Count) //If the animation frame I'm tryting to get is 1 outside my list length, reset the list.
this.currentAnimationListIndex = 0;
if (this.loopAnimation)
{
this.currentAnimationListIndex = 0;
}
else
{
this.playDefaultAnimation();
return;
}
//Get the next animation from the list and reset it's counter to the starting frame value.
this.currentAnimation = this.currentAnimationList[this.currentAnimationListIndex];
@ -137,9 +146,13 @@ namespace StardustCore.Animations
}
}
/// <summary>Gets the animation from the dictionary of all animations available.</summary>
/// <summary>
/// Plays the animation for the animation manager.
/// </summary>
/// <param name="AnimationName"></param>
/// <param name="overrideSameAnimation"></param>
/// <param name="StartingFrame"></param>
/// <returns></returns>
public bool playAnimation(string AnimationName,bool overrideSameAnimation=false,int StartingFrame = 0)
{
if (this.animations.TryGetValue(AnimationName, out List<Animation> dummyList))
@ -154,6 +167,7 @@ namespace StardustCore.Animations
this.currentAnimation = this.currentAnimationList[StartingFrame];
this.currentAnimationName = AnimationName;
this.currentAnimation.startAnimation();
this.loopAnimation = true;
return true;
}
else
@ -172,6 +186,56 @@ namespace StardustCore.Animations
}
}
/// <summary>
/// Plays the animation for the animation manager only once.
/// </summary>
/// <param name="AnimationName"></param>
/// <param name="overrideSameAnimation"></param>
/// <param name="StartingFrame"></param>
/// <returns></returns>
public bool playAnimationOnce(string AnimationName, bool overrideSameAnimation = false, int StartingFrame = 0)
{
if (this.animations.TryGetValue(AnimationName, out List<Animation> dummyList))
{
if (overrideSameAnimation == false)
{
if (this.currentAnimationName == AnimationName) return true;
}
if (dummyList.Count != 0 || StartingFrame >= dummyList.Count)
{
this.currentAnimationList = dummyList;
this.currentAnimation = this.currentAnimationList[StartingFrame];
this.currentAnimationName = AnimationName;
this.currentAnimation.startAnimation();
this.loopAnimation = false;
return true;
}
else
{
if (dummyList.Count == 0)
ModCore.ModMonitor.Log("Error: Current animation " + AnimationName + " has no animation frames associated with it.");
if (dummyList.Count > dummyList.Count)
ModCore.ModMonitor.Log("Error: Animation frame " + StartingFrame + " is outside the range of provided animations. Which has a maximum count of " + dummyList.Count);
return false;
}
}
else
{
ModCore.ModMonitor.Log("Error setting animation: " + AnimationName + " animation does not exist in list of available animations. Did you make sure to add it in?");
return false;
}
}
/// <summary>
/// Plays the default animation.
/// </summary>
public void playDefaultAnimation()
{
this.currentAnimation = this.defaultDrawFrame;
this.currentAnimationName = "";
this.currentAnimationListIndex = 0;
}
/// <summary>Sets the animation manager to an on state, meaning that this animation will update on the draw frame.</summary>
public void enableAnimation()
{