// Start is called before the first frame update void Start() { // get scripts we need charDirection = this.GetComponent <CharDirection>(); characterMover = this.GetComponent <CharacterMover>(); characterAnimator = this.GetComponent <CharacterAnimator>(); }
// we will need this c# magic for our animation state when its in //public bool isMovingTest //{ // set // { // if (Input.GetAxis("Vertical") == 0 && Input.GetAxis("Horizontal") == 0) { isMoving = false; } // else { isMoving = true; } // } // get { return isMoving; } //} // Start is called before the first frame update void Start() { charDirection = this.GetComponent <CharDirection>(); characterMover = this.GetComponent <CharacterMover>(); characterAnimator = this.GetComponent <CharacterAnimator>(); worldInteracter = this.GetComponent <WorldInteracter>(); }
override public void ShowGUI(List <ActionParameter> parameters) { isPlayer = EditorGUILayout.Toggle("Affect Player?", isPlayer); if (!isPlayer) { charToMoveParameterID = Action.ChooseParameterGUI("Character to turn:", parameters, charToMoveParameterID, ParameterType.GameObject); if (charToMoveParameterID >= 0) { charToMoveID = 0; charToMove = null; } else { charToMove = (Char)EditorGUILayout.ObjectField("Character to turn:", charToMove, typeof(Char), true); charToMoveID = FieldToID <Char> (charToMove, charToMoveID); charToMove = IDToField <Char> (charToMove, charToMoveID, false); } } direction = (CharDirection)EditorGUILayout.EnumPopup("Direction to face:", direction); isInstant = EditorGUILayout.Toggle("Is instant?", isInstant); if (!isInstant) { willWait = EditorGUILayout.Toggle("Wait until finish?", willWait); } AfterRunningOption(); }
// Constructor /// <summary> /// Create a new Slime object /// </summary> /// <param name="location">The location to draw this Slime in when /// instantiated</param> /// <param name="healthBarBackground">The background texture of /// this Slime's health bar</param> /// <param name="healthBarForeground">The foreground texture of /// this Slime's health bar</param> /// <param name="health">The maximum health value of this Slime</param> /// <param name="speed">The chronological identifier for this Slime in /// battle</param> /// <param name="state">The state to instantiate this Slime in</param> /// <param name="direction">The direction to draw this Slime in</param> public Slime(Vector2 location, Texture2D healthBarBackground, Texture2D healthBarForeground, int health = SLIME_HEALTH, int speed = SLIME_SPEED, CharacterState state = CharacterState.o_idle, CharDirection direction = CharDirection.left) : base(slimeSprite, location, health, speed, healthBarBackground, healthBarForeground, font, 0.1, state, direction) { damage = SLIME_DAMAGE; damageCycleIndex = 5; chargeCycles = 4; frames[IDLE_FRAME] = new Rectangle(0, 0, FRAME_SIZE, FRAME_SIZE); frames[1] = new Rectangle(FRAME_SIZE, 0, FRAME_SIZE, FRAME_SIZE); frames[2] = new Rectangle(2 * FRAME_SIZE, 0, FRAME_SIZE, FRAME_SIZE); frames[3] = new Rectangle(3 * FRAME_SIZE, 0, FRAME_SIZE, FRAME_SIZE); frames[4] = new Rectangle(0, FRAME_SIZE, FRAME_SIZE, FRAME_SIZE); frames[5] = new Rectangle(FRAME_SIZE, FRAME_SIZE, FRAME_SIZE, FRAME_SIZE); frames[6] = new Rectangle(2 * FRAME_SIZE, FRAME_SIZE, FRAME_SIZE, FRAME_SIZE); attackIndicies = new int[8] { 0, 1, 2, 3, 4, 5, 6, 0 }; walkIndicies = new int[4] { 1, 2, 3, 0 }; // Setup the QuickTimeEvent for this Slime //quickTimeTimer = SLIME_TIMER; quickTimeEvent.WindowLength = SLIME_TIMER; }
// Constructor /// <summary> /// Create a new Zombie object /// </summary> /// <param name="location">The location to draw this Zombie in when /// instantiated</param> /// <param name="healthBarBackground">The background texture of /// this Zombie's health bar</param> /// <param name="healthBarForeground">The foreground texture of /// this Zombie's health bar</param> /// <param name="health">The maximum health value of this Zombie</param> /// <param name="speed">The chronological identifier for this Zombie in /// battle</param> /// <param name="state">The state to instantiate this Zombie in</param> /// <param name="direction">The direction to draw this Zombie in</param> public Zombie(Vector2 location, Texture2D healthBarBackground, Texture2D healthBarForeground, int health = ZOM_HEALTH, int speed = ZOM_SPEED, CharacterState state = CharacterState.o_idle, CharDirection direction = CharDirection.left) : base(zombieSprite, location, health, speed, healthBarBackground, healthBarForeground, font, 0.2, state, direction) { damage = ZOM_DAMAGE; damageCycleIndex = 4; chargeTime = BASE_CHARGE; frames[3] = new Rectangle(3 * FRAME_SIZE, 0, FRAME_SIZE, FRAME_SIZE); frames[4] = new Rectangle(0, FRAME_SIZE, FRAME_SIZE, FRAME_SIZE); walkIndicies = new int[2] { 4, 0 }; attackIndicies = new int[6] { 0, 1, 2, 3, 1, 0 }; // Setup the QuickTimeEvent for this Zombie //quickTimeTimer = ZOM_TIMER; quickTimeEvent.WindowLength = ZOM_TIMER; }
public void Init(PathSpeed _moveSpeed, bool _turnInstantly, bool _forceDirection, CharDirection _charDirection, CharacterAnimation2DShot _activeShot) { moveSpeed = _moveSpeed; forceDirection = _forceDirection; charDirection = _charDirection; turnInstantly = _turnInstantly; activeShot = _activeShot; }
public void FaceTo(CharDirection dir) { if (dir == CharDirection.LEFT) { transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, 0.0f)); } else { transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 180.0f, 0.0f)); } }
/** * <summary>Creates a new instance of the 'Character: Face direction' Action</summary> * <param name = "characterToTurn">The character to affect</param> * <param name = "directionToFace">The direction to face</param> * <param name = "relativeTo">What the supplied direction is relative to</param> * <param name = "isInstant">If True, the character will stop turning their head instantly</param> * <param name = "waitUntilFinish">If True, then the Action will wait until the transition is complete</param> * <returns>The generated Action</returns> */ public static ActionCharFaceDirection CreateNew(AC.Char characterToTurn, CharDirection directionToFace, RelativeTo relativeTo = RelativeTo.Camera, bool isInstant = false, bool waitUntilFinish = false) { ActionCharFaceDirection newAction = (ActionCharFaceDirection)CreateInstance <ActionCharFaceDirection>(); newAction.charToMove = characterToTurn; newAction.direction = directionToFace; newAction.relativeTo = relativeTo; newAction.isInstant = isInstant; newAction.willWait = waitUntilFinish; return(newAction); }
public void ShowGUI() { moveSpeed = (PathSpeed)EditorGUILayout.EnumPopup("Animation when moving:", moveSpeed); turnInstantly = EditorGUILayout.Toggle("Turning is instant?", turnInstantly); forceDirection = EditorGUILayout.Toggle("Face fixed direction?", forceDirection); if (forceDirection) { charDirection = (CharDirection)EditorGUILayout.EnumPopup("Direction:", charDirection); } EditorGUILayout.Space(); EditorGUILayout.HelpBox("This track type does not support live previewing.", MessageType.Info); }
public override void AssignValues(List <ActionParameter> parameters) { if (isPlayer) { runtimeCharToMove = AssignPlayer(playerID, parameters, charToMoveParameterID); } else { runtimeCharToMove = AssignFile <Char> (parameters, charToMoveParameterID, charToMoveID, charToMove); } if (directionParameterID >= 0) { int _directionInt = AssignInteger(parameters, directionParameterID, 0); direction = (CharDirection)_directionInt; } }
public override void ShowGUI(List <ActionParameter> parameters) { isPlayer = EditorGUILayout.Toggle("Affect Player?", isPlayer); if (isPlayer) { if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow) { charToMoveParameterID = ChooseParameterGUI("Player ID:", parameters, charToMoveParameterID, ParameterType.Integer); if (charToMoveParameterID < 0) { playerID = ChoosePlayerGUI(playerID, true); } } } else { charToMoveParameterID = ChooseParameterGUI("Character to turn:", parameters, charToMoveParameterID, ParameterType.GameObject); if (charToMoveParameterID >= 0) { charToMoveID = 0; charToMove = null; } else { charToMove = (Char)EditorGUILayout.ObjectField("Character to turn:", charToMove, typeof(Char), true); charToMoveID = FieldToID <Char> (charToMove, charToMoveID); charToMove = IDToField <Char> (charToMove, charToMoveID, false); } } directionParameterID = Action.ChooseParameterGUI("Direction to face:", parameters, directionParameterID, ParameterType.Integer); if (directionParameterID < 0) { direction = (CharDirection)EditorGUILayout.EnumPopup("Direction to face:", direction); } relativeTo = (RelativeTo)EditorGUILayout.EnumPopup("Direction is relative to:", relativeTo); isInstant = EditorGUILayout.Toggle("Is instant?", isInstant); if (!isInstant) { willWait = EditorGUILayout.Toggle("Wait until finish?", willWait); } AfterRunningOption(); }
//protected double coolDownTimer; // The dodge cooldown timer. Color should change while dodging, return to normal after, and ability to dodge again returns after cooldown // Properties // Constructor /// <summary> /// Create a new Enemy /// </summary> /// <param name="spriteSheet">All sprites for this Enemy in a single /// image. Must have (an) idle, walking, and attack frame(s).</param> /// <param name="location">The base location of this Enemy when they are /// instantiated</param> /// <param name="health">The maximum health value for this Enemy /// </param> /// <param name="speed">The value used to determine the chronological /// order of attack during battles. Lower numbers have higher priority. /// </param> /// <param name="timePerFrame">The time that a frame of animation draws /// for before advancing to the next frame</param> /// <param name="healthBarBackground">The background texture of the /// health bar texture for this Enemy</param> /// <param name="healthBarForeground">The foreground texture of the /// health bar texture for this Enemy (the overlay)</param> /// <param name="healthFont">The font of the text in the health bar /// </param> /// <param name="state">The current CharacterState of this Enemy when /// it's initiated</param> /// <param name="direction">Whether this Enemy should be /// instantiated facing right or left</param> public Enemy(Texture2D spriteSheet, Vector2 location, int health, int speed, Texture2D healthBarBackground, Texture2D healthBarForeground, SpriteFont healthFont, double timePerFrame = 0.1, CharacterState state = CharacterState.o_idle, CharDirection direction = CharDirection.left) : base(spriteSheet, location, health, speed, timePerFrame, healthBarBackground, healthBarForeground, healthFont, state, direction) { frames = new Dictionary <int, Rectangle>(3); frames[IDLE_FRAME] = new Rectangle(0, 0, FRAME_SIZE, FRAME_SIZE); frames[1] = new Rectangle(FRAME_SIZE, 0, FRAME_SIZE, FRAME_SIZE); frames[2] = new Rectangle(2 * FRAME_SIZE, 0, FRAME_SIZE, FRAME_SIZE); walkIndicies = new int[2] { 0, 2 }; attackIndicies = new int[5] { 0, 1, 2, 1, 0 }; damageCycleIndex = 3; o_position.Width = 50; o_position.Height = 50; b_position = new Rectangle( (int)location.X, (int)location.Y, FRAME_SIZE / BATTLE_PROPORTION, FRAME_SIZE / BATTLE_PROPORTION); B_LocX = location.X; B_LocY = location.Y; // Create the QuickTimeEvent for this Enemy //quickTimeTimer = BASE_ENEMY_TIMER; quickTimeEvent = new QuickTimeEvent(NullifyDamage, Microsoft.Xna.Framework.Input.Keys.Q, BASE_ENEMY_TIMER); //coolDownTimer = 0; }
// Properties // Constructor /// <summary> /// Create a new Ally /// </summary> /// <param name="spriteSheet">All sprites for this Ally in a single /// image. Must have (an) idle, walking, and attack frame(s).</param> /// <param name="location">The base location of this Ally when they are /// instantiated</param> /// <param name="health">The maximum health value for this Ally /// </param> /// <param name="speed">The value used to determine the chronological /// order of attack during battles. Lower numbers have higher priority. /// </param> /// <param name="timePerFrame">The time that a frame of animation draws /// for before advancing to the next frame</param> /// <param name="healthBarBackground">The background texture of the /// health bar texture for this Ally</param> /// <param name="healthBarForeground">The foreground texture of the /// health bar texture for this Ally (the overlay)</param> /// <param name="healthFont">The font of the text in the health bar /// </param> /// <param name="state">The current CharacterState of this Ally when /// it's initiated</param> /// <param name="direction">Whether this Ally should be /// instantiated facing right or left</param> public Ally(Texture2D spriteSheet, Vector2 location, int health, int speed, Texture2D healthBarBackground, Texture2D healthBarForeground, SpriteFont healthFont, double timePerFrame = 0.1, CharacterState state = CharacterState.o_idle, CharDirection direction = CharDirection.right) : base(spriteSheet, location, health, speed, timePerFrame, healthBarBackground, healthBarForeground, healthFont, state, direction) { frames = new Dictionary <int, Rectangle>(3); frames[IDLE_FRAME] = new Rectangle(0, 0, FRAME_SIZE, FRAME_SIZE); frames[JUMP_FRAME] = new Rectangle(FRAME_SIZE, 0, FRAME_SIZE, FRAME_SIZE); frames[2] = new Rectangle(2 * FRAME_SIZE, 0, FRAME_SIZE, FRAME_SIZE); walkIndicies = new int[2] { 0, 2 }; attackIndicies = new int[5] { 0, 1, 2, 1, 0 }; o_position.Width = 25; o_position.Height = 50; b_position = new Rectangle( (int)location.X, (int)location.Y, FRAME_SIZE / 3, FRAME_SIZE / 3); // Create the QuickTimeEvent for this Ally //quickTimeTimer = BASE_ALLY_TIMER; quickTimeEvent = new QuickTimeEvent( new List <ActivationFunction> { ExtraDamage, NextAttackFrame }, Microsoft.Xna.Framework.Input.Keys.E, BASE_ALLY_TIMER); }
public override void AssignValues(List <ActionParameter> parameters) { if (isPlayer) { runtimeChar = AssignPlayer(playerID, parameters, parameterID); } else { runtimeChar = AssignFile <Char> (parameters, parameterID, constantID, _char); } sortingOrder = AssignInteger(parameters, sortingOrderParameterID, sortingOrder); sortingLayer = AssignString(parameters, sortingLayerParameterID, sortingLayer); runtimeSortingMap = AssignFile <SortingMap> (parameters, sortingMapParameterID, sortingMapConstantID, sortingMap); scale = AssignInteger(parameters, scaleParameterID, scale); if (directionParameterID >= 0) { int _directionInt = AssignInteger(parameters, directionParameterID, 0); direction = (CharDirection)_directionInt; } }
public int DirectionToInt(CharDirection charDirection) { if (charDirection == CharDirection.Down) { return(0); } if (charDirection == CharDirection.Left) { return(1); } if (charDirection == CharDirection.Right) { return(2); } if (charDirection == CharDirection.Up) { return(3); } if (charDirection == CharDirection.DownLeft) { return(4); } if (charDirection == CharDirection.DownRight) { return(5); } if (charDirection == CharDirection.UpLeft) { return(6); } if (charDirection == CharDirection.UpRight) { return(7); } return(0); }
//All Keyboard input will be processed here public void CheckKeyBoardInput() { IDOWN = false; //End Game Case if (checKeyBoardState.IsKeyDown(Keys.Escape)) { gameObj.Exit(); } else if (checKeyBoardState.IsKeyDown(Keys.B) && ACTIVELEVEL == 6 && burstRemaining >= 0) { //gameObj.BurstSound.Play(); burstExhausted += 1; if (characterFacing == CharDirection.Right) { gameObj.PlayerClass.UpdateRight(gameTime); velocity.X = (float)(gameTime.ElapsedGameTime.TotalMilliseconds / 5) * 3; } if (characterFacing == CharDirection.Left) { gameObj.PlayerClass.UpdateLeft(gameTime); velocity.X = -(float)(gameTime.ElapsedGameTime.TotalMilliseconds / 5) * 3; } } //Right Movement Controlled By D else if (checKeyBoardState.IsKeyDown(Keys.D)) { gameObj.PlayerClass.UpdateRight(gameTime); characterFacing = CharDirection.Right; if (ACTIVELEVEL == 6 && activePlayer == ActivePlayerz.Miner) { velocity.X = (float)((gameTime.ElapsedGameTime.TotalMilliseconds / 5) * 1.25); } else { velocity.X = (float)((gameTime.ElapsedGameTime.TotalMilliseconds / 5)); } } //Left Movement Controlled by A else if (checKeyBoardState.IsKeyDown(Keys.A)) { gameObj.PlayerClass.UpdateLeft(gameTime); characterFacing = CharDirection.Left; if (ACTIVELEVEL == 6 && activePlayer == ActivePlayerz.Miner) { velocity.X = -(float)((gameTime.ElapsedGameTime.TotalMilliseconds / 5) * 1.25); } else { velocity.X = -(float)((gameTime.ElapsedGameTime.TotalMilliseconds / 5)); } } else { if (jumpState == false && ladderCollision(new Rectangle((int)(gameObj.currPlayerPositionFunc.X + velocity.X), (int)(gameObj.currPlayerPositionFunc.Y + velocity.Y - yOffset), 40, 40))) { gameObj.PlayerClass.UpdateClimb(gameTime); } else if (jumpState == false) { if (characterFacing == CharDirection.Right) { gameObj.PlayerClass.UpdateStand(1); } else { gameObj.PlayerClass.UpdateStand(-1); } } velocity.X = 0f; } if (checKeyBoardState.IsKeyDown(Keys.W)) { if (ladderCollision(new Rectangle((int)(gameObj.currPlayerPositionFunc.X + velocity.X), (int)(gameObj.currPlayerPositionFunc.Y + velocity.Y - yOffset), 40, 40))) { gameObj.PlayerClass.UpdateClimb(gameTime); characterFacing = CharDirection.Up; velocity.Y = -1; gameObj.currPlayerPositionFunc.Y += (int)velocity.Y; climbState = true; } } climbState = false; //Checks for jump keypress Jump(); if (checKeyBoardState.IsKeyDown(Keys.I) && HASBAG == true) { if (IDOWN) { IDOWN = false; } else { IDOWN = true; } } if(checKeyBoardState.IsKeyDown(Keys.S)) { switch (playerInteractionDetection()) { case 0: { break; } //Swap to Eng case 1: { if (activePlayer == ActivePlayerz.Miner) { gameObj.PlayerClassMiner.PlayerLocation = new Vector2(gameObj.PlayerClass.PlayerLocation.X, gameObj.PlayerClass.PlayerLocation.Y - 80); gameObj.PlayerClassMiner.ACTIVELVL = ACTIVELEVEL; gameObj.PlayerClassMiner.SwapAble = false; } else if (activePlayer == ActivePlayerz.Foreman) { gameObj.PlayerClassFore.PlayerLocation = new Vector2(gameObj.PlayerClass.PlayerLocation.X, gameObj.PlayerClass.PlayerLocation.Y - 80); gameObj.PlayerClassFore.ACTIVELVL = ACTIVELEVEL; gameObj.PlayerClassFore.SwapAble = false; } gameObj.PlayerClass = gameObj.PlayerClassEng; gameObj.PlayerClass.SwapAble = false; activePlayer = ActivePlayerz.Engineer; break; } //Swap to foreman case 2: { if (activePlayer == ActivePlayerz.Miner) { gameObj.PlayerClassMiner.PlayerLocation = new Vector2(gameObj.PlayerClass.PlayerLocation.X, gameObj.PlayerClass.PlayerLocation.Y - 80); gameObj.PlayerClassMiner.ACTIVELVL = ACTIVELEVEL; gameObj.PlayerClassMiner.SwapAble = false; } else if (activePlayer == ActivePlayerz.Engineer) { gameObj.PlayerClassEng.PlayerLocation = new Vector2(gameObj.PlayerClass.PlayerLocation.X, gameObj.PlayerClass.PlayerLocation.Y - 80); gameObj.PlayerClassEng.ACTIVELVL = ACTIVELEVEL; gameObj.PlayerClassEng.SwapAble = false; } gameObj.PlayerClass = gameObj.PlayerClassFore; gameObj.PlayerClass.SwapAble = false; activePlayer = ActivePlayerz.Foreman; break; } //Swap to miner case 3: { if (activePlayer == ActivePlayerz.Engineer) { gameObj.PlayerClassEng.PlayerLocation = new Vector2(gameObj.PlayerClass.PlayerLocation.X, gameObj.PlayerClass.PlayerLocation.Y - 80); gameObj.PlayerClassEng.ACTIVELVL = ACTIVELEVEL; gameObj.PlayerClassEng.SwapAble = false; } else if (activePlayer == ActivePlayerz.Foreman) { gameObj.PlayerClassFore.PlayerLocation = new Vector2(gameObj.PlayerClass.PlayerLocation.X, gameObj.PlayerClass.PlayerLocation.Y - 80); gameObj.PlayerClassFore.ACTIVELVL = ACTIVELEVEL; gameObj.PlayerClassFore.SwapAble = false; } gameObj.PlayerClass = gameObj.PlayerClassMiner; gameObj.PlayerClass.SwapAble = false; activePlayer = ActivePlayerz.Miner; break; } } } //Check if we have the mining age euipt if (checKeyBoardState.IsKeyDown(Keys.T) && gameObj.checkInventoryItem(0) && ACTIVELEVEL == 1) { if (TDOWN) { TDOWN = false; } else { TDOWN = true; } //gameObj.Pickaxe.Play(); throwItem(); } //Remove item from character and return to inventory bag if (checKeyBoardState.IsKeyDown(Keys.U)) { unequiptItem(); } if (checKeyBoardState.IsKeyDown(Keys.R)) { if (ACTIVELEVEL < 6) { restartLevel(); } } //M is for minigame interaction elements if (checKeyBoardState.IsKeyDown(Keys.M) && interactiveDetection(gameObj.PlayerBox) && ACTIVELEVEL == 2) { CraneGameSimulation(); } //Checks for item key presses, these equipt items in inventory if applicable. checkItemUse(); GUIINVUpdate(); if (ACTIVELEVEL == 6) { burstRemaining -= burstExhausted; burstExhausted = 0; } //Check if we need to load a lower level if (gameObj.currPlayerPositionFunc.X <= 0 && ACTIVELEVEL > -1 && ACTIVELEVEL < 6) { if (ACTIVELEVEL != 0) { ACTIVELEVEL -= 1; loadLevel(-1); } } if(gameObj.currPlayerPositionFunc.X <= 0) { gameObj.currPlayerPositionFunc.X = 0; } //Check if we need to load a higher level if (gameObj.currPlayerPositionFunc.X >= graphics.PreferredBackBufferWidth && ACTIVELEVEL > -1 && ACTIVELEVEL < 6) { if (ACTIVELEVEL != 4) { ACTIVELEVEL += 1; loadLevel(1); } } if (gameObj.currPlayerPositionFunc.X >= graphics.PreferredBackBufferWidth) { gameObj.currPlayerPositionFunc.X = graphics.PreferredBackBufferWidth; } //Flash light not accessible until after this stage. if (eventStates[2]) { checkFlashLight(); } }
/** * <summary>Creates a new instance of the 'Character: Render' Action, set to update a sprite-based character</summary> * <param name = "characterToAffect">The character to affect</param> * <param name = "sortingLock">Whether or not to lock the character's sorting</param> * <param name = "newSortingLayer">The new sorting layer, if locking the character's sorting</param> * <param name = "scaleLock">Whether of not to lock the character's scale</param> * <param name = "newScale">The new scale, as a percentage, if locking the character's scale</param> * <param name = "directionLock">Whether or not to lock the character's facing direction</parm> * <param name = "newDirection">The new direction, if locking the character's facing direction</param> * <param name = "sortingMapLock">Whether or not to lock the character's current SortingMap</parm> * <param name = "newSortingMap">The new SortingMap, if locking the character's facing direction</param> * <returns>The generated Action</returns> */ public static ActionCharRender CreateNew_Sprites(AC.Char characterToAffect, RenderLock sortingLock, string newSortingLayer, RenderLock scaleLock, int newScale, RenderLock directionLock, CharDirection newDirection, RenderLock sortingMapLock, SortingMap newSortingMap) { ActionCharRender newAction = (ActionCharRender)CreateInstance <ActionCharRender>(); newAction._char = characterToAffect; newAction.renderLock_sorting = sortingLock; newAction.mapType = SortingMapType.SortingLayer; newAction.sortingLayer = newSortingLayer; newAction.renderLock_scale = scaleLock; newAction.scale = newScale; newAction.renderLock_direction = directionLock; newAction.direction = newDirection; newAction.renderLock_sortingMap = sortingMapLock; newAction.sortingMap = newSortingMap; return(newAction); }
// Constructor /// <summary> /// A Character object /// </summary> /// <param name="spriteSheet">All sprites for this Character in a single /// image. Must have (an) idle, walking, and attack frame(s).</param> /// <param name="location">The base location of this Character in the /// overworld, regardless of sprite sheet size.</param> /// <param name="health">The maximum health value for this Character /// </param> /// <param name="speed">The value used to determine the chronological /// order of attack during battles. Lower numbers have higher priority. /// </param> /// <param name="timePerFrame">The time that a frame of animation draws /// for before advancing to the next frame</param> /// <param name="healthBarBackground">The background texture of the /// health bar texture for this Character</param> /// <param name="healthBarForeground">The foreground texture of the /// health bar texture for this Character (the overlay)</param> /// <param name="healthFont">The font of the text in the health bar /// </param> /// <param name="state">The current CharacterState of this Character /// when it's initiated</param> /// <param name="direction">Whether this Character should be /// instantiated facing right or left</param> /// <param name="sourceFrames">A collection of Rectangles to use as /// frames for drawing</param> public Character(Texture2D spriteSheet, Vector2 location, int health, int speed, double timePerFrame, Texture2D healthBarBackground, Texture2D healthBarForeground, SpriteFont healthFont, CharacterState state = CharacterState.o_idle, CharDirection direction = CharDirection.right, List <Rectangle> sourceFrames = null) { this.spriteSheet = spriteSheet; color = Color.White; currentFrame = 0; frameCycleIndex = 0; damageCycleIndex = 0; this.timePerFrame = timePerFrame; baseTimePerFrame = timePerFrame; timeCounter = 0; totalTime = 0; quickTimeTimer = int.MaxValue; quickEventLocked = false; State = state; Direction = direction; int o_width = 50, o_height = 50; if (sourceFrames != null) { frames = new Dictionary <int, Rectangle>(sourceFrames.Count); foreach (Rectangle rect in sourceFrames) { frames.Add(frames.Count, rect); } } else { frames = new Dictionary <int, Rectangle>(); frames.Add(0, new Rectangle(0, 0, spriteSheet.Width, spriteSheet.Height)); o_width = (int)(frames[IDLE_FRAME].Width * ((double)50 / frames[IDLE_FRAME].Width)); o_height = (int)(frames[IDLE_FRAME].Height * ((double)50 / frames[IDLE_FRAME].Height)); } o_position = new Rectangle( (int)location.X, (int)location.Y, o_width, o_height); b_position = new Rectangle( (int)location.X, (int)location.Y, frames[IDLE_FRAME].Width, frames[IDLE_FRAME].Height); o_location = new Vector2(o_position.Location.X, o_position.Location.Y); b_location = new Vector2(b_position.Location.X, b_position.Location.Y); o_posX = location.X; o_posY = location.Y; b_posX = location.X; b_posY = location.Y; healthMax = health; this.health = healthMax; damage = 1; this.speed = speed; healthBar = new StatusBar( healthBarBackground, healthBarForeground, new Rectangle( b_position.X - b_position.Width / 2 - 52, b_position.Y + b_position.Height + 10, 104, 13), new Rectangle( 2, 2, 100, 9), healthFont, healthMax); }
public void SetSpriteDirection(CharDirection direction) { if (direction == CharDirection.Down) { spriteDirection = "D"; } else if (direction == CharDirection.Left) { spriteDirection = "L"; } else if (direction == CharDirection.Right) { spriteDirection = "R"; } else if (direction == CharDirection.Up) { spriteDirection = "U"; } else if (direction == CharDirection.DownLeft) { spriteDirection = "DL"; } else if (direction == CharDirection.DownRight) { spriteDirection = "DR"; } else if (direction == CharDirection.UpLeft) { spriteDirection = "UL"; } else if (direction == CharDirection.UpRight) { spriteDirection = "UR"; } }
override public void ShowGUI(List <ActionParameter> parameters) { isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer); if (isPlayer) { if (Application.isPlaying) { animChar = KickStarter.player; } else { animChar = AdvGame.GetReferences().settingsManager.GetDefaultPlayer(); } } else { parameterID = Action.ChooseParameterGUI("Character:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; animChar = null; } else { animChar = (Char)EditorGUILayout.ObjectField("Character:", animChar, typeof(Char), true); constantID = FieldToID <Char> (animChar, constantID); animChar = IDToField <Char> (animChar, constantID, true); } } if (animChar) { ResetAnimationEngine(animChar.animationEngine); } if (editingAnimEngine != null) { method = (ActionCharAnimSpine.AnimMethodChar)EditorGUILayout.EnumPopup("Method:", method); if (method == ActionCharAnimSpine.AnimMethodChar.PlayCustom) { clip2D = EditorGUILayout.TextField("Clip:", clip2D); layerInt = EditorGUILayout.IntField("Layer:", layerInt); timeScale = EditorGUILayout.FloatField("Timescale:", timeScale); atTime = EditorGUILayout.FloatField("At time:", atTime); forceDirection = EditorGUILayout.Toggle("Force direction?", forceDirection); if (forceDirection) { newDirection = (CharDirection)EditorGUILayout.EnumPopup("Direction:", newDirection); } loop = EditorGUILayout.Toggle("Loop?", loop); if (loop) { loopTimes = EditorGUILayout.IntField("Looping times:", loopTimes); } willWait = EditorGUILayout.Toggle("Wait until finish?", willWait); if (willWait) { idleAfter = EditorGUILayout.Toggle("Return to idle after?", idleAfter); if (idleAfter) { willTransform = EditorGUILayout.Toggle("Reposition before idle?", willTransform); if (willTransform) { transformOffset = EditorGUILayout.Vector3Field("Point:", transformOffset); } } } } else if (method == ActionCharAnimSpine.AnimMethodChar.SetStandard) { clip2D = EditorGUILayout.TextField("Clip:", clip2D); standard = (AnimStandard)EditorGUILayout.EnumPopup("Change:", standard); if (standard == AnimStandard.Walk || standard == AnimStandard.Run) { changeSound = EditorGUILayout.Toggle("Change sound?", changeSound); if (changeSound) { newSoundParameterID = Action.ChooseParameterGUI("New sound:", parameters, newSoundParameterID, ParameterType.UnityObject); if (newSoundParameterID < 0) { newSound = (AudioClip)EditorGUILayout.ObjectField("New sound:", newSound, typeof(AudioClip), false); } } changeSpeed = EditorGUILayout.Toggle("Change speed?", changeSpeed); if (changeSpeed) { newSpeed = EditorGUILayout.FloatField("New speed:", newSpeed); } } } else if (method == ActionCharAnimSpine.AnimMethodChar.ResetToIdle) { idleAfterCustom = EditorGUILayout.Toggle("Wait for animation to finish?", idleAfterCustom); } if (GUI.changed) { EditorUtility.SetDirty(this); } } else { EditorGUILayout.HelpBox("This Action requires a Character before more options will show.", MessageType.Info); } AfterRunningOption(); }
public Character(Map map, Controls controls, int currentTile, string sprite, Game game, List<Character> characterList) : base(game) { this.characterList = characterList; this.map = map; this.controls = controls; this.parent = game; this.currentTile = currentTile; this.sprite = sprite; this.direction = CharDirection.Down; this.charSpawnLocation = currentTile; this.x = ((currentTile % this.map.MapSize.Width) - 1) * this.map.SpriteSize.Width; this.y = (float)Math.Floor((decimal)(currentTile / this.map.MapSize.Width)) * this.map.SpriteSize.Height; this.baseX = this.x; this.baseY = this.y; }
//TODO Determine all parameters needed to spawn a physics class with functionality. public Physics(Game1 gameObj, int characterNum, SpriteBatch sprites, GraphicsDeviceManager graphics) { characterFacing = CharDirection.Right; activePlayer = ActivePlayerz.Miner; ACTIVELEVEL = 1; this.gameObj = gameObj; this.characterNum = characterNum; this.sprites = sprites; this.graphics = graphics; eventStates = new bool[5]; healthRemaining = 200; pathHighlight = Texture2D.FromStream(gameObj.GraphicsDevice, TitleContainer.OpenStream(@"Images/GUIImages/Path.png")); resList = new List<double>(); resList.Add(0.0); resList.Add(0.0); resList.Add(0.0); }
public override void ShowGUI(List<ActionParameter> parameters) { isPlayer = EditorGUILayout.Toggle ("Affect Player?", isPlayer); if (!isPlayer) { charToMoveParameterID = Action.ChooseParameterGUI ("Character to turn:", parameters, charToMoveParameterID, ParameterType.GameObject); if (charToMoveParameterID >= 0) { charToMoveID = 0; charToMove = null; } else { charToMove = (Char) EditorGUILayout.ObjectField ("Character to turn:", charToMove, typeof(Char), true); charToMoveID = FieldToID <Char> (charToMove, charToMoveID); charToMove = IDToField <Char> (charToMove, charToMoveID, false); } } direction = (CharDirection) EditorGUILayout.EnumPopup ("Direction to face:", direction); isInstant = EditorGUILayout.Toggle ("Is instant?", isInstant); if (!isInstant) { willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait); } AfterRunningOption (); }
public override void Update(GameTime gameTime) { if (this.charLives == 0) { this.Game.Components.Remove(this); } if (this.spawnTime > 0) { this.spawnTime += gameTime.ElapsedGameTime.Milliseconds; if (this.spawnTime > 2000 && this.spawnTime <= 4500) { if (!this.reset) { this.alpha = 125; this.currentTile = this.charSpawnLocation; this.x = this.baseX; this.y = this.baseY; this.reset = true; } } else if (this.spawnTime > 4500) { this.alpha = 255; this.isBombDown = false; this.spawnTime = 0; } } this.gameCount += gameTime.ElapsedGameTime.Milliseconds; this.bombDown += gameTime.ElapsedGameTime.Milliseconds; if (!this.moving) { KeyboardState kb = Keyboard.GetState(); if (this.bombDown >= 2800) { this.isBombDown = false; this.bombDown = 0; } if (kb.IsKeyDown(controls.Drop) && !this.isBombDown) { this.bomb = new Bomb(this.parent, this.currentTile, this.map, this.characterList); this.parent.Components.Add(this.bomb); this.isBombDown = true; } if (kb.IsKeyDown(controls.Up) && !kb.IsKeyDown(controls.Down)) { this.moving = true; this.direction = CharDirection.Up; } else if (kb.IsKeyDown(controls.Down) && !kb.IsKeyDown(controls.Up)) { this.moving = true; this.direction = CharDirection.Down; } else if (kb.IsKeyDown(controls.Left) && !kb.IsKeyDown(controls.Right)) { this.moving = true; this.direction = CharDirection.Left; } else if (kb.IsKeyDown(controls.Right) && !kb.IsKeyDown(controls.Left)) { this.moving = true; this.direction = CharDirection.Right; } if (this.moving) { switch (this.direction) { case CharDirection.Up: if (!this.map.CanWalk(this.currentTile - this.map.MapSize.Width)) { this.moving = false; } else { currentTile -= this.map.MapSize.Width; } break; case CharDirection.Down: if (!this.map.CanWalk(this.currentTile + this.map.MapSize.Width)) { this.moving = false; } else { currentTile += this.map.MapSize.Width; } break; case CharDirection.Left: if (!this.map.CanWalk(this.currentTile - 1)) { this.moving = false; } else { currentTile -= 1; } break; case CharDirection.Right: if (!this.map.CanWalk(this.currentTile + 1)) { this.moving = false; } else { currentTile += 1; } break; case CharDirection.Drop: break; default: break; } } } else { if (this.gameCount > charCount) { this.steps++; if (this.direction == CharDirection.Up) { this.y -= 4f; } else if (this.direction == CharDirection.Down) { this.y += 4f; } else if (this.direction == CharDirection.Right) { this.x += 4f; } else if (this.direction == CharDirection.Left) { this.x -= 4f; } this.gameCount = 0; if (this.steps >= 11) { this.moving = false; this.steps = 0; } } } base.Update(gameTime); }