public void SetTile(State state, Motion motion, Vector2 position, Texture2D tileSheet, Rectangle tileArea) { this.state = state; this.motion = motion; this.position = position; increase = true; tileImage = CropImage(tileSheet, tileArea); range = 90; counter = 0; moveSpeed = 80f; animation = new Animation(); animation.LoadContent(ScreenManager.Instance.Content, tileImage, "", position, Color.White); containsEntity = false; velocity = Vector2.Zero; }
public override void Update(GameTime gameTime, ref Animation a) { if (a.IsActive) { if (!stopUpdating) { if (!increase) a.Alpha -= fadeSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; else a.Alpha += fadeSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; if (a.Alpha <= 0.0f) { a.Alpha = 0.0f; increase = true; } else if (a.Alpha >= 1.0f) { a.Alpha = 1.0f; increase = false; } } if (a.Alpha == activateValue) { stopUpdating = true; timer -= gameTime.ElapsedGameTime; if (timer.TotalSeconds <= 0) { timer = defaultTime; stopUpdating = false; } } } else { a.Alpha = defaultAlpha; stopUpdating = false; } }
public override void Update(GameTime gameTime, ref Animation a) { currentFrame = a.CurrentFrame; if (a.IsActive) { frameCounter += (int)gameTime.ElapsedGameTime.TotalMilliseconds; if (frameCounter >= switchFrame) { frameCounter = 0; currentFrame.X++; if (currentFrame.X * a.FrameWidth >= a.Image.Width) currentFrame.X = 0; } } else { frameCounter = 0; //currentFrame.X = 1; } a.CurrentFrame = currentFrame; a.SourceRect = new Rectangle((int)currentFrame.X * a.FrameWidth, (int)currentFrame.Y * a.FrameHeight, a.FrameWidth, a.FrameHeight); }
public void Initialize() { Animation = new Animation(); ssAnimation = new SpriteSheetAnimation(); fAnimation = new FadeAnimation(); currentScreen = new SplashScreen(); inputManager = new InputManager(); }
public virtual void Update(GameTime gameTime, ref Animation a) { }
public virtual void LoadContent(ContentManager content, List<string> attributes, List<string> contents, InputManager input) { this.content = new ContentManager(content.ServiceProvider, "Content"); moveAnimation = new Animation(); ssAnimation = new SpriteSheetAnimation(); fAnimation = new FadeAnimation(); images = new List<Texture2D>(); healths = new List<int>(); framesList = new List<Vector2>(); moveSpeeds = new List<float>(); for (int i = 0; i < attributes.Count; i++) { switch (attributes[i]) { case "Image": Texture2D tempImage = this.content.Load<Texture2D>(contents[i]); string[] name = contents[i].Split('/'); tempImage.Name = name[name.Count() - 1]; image = tempImage; break; case "Frames": string[] framesTemp = contents[i].Split(','); moveAnimation.Frames = new Vector2(int.Parse(framesTemp[0]), int.Parse(framesTemp[1])); break; case "Position": string[] pos = contents[i].Split(','); position = new Vector2(int.Parse(pos[0]) * Layer.Instance.TileDimensions.X, int.Parse(pos[1]) * Layer.Instance.TileDimensions.Y); break; case "Health": health = int.Parse(contents[i]); break; case "MoveSpeed" : moveSpeed = float.Parse(contents[i]); break; case "Range": range = int.Parse(contents[i]); break; } } gravity = 100f; velocity = Vector2.Zero; syncTilePosition = false; activateGravity = true; moveAnimation.LoadContent(content, image, "", position, Color.White); }