/// <summary> /// Instantiate player prefabs and link scripts. Called in awake /// </summary> /// <param name="Player1PrefabName"></param> /// <param name="Player2PrefabName"></param> public void CreatePlayers(string Player1PrefabName, string Player2PrefabName) { UnityEngine.Object Player1Prefab = Resources.Load("PlayerModels/" + Player1PrefabName); UnityEngine.Object Player2Prefab = Resources.Load("PlayerModels/" + Player2PrefabName); if (Player2Prefab == null || Player2Prefab == null) { throw new System.Exception("Could not load player prefabs of name (" + Player1PrefabName + ") or (" + Player2PrefabName + ")"); } Player1 = (GameObject)Instantiate(Player1Prefab); Player2 = (GameObject)Instantiate(Player2Prefab); AnimationController.AddAnimation(Player1PrefabName, Player1.GetComponentInChildren <Animator>()); AnimationController.AddAnimation(Player2PrefabName, Player2.GetComponentInChildren <Animator>()); PlayerControls P1Controls = Player1.GetComponent <PlayerControls>(); PlayerControls P2Controls = Player2.GetComponent <PlayerControls>(); P1Controls.gameManager = this; P2Controls.gameManager = this; P1Controls.PlayerNumber = "P1"; P2Controls.PlayerNumber = "P2"; P1Controls.OtherPlayer = Player2; P2Controls.OtherPlayer = Player1; // Hard coded starting positions Player1.transform.position = new Vector3(-4, 0.5f, 0); Player2.transform.position = new Vector3(4, 0.5f, 0); }
private void Projectiles_ProjectileFired(object sender) { Projectile proj = sender as Projectile; // Muzzleflash Animation Point size = new Point(50, 60); Point loc = new Point(proj.Location.X - size.X / 2, proj.Location.Y - size.Y / 2); float rotation = VectorMath.VectorToAngle(proj.Speed); Color col = Color.White; if (proj.Type == Projectile.ProjectileType.Enemy_Proj_Def) { col = Color.Green; } animationManager.AddAnimation(240, 12, 1, new Rectangle(loc, size), rotation, (int)Config.Graphics.AnimationType.Projectile_Explosion, col); // Trail Particle ParticleEmitter e = particleEngine.AddParticleSystem(new Texture2D[] { projectileTexture, smokeTexture }, col, proj.Location.ToVector2(), -1, 100, 11, 17, 1, 4, rotation + MathHelper.Pi, -0.2F, 0.2F, 0.1F, 5, 20); proj.Tag = e; // Shooting Sound if (proj.Type == Projectile.ProjectileType.Player_Proj_Def) { SoundEffectInstance instance = soundEffects[1].CreateInstance(); instance.Volume = 0.1F; instance.Play(); } }
private void Load() { animationManager = new AnimationManager <AnimationState>(); Animation createAnim = new Animation(TextureProvider.DarkTile.Textures.Create, AnimationConfig.CreatePeriod); Animation idleAnim = new Animation(TextureProvider.DarkTile.Textures.Idle, AnimationConfig.IdlePeriod, true); Animation destroyAnim = new Animation(TextureProvider.DarkTile.Textures.Destroy, AnimationConfig.DestroyPeriod); animationManager.AddAnimation(AnimationState.Create, createAnim, setCurrentAnimation: true); animationManager.AddAnimation(AnimationState.Idle, idleAnim); animationManager.AddAnimation(AnimationState.Destroy, destroyAnim); }
private void LoadTextures(TileType type) { animationManager = new AnimationManager <AnimationState>(); Animation idleAnim = new Animation(TextureProvider.YellowTile.Textures.Idle, AnimationConfig.IdlePeriod, true); Animation destroyAnim = new Animation(TextureProvider.YellowTile.Textures.Destroy, AnimationConfig.DestroyPeriod); Animation selectAnim = new Animation(TextureProvider.YellowTile.Textures.Destroy, AnimationConfig.SelectPeriod, true); Animation waitDestroy = new Animation(TextureProvider.YellowTile.Textures.Idle, AnimationConfig.WhaitDestroy); switch (type) { case TileType.Bomb: { idleAnim.SetDetailTexture(TextureProvider.BombTile.Textures.Idle); destroyAnim.SetDetailTexture(TextureProvider.BombTile.Textures.Destroy); selectAnim.SetDetailTexture(TextureProvider.BombTile.Textures.Destroy); waitDestroy.SetDetailTexture(TextureProvider.BombTile.Textures.Idle); break; } case TileType.HorizontalLine: { idleAnim.SetDetailTexture(TextureProvider.HorizontalLineTile.Textures.Idle); destroyAnim.SetDetailTexture(TextureProvider.HorizontalLineTile.Textures.Destroy); selectAnim.SetDetailTexture(TextureProvider.HorizontalLineTile.Textures.Destroy); waitDestroy.SetDetailTexture(TextureProvider.HorizontalLineTile.Textures.Idle); break; } case TileType.VerticalLine: { idleAnim.SetDetailTexture(TextureProvider.VerticalLineTile.Textures.Idle); destroyAnim.SetDetailTexture(TextureProvider.VerticalLineTile.Textures.Destroy); selectAnim.SetDetailTexture(TextureProvider.VerticalLineTile.Textures.Destroy); waitDestroy.SetDetailTexture(TextureProvider.VerticalLineTile.Textures.Idle); break; } default: break; } animationManager.AddAnimation(AnimationState.Idle, idleAnim, setCurrentAnimation: true); animationManager.AddAnimation(AnimationState.Destroy, destroyAnim); animationManager.AddAnimation(AnimationState.Select, selectAnim); animationManager.AddAnimation(AnimationState.WaitDestroy, waitDestroy); }
public static AnimationManager AppendAnis(this AnimationManager am, params IAnimation[] anis) { for (int i = 0; i < anis.Length; i++) { am.AddAnimation(anis[i]); } return(am); }
private static void ConfigureAnimations() { AnimationManager = new AnimationManager(); AnimationManager.AddAnimation(new AnimationWrapper("FadeOut", () => new DoubleAnimation { To = 0, BeginTime = TimeSpan.FromMilliseconds(2500), Duration = TimeSpan.FromMilliseconds(1000), EasingFunction = new QuadraticEase() }, UIElement.OpacityProperty, (sender, args, element) => element.Opacity = 0)); }
public override void LoadContent(ContentManager Content) { spritesheet = new SpriteSheet(Graphics); spritesheet.SetTexture(Content.Load <Texture2D>("Sprites/Player/Human")); /** We multiply the position x or y by 32 to move indices in the spritesheet. **/ animation.AddFrame(spritesheet.GetSprite(new Point(1 * 32, 0), new Point(32)), 200); animation.AddFrame(spritesheet.GetSprite(new Point(2 * 32, 0), new Point(32)), 200); animation.AddFrame(spritesheet.GetSprite(new Point(1 * 32, 0), new Point(32)), 200); animation.AddFrame(spritesheet.GetSprite(new Point(0 * 32, 0), new Point(32)), 200); animationManager.AddAnimation(animation); animationManager.SetActive(x => x.Name == "down_movement"); }
public void LoadAnimations() { Animation.AddAnimation(PlayerAnimation.Idle.ToString(), true, new[] { new Sprite(GameCore.Assets.Get <Texture2D>("ninja/Idle__000"), new Transform(0, 0, 232, 439), null, -new Vector2(116, 439)) }); Animation.AddAnimation(PlayerAnimation.Breath.ToString(), 0.1f, new [] { new Sprite(GameCore.Assets.Get <Texture2D>("ninja/Idle__000"), new Transform(0, 0, 232, 439), null, -new Vector2(116, 439)), new Sprite(GameCore.Assets.Get <Texture2D>("ninja/Idle__001"), new Transform(0, 0, 232, 439), null, -new Vector2(116, 439)), new Sprite(GameCore.Assets.Get <Texture2D>("ninja/Idle__002"), new Transform(0, 0, 232, 439), null, -new Vector2(116, 439)), new Sprite(GameCore.Assets.Get <Texture2D>("ninja/Idle__003"), new Transform(0, 0, 232, 439), null, -new Vector2(116, 439)), new Sprite(GameCore.Assets.Get <Texture2D>("ninja/Idle__004"), new Transform(0, 0, 232, 439), null, -new Vector2(116, 439)), new Sprite(GameCore.Assets.Get <Texture2D>("ninja/Idle__005"), new Transform(0, 0, 232, 439), null, -new Vector2(116, 439)), new Sprite(GameCore.Assets.Get <Texture2D>("ninja/Idle__006"), new Transform(0, 0, 232, 439), null, -new Vector2(116, 439)), new Sprite(GameCore.Assets.Get <Texture2D>("ninja/Idle__007"), new Transform(0, 0, 232, 439), null, -new Vector2(116, 439)), new Sprite(GameCore.Assets.Get <Texture2D>("ninja/Idle__008"), new Transform(0, 0, 232, 439), null, -new Vector2(116, 439)), new Sprite(GameCore.Assets.Get <Texture2D>("ninja/Idle__009"), new Transform(0, 0, 232, 439), null, -new Vector2(116, 439)) }); Animation.ChangeAnimation(PlayerAnimation.Breath.ToString()); }
void Start() { animationManager = GetComponent<AnimationManager>() as AnimationManager; animationManager.AddAnimation("Pulse", new int[] {1,2,3,4,0}, 30f, false); }
// Use this for initialization void Start() { animationManager = GetComponent<AnimationManager>() as AnimationManager; animationManager.AddAnimation("Flicker", new int[] {0,1}, 15f); }