//handles the player crouching and informs the shadows to do the same void Crouch() { // print("Crouch Called"); eFacing = Facings.Crouch; goCharacter.animation.Play("Duck"); SendShadowMessage("ChangeFacing", 3); }
//determines multiplier for angle based scoring int MultiplierForAngle(Unit caster, Tile tile) { if (tile.content == null) { return(0); } Unit defender = tile.content.GetComponentInChildren <Unit>(); if (defender == null) { return(0); } //higher score for hitting back and sides Facings facing = caster.GetFacing(defender); if (facing == Facings.Back) { return(90); } if (facing == Facings.Side) { return(75); } return(50); }
private int MultiplierForAngle(Unit caster, Tile tile) { if (tile.content == null) { return(0); } Unit defender = tile.content.GetComponentInChildren <Unit>(); if (defender == null) { return(0); } Facings facing = caster.GetFacing(defender); if (facing == Facings.Back) { return(90); } if (facing == Facings.Side) { return(75); } return(50); }
public BoxMesh(Vector3 min, Vector3 max, Facings facings, bool boxMap) { Min = min; Max = max; Facings = facings; BoxMap = boxMap; }
public void Read(BinaryReader reader, int version) { IsValid = true; InControl = reader.ReadBoolean(); Position = new Vector2(reader.ReadSingle(), reader.ReadSingle()); Speed = new Vector2(reader.ReadSingle(), reader.ReadSingle()); Rotation = reader.ReadSingle(); Scale = new Vector2(reader.ReadSingle(), reader.ReadSingle()); Color = new Color(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte()); SpriteRate = reader.ReadSingle(); SpriteJustify = reader.ReadBoolean() ? (Vector2?)new Vector2(reader.ReadSingle(), reader.ReadSingle()) : null; Facing = (Facings)reader.ReadInt32(); CurrentAnimationID = reader.ReadNullTerminatedString(); CurrentAnimationFrame = reader.ReadInt32(); HairColor = new Color(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte()); HairSimulateMotion = reader.ReadBoolean(); if (version < 2) { return; } DashColor = reader.ReadBoolean() ? (Color?)new Color(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte()) : null; DashDir = new Vector2(reader.ReadSingle(), reader.ReadSingle()); DashWasB = reader.ReadBoolean(); }
//handles if the player needs to change facing and moving right void MoveRight() { if (fYAxis != -1) { if (!goCharacter.animation.IsPlaying("Jump") && !goCharacter.animation.IsPlaying("Fall")) { goCharacter.animation.Play("Walk"); } if (!bGoingRight) { transform.eulerAngles = new Vector3(0, 0, 0); bGoingRight = true; eFacing = Facings.Right; } if (!bAttacking || !bGrounded) { RaycastHit hit; if (Physics.Raycast(transform.position, transform.right, out hit, fWidth, lmGroundLayer.value)) { if (hit.collider.tag != "Wall") { transform.Translate(transform.right * fMoveSpeed * Time.deltaTime, Space.World); } } else { transform.Translate(transform.right * fMoveSpeed * Time.deltaTime, Space.World); } bMoved = true; } } SendShadowMessage("ChangeFacing", 0); //consider taking it out of if statement same in move left }
public override void Awake(Scene scene) { base.Awake(scene); if (bounce == Vector2.Zero) { return; } if (Math.Abs(bounce.X) > Math.Abs(bounce.Y)) { sprite.Play("deadside"); facing = (Facings)(-Math.Sign(bounce.X)); return; } bounce = Calc.AngleToVector(Calc.AngleApproach(bounce.Angle(), new Vector2(0 - player.Facing, 0f).Angle(), 0.5f), 1f); if (bounce.Y < 0f) { sprite.Play("deadup"); } else { sprite.Play("deaddown"); } }
public Option(string key) { this.Key = key; this.Tag = (int)Tags.HUD; int maxLineWidth = 1828; this.Text = FancyText.Parse(Dialog.Get(this.Key), maxLineWidth, -1); foreach (FancyText.Node node in this.Text.Nodes) { if (!(node is FancyText.Portrait portrait)) { continue; } this.Portrait = GFX.PortraitsSpriteBank.Create(portrait.SpriteId); this.Portrait.Play(portrait.IdleAnimation); this.PortraitSide = (Facings)portrait.Side; this.Textbox = "textbox/" + portrait.Sprite + "_ask"; XmlElement xml = GFX.PortraitsSpriteBank.SpriteData[portrait.SpriteId].Sources[0].XML; if (xml != null) { this.PortraitSize = xml.AttrInt("size", 160); } break; } }
public override void Render() { if (this.Scene is Level level && level.Paused) { return; } float introEase = Monocle.Ease.CubeOut(this.Ease); float highlightEase = Monocle.Ease.CubeInOut(this.Highlight); var position = this.Position; position.Y += (float)(-32.0 * (1.0 - introEase)); position.X += highlightEase * 32f; Color color1 = Color.Lerp(Color.Gray, Color.White, highlightEase) * introEase; float alpha = MathHelper.Lerp(0.6f, 1f, highlightEase) * introEase; GFX.Portraits[this.Textbox].Draw(position, Vector2.Zero, color1); Facings facings = this.PortraitSide; if (SaveData.Instance != null && SaveData.Instance.Assists.MirrorMode) { facings = (Facings)(-(int)facings); } float num2 = 100f; this.Portrait.Scale = Vector2.One * (num2 / this.PortraitSize); if (facings == Facings.Right) { this.Portrait.Position = position + new Vector2((float)(1380.0 - num2 * 0.5), 70f); this.Portrait.Scale.X *= -1f; } else { this.Portrait.Position = position + new Vector2((float)(20.0 + num2 * 0.5), 70f); } this.Portrait.Color = Color.White * (float)(0.5 + highlightEase * 0.5) * introEase; this.Portrait.Render(); float num3 = (float)((140.0 - ActiveFont.LineHeight * 0.699999988079071) / 2.0); Vector2 position1 = new Vector2(0.0f, position.Y + 70f); Vector2 justify = new Vector2(0.0f, 0.5f); if (facings == Facings.Right) { justify.X = 1f; position1.X = (float)(position.X + 1400.0 - 20.0) - num3 - num2; } else { position1.X = position.X + 20f + num3 + num2; } this.Text.Draw(position1, justify, Vector2.One * 0.7f, alpha); }
public static void InstantTeleport(Scene scene, Player player, string room, bool sameRelativePosition, float positionX, float positionY) { Level level = scene as Level; if (level == null) { return; } if (String.IsNullOrEmpty(room)) { Vector2 playerRelativeOffset = (new Vector2(positionX, positionY) - player.Position); player.Position = new Vector2(positionX, positionY); level.Camera.Position += playerRelativeOffset; player.Hair.MoveHairBy(playerRelativeOffset); } else { level.OnEndOfFrame += delegate { Vector2 levelOffset = level.LevelOffset; Vector2 playerOffset = player.Position - level.LevelOffset; Vector2 cameraOffset = level.Camera.Position - level.LevelOffset; Facings facing = player.Facing; level.Remove(player); level.UnloadLevel(); level.Session.Level = room; level.Session.RespawnPoint = level.GetSpawnPoint(new Vector2(level.Bounds.Left, level.Bounds.Top)); level.Session.FirstLevel = false; level.LoadLevel(Player.IntroTypes.Transition); if (sameRelativePosition) { level.Camera.Position = level.LevelOffset + cameraOffset; level.Add(player); player.Position = level.LevelOffset + playerOffset; player.Facing = facing; player.Hair.MoveHairBy(level.LevelOffset - levelOffset); } else { Vector2 playerRelativeOffset = (new Vector2(positionX, positionY) - level.LevelOffset - playerOffset); level.Camera.Position = level.LevelOffset + cameraOffset + playerRelativeOffset; level.Add(player); player.Position = new Vector2(positionX, positionY); player.Facing = facing; player.Hair.MoveHairBy(level.LevelOffset - levelOffset + playerRelativeOffset); } if (level.Wipe != null) { level.Wipe.Cancel(); } }; } }
//public PlayerHair Hair; //public PlayerSprite Sprite; public RewindStateInfo(Vector2 pos, Facings dir, int dashes, string animation, int animframe)//,PlayerHair hair, PlayerSprite sprite) { Position = pos; Facing = dir; Dashes = dashes; Animation = animation; Animframe = animframe; }
void Update() { if (!goCharacter.animation.IsPlaying("Idle")) { if (bGrounded && fXAxis != 1 && fXAxis != 1 && fYAxis != 1 && fYAxis != -1) { eFacing = Facings.Idle; goCharacter.animation.Play("Idle"); SendShadowMessage("ChangeFacing", 4); } } if (fAttackPauseTime > 0.0f) { fAttackPauseTime -= Time.deltaTime; if (fAttackPauseTime <= 0.0f) { bAttacking = false; } } if (fCurRopeScaleTime < fMaxRopeScaleTime) { fCurRopeScaleTime += Time.deltaTime; goRopeAttackBox.transform.localScale = new Vector3(fOriginalRopeXScale * fCurRopeScaleTime / fMaxRopeScaleTime, 1, 1); if (fCurRopeScaleTime > fMaxRopeScaleTime) { goRopeAttackBox.transform.localScale = new Vector3(fOriginalRopeXScale, 1, 1); } } //if currently attacking resolve it if (fCurAttackTime > 0) { if (bRopeAttack && fCurRopeScaleTime >= fMaxRopeScaleTime) { RopeHandler(); fCurAttackTime -= Time.deltaTime; } else if (bSwordAttack) { fCurAttackTime -= Time.deltaTime; } else if (bRangedAttack) { fCurAttackTime -= Time.deltaTime; } else { fCurAttackTime -= Time.deltaTime; } if (fCurAttackTime <= 0) { goRopeAttackBox.SetActive(false); } } }
void Normal_Update() { if (CollisionSelf(PitLayer)) { fsm.ChangeState(States.FallInPit, StateTransition.Overwrite); } if (CanRoll) { fsm.ChangeState(States.Roll, StateTransition.Overwrite); return; } // Movement Vector2 value = new Vector2(moveX, moveY); value.Normalize(); Speed.x = Calc.Approach(Speed.x, value.x * MaxRun, RunAccel * Time.deltaTime); Speed.y = Calc.Approach(Speed.y, value.y * MaxRun, RunAccel * Time.deltaTime); // Aiming var mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); //float angle = Mathf.Atan2(mousePos.y, mousePos.x) * Mathf.Rad2Deg; float angle = Mathf.Atan2(mousePos.y - transform.position.y, mousePos.x - transform.position.x) * 180 / Mathf.PI; var vectorMouse = new Vector2(mousePos.x - transform.position.x, mousePos.y - transform.position.y).normalized; if (PixelCameraFollower.instance != null) { PixelCameraFollower.instance.m_OffsetDir = vectorMouse; } if (angle < 0) { angle += 360f; } if (angle > 270 || angle < 90) { Facing = Facings.Right; } else { Facing = Facings.Left; } if (weapon != null) { weapon.SetRotation(angle); } // Weapon if ((input.GetButtonDown(playerNumber, InputAction.Fire) || input.GetButton(playerNumber, InputAction.Fire)) && weapon != null) { weapon.TryToTriggerWeapon(); } }
private void DoTurn() { int index = (int)this.facing; this.animators[index].gameObject.SetActive(false); index = (index + 1) % 4; this.animators[index].gameObject.SetActive(true); this.facing = (Facings)index; this.transform.Rotate(this.transform.up, 90f); }
static int HitRateForAType(Effect effect, Unit attacker, Unit defender) { int retValue; // Step 1. Automatic Hit Conditions - CAN YOU GUARANTEE A HIT? if (ReturnEvent <bool>(effect, attacker, defender, automaticHitCheckEvent, false)) { retValue = 100; goto Step8; } // Step 2. Reaction Check - CAN YOU GUARANTEE A MISS? if (ReturnEvent <bool>(effect, attacker, defender, automaticMissCheckEvent, false)) { retValue = 0; goto Step9; } // Step 3. Retrieve Target's Evade stat - GET BASE EVADE STAT (FROM JOB & EQUIPMENT) int defenderEvade = defender.ModifiedStat(Stats.Evd); // Step 4. Work out Relative Facing - MODIFY EVADE STAT DUE TO ANGLE OF ATTACK Facings f = attacker.AngleOfAttack(defender); if (f == Facings.Side) { defenderEvade /= 2; } else if (f == Facings.Back) { defenderEvade /= 4; } // Step 5. Status Check - MODIFY EVADE DUE TO STATUS BOOSTS AND AILMENTS defenderEvade += ReturnEvent <int>(effect, attacker, defender, boostCheckEvent, 0); // Step 6. Cap Evade - CAP VALUE TO LEGAL RANGE defenderEvade = Mathf.Clamp(defenderEvade, 5, 95); // Step 7. Work out Hit Rate based on Evade retValue = 100 - defenderEvade; // Step 8. Final Checks Step8: retValue = Mathf.FloorToInt(retValue * ReturnEvent <float>(effect, attacker, defender, finalCheckEvent, 1)); Step9: return(retValue); }
static int HitRateForSType(Effect effect, Unit attacker, Unit defender) { int retValue; // Step 1. Automatic Miss Conditions - IS TARGET IMMUNE? if (ReturnEvent <bool>(effect, attacker, defender, immunityCheckEvent, false)) { retValue = 0; goto Step9; } // Step 2. Automatic Hit Conditions - CAN YOU GUARANTEE A HIT? if (ReturnEvent <bool>(effect, attacker, defender, vulnerabilityCheckEvent, false)) { retValue = 100; goto Step8; } // Step 3. Retrieve Target's Evade stat - GET BASE EVADE STAT (FROM JOB & EQUIPMENT) int defenderResistance = defender.ModifiedStat(Stats.SRes); // Step 4. Status Check - MODIFY EVADE DUE TO STATUS BOOSTS AND AILMENTS defenderResistance += ReturnEvent <int>(effect, attacker, defender, boostCheckEvent, 0); // Step 5. Work out Relative Facing - MODIFY RESISTANCE STAT DUE TO ANGLE OF ATTACK Facings f = attacker.AngleOfAttack(defender); if (f == Facings.Side) { defenderResistance -= 10; } else if (f == Facings.Back) { defenderResistance -= 20; } // Step 6. Cap Resistance - CAP VALUE TO LEGAL RANGE defenderResistance = Mathf.Clamp(defenderResistance, 0, 100); // Step 7. Work out Hit Rate based on Resistance retValue = 100 - defenderResistance; // Step 8. Final Checks Step8: retValue = Mathf.FloorToInt(retValue * ReturnEvent <float>(effect, attacker, defender, finalCheckEvent, 1)); Step9: return(retValue); }
public static Direction FromVector2(Vector2 vector) { var direction = new Direction { Facing = Facings.None }; Facings directionIfHorizontal = vector.x < 0 ? Facings.Left : Facings.Right; Facings directionIfVertical = vector.y > 0 ? Facings.Back : Facings.Front; bool shouldBeHorizontal = vector.x != 0 && Math.Abs(vector.x) >= Math.Abs(vector.y); direction.Facing = shouldBeHorizontal ? directionIfHorizontal : directionIfVertical; return(direction); }
private IEnumerator Roll_Enter() { if (weapon != null) { weapon.HideWeapon(); } rollCooldownTimer = RollCooldownTime; Speed = Vector2.zero; RollDir = Vector2.zero; Vector2 value = new Vector2(moveX, moveY); if (value == Vector2.zero) { value = new Vector2((int)Facing, 0f); } else if (value.x == 0 && value.y > 0 && onGround) { value = new Vector2((int)Facing, value.y); } value.Normalize(); Vector2 vector = value * RollSpeed; Speed = vector; RollDir = value; if (RollDir.x != 0f) { Facing = (Facings)Mathf.Sign(RollDir.x); } // Screenshake if (CameraShaker.instance != null) { CameraShaker.instance.InitShake(0.125f, 1f); } // Invincibility health.invincible = true; yield return(new WaitForSeconds(RollTime)); // Wait one extra frame yield return(null); fsm.ChangeState(States.Normal, StateTransition.Overwrite); yield break; }
private static void Player_Update(On.Celeste.Player.orig_Update orig, Player self) { DreamDashController controller = self.Scene.Tracker.GetEntity <DreamDashController>(); if (controller != null) { if (Input.Dash.Pressed && Input.Aim.Value != Vector2.Zero) { controller.dreamDashRedirect(self); } } Facings preOrigFacing = self.Facing; Vector2 preOrigScale = self.Sprite.Scale; orig(self); if (wallPlayerRotations.TryGetValue(self, out var rotationHolder)) { self.Facing = preOrigFacing; self.Sprite.Scale = preOrigScale; Vector2 inputAim = Input.Aim.Value; if (inputAim != Vector2.Zero) { float inputAngleOffset = (inputAim.Angle() - rotationHolder.value + MathHelper.TwoPi) % MathHelper.TwoPi; Facings newFacing = self.Facing; if (inputAngleOffset >= Math.PI * 0.75 && inputAngleOffset <= Math.PI * 1.25) { newFacing = Facings.Left; } else if (inputAngleOffset >= Math.PI * -0.25 && inputAngleOffset <= Math.PI * 0.25 || inputAngleOffset - MathHelper.TwoPi >= Math.PI * -0.25 && inputAngleOffset - MathHelper.TwoPi <= Math.PI * 0.25) { newFacing = Facings.Right; } if (self.Facing != newFacing) { self.Facing = newFacing; } } } }
public EndPoint(Player player) { Tag = Tags.Global; facing = player.Facing; Collidable = false; Collider = new Hitbox(8f, 11f, -4f, -11f); Position = player.Position; Depth = player.Depth + 1; Add(new PlayerCollider(OnCollidePlayer)); Add(new BloomPoint(Vector2.UnitY * -8, 0.5f, 18f)); Add(new VertexLight(Vector2.UnitY * -8, Color.White, 1f, 24, 48)); // saved madeline sprite CreateMadelineSprite(player); SetSprite(player); }
public EndPoint(Player player) { this.player = player; facing = player.Facing; LevelName = player.SceneAs <Level>().Session.Level; Collidable = false; Collider = new Hitbox(8f, 11f, -4f, -11f); Position = player.Position; Depth = player.Depth + 1; Add(new PlayerCollider(OnCollidePlayer)); Add(new BloomPoint(Vector2.UnitY * -8, 0.5f, 18f)); Add(new VertexLight(Vector2.UnitY * -8, Color.White, 1f, 24, 48)); // saved madeline sprite CreateMadelineSprite(); SetSprite(); }
//handles if the player needs to change facing and moving left void MoveLeft() { if (!(fYAxis < -.5f)) { if (!goCharacter.animation.IsPlaying("Jump") && !goCharacter.animation.IsPlaying("Fall")) { goCharacter.animation.Play("Walk"); } if (bGoingLeft) { transform.eulerAngles = new Vector3(0, 180, 0); bGoingLeft = false; eFacing = Facings.Left; } if (!bAttacking || !bGrounded) { RaycastHit hit; if (Physics.Raycast(transform.position, transform.right, out hit, fWidth, lmGroundLayer.value)) { //print (hit.collider.tag); if (hit.collider.tag != "Wall") { Vector3 test = transform.position + (transform.right * fMoveSpeed * Time.deltaTime); if (CheckCanMoveInDirection(test)) { transform.Translate(transform.right * fMoveSpeed * Time.deltaTime, Space.World); } } } else { Vector3 test = transform.position + (transform.right * fMoveSpeed * Time.deltaTime); if (CheckCanMoveInDirection(test)) { transform.Translate(transform.right * fMoveSpeed * Time.deltaTime, Space.World); } } bMoved = true; } } SendShadowMessage("ChangeFacing", 1); }
int AdjustForRelativeFacing(Unit attacker, Unit target, int rate) { Facings facing = attacker.GetFacings(target); switch (facing) { case Facings.Back: return(rate / 4); case Facings.Side_B: return(rate / 3); case Facings.Side_F: return(rate / 2); default: return(rate); } }
void ChangeFacing(int newFacing) { switch (newFacing) { case 0: eFacing = Facings.Right; vDirection = new Vector3(1.0f, 0, 0); break; case 1: eFacing = Facings.Left; vDirection = new Vector3(-1.0f, 0, 0); break; case 2: eFacing = Facings.Up; vDirection = new Vector3(0, 1.0f, 0); break; case 3: eFacing = Facings.Crouch; vDirection = new Vector3(0, -1.0f, 0); break; case 4: eFacing = Facings.Idle; if (transform.eulerAngles == new Vector3(0, 0, 0)) { vDirection = new Vector3(1.0f, 0, 0); } else { vDirection = new Vector3(-1.0f, 0, 0); } break; default: eFacing = Facings.Right; break; } }
public CustomPlayerDeadBody(Player player, Vector2 direction, bool endLevel = false, bool muted = true) { base.Depth = -1000000; this.player = player; this.endLevel = endLevel; this.muted = muted; facing = player.Facing; Position = player.Position; Add(hair = player.Hair); Add(sprite = player.Sprite); Add(light = player.Light); sprite.Color = Color.White; initialHairColor = hair.Color; bounce = direction; Add(new Coroutine(DeathRoutine())); }
public static Vector2 GetAimVector(Facings defaultFacing = Facings.Right) { Vector2 vector2 = Aim.Value; if (vector2 == Vector2.zero) { //if (SaveData.Instance != null && SaveData.Instance.Assists.DashAssist) // return Input.LastAim; LastAim = Vector2.right * (float)defaultFacing; } //else if (SaveData.Instance != null && SaveData.Instance.Assists.ThreeSixtyDashing) //{ // LastAim = vector2.normalized; //} else { float radiansA = vector2.Angle(); float num = (float)(0.392699092626572 - ((double)radiansA < 0.0 ? 1.0 : 0.0) * 0.0872664600610733); LastAim = (double)Util.AbsAngleDiff(radiansA, 0.0f) >= (double)num ? ((double)Util.AbsAngleDiff(radiansA, 3.141593f) >= (double)num ? ((double)Util.AbsAngleDiff(radiansA, -1.570796f) >= (double)num ? ((double)Util.AbsAngleDiff(radiansA, 1.570796f) >= (double)num ? new Vector2((float)Mathf.Sign(vector2.x), (float)Mathf.Sign(vector2.y)).normalized : new Vector2(0.0f, 1f)) : new Vector2(0.0f, -1f)) : new Vector2(-1f, 0.0f)) : new Vector2(1f, 0.0f); } return(LastAim); }
public override void OnEnter(Player player) { Level level = Engine.Scene as Level; level.OnEndOfFrame += delegate { new Vector2(level.LevelOffset.X + level.Bounds.Width - player.X, player.Y - level.LevelOffset.Y); Vector2 levelOffset = level.LevelOffset; Vector2 value = player.Position - level.LevelOffset; Vector2 value2 = level.Camera.Position - level.LevelOffset; Facings facing = player.Facing; level.Remove(player); level.UnloadLevel(); level.Session.Dreaming = true; level.Session.Level = destLevel; level.Session.RespawnPoint = level.GetSpawnPoint(new Vector2(level.Bounds.Left, level.Bounds.Top)); level.LoadLevel(Player.IntroTypes.Transition); level.Camera.Position = level.LevelOffset + value2; level.Session.Inventory.Dashes = 1; player.Dashes = Math.Min(player.Dashes, 1); level.Add(player); player.Position = level.LevelOffset + value; player.Facing = facing; player.Hair.MoveHairBy(level.LevelOffset - levelOffset); if (level.Wipe != null) { level.Wipe.Cancel(); } level.Flash(Color.White); level.Shake(); if (spawnThunder) { level.Add(new LightningStrike(new Vector2(player.X + 60f, level.Bounds.Bottom - 180), 10, 200f)); level.Add(new LightningStrike(new Vector2(player.X + 220f, level.Bounds.Bottom - 180), 40, 200f, 0.25f)); Audio.Play("event:/new_content/game/10_farewell/lightning_strike"); } }; }
public void ReadChunkData(BinaryReader reader) { HasData = true; InControl = reader.ReadBoolean(); Position = new Vector2(reader.ReadSingle(), reader.ReadSingle()); Speed = new Vector2(reader.ReadSingle(), reader.ReadSingle()); Rotation = reader.ReadSingle(); Scale = new Vector2(reader.ReadSingle(), reader.ReadSingle()); Color = new Color(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte()); SpriteRate = reader.ReadSingle(); SpriteJustify = reader.ReadBoolean() ? (Vector2?)new Vector2(reader.ReadSingle(), reader.ReadSingle()) : null; Facing = (Facings)reader.ReadInt32(); CurrentAnimationID = reader.ReadNullTerminatedString(); CurrentAnimationFrame = reader.ReadInt32(); HairColor = new Color(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte()); HairSimulateMotion = reader.ReadBoolean(); }
public void Update() { if (AutoFromVelocity) { var velocity = transform.position - m_LastPosition; if (velocity.x > MinAutoTurnVelocity) { Facing = Facings.Right; } else if (velocity.x < -MinAutoTurnVelocity) { Facing = Facings.Left; } } var scaleX = (Facing == Facings.Right) ? 1.0f : -1.0f; transform.localScale = new Vector3( scaleX, transform.localScale.y, transform.localScale.z ); m_LastPosition = transform.position; }
private void GrabLedge(int targetY, int direction) { // Set the facing direction Facing = (Facings)direction; // The collider's extents on the Y axis (half of height) var extentsY = myCollider.bounds.extents.y + 1; // Set the Y position to the desired one according to our collider's size and the targetY transform.position = new Vector2(transform.position.x, (float)(targetY - extentsY)); // Set the vertical speed to 0 Speed.y = 0f; // We check for collisions with the ledge on the set direction while (!CheckColAtPlace(Vector2.right * direction, solid_layer)) { transform.position = new Vector2(transform.position.x + direction, transform.position.y); } // Change the sprite scale to add extra feel SpriteScale = new Vector2(1.3f, 0.7f); // Change the state to the ledge grabbing state fsm.ChangeState(States.LedgeGrab, StateTransition.Overwrite); }
void ChangeFacing(int newFacing) { switch(newFacing) { case 0: eFacing = Facings.Right; vDirection = new Vector3(1.0f, 0, 0); break; case 1: eFacing = Facings.Left; vDirection = new Vector3(-1.0f, 0, 0); break; case 2: eFacing = Facings.Up; vDirection = new Vector3(0, 1.0f, 0); break; case 3: eFacing = Facings.Crouch; vDirection = new Vector3(0, -1.0f, 0); break; case 4: eFacing = Facings.Idle; if(transform.eulerAngles == new Vector3(0, 0, 0)) vDirection = new Vector3(1.0f, 0, 0); else vDirection = new Vector3(-1.0f, 0, 0); break; default: eFacing = Facings.Right; break; } }
//handles if the player needs to change facing and moving left void MoveLeft() { if(!(fYAxis < -.5f)) { if(!goCharacter.animation.IsPlaying("Jump") && !goCharacter.animation.IsPlaying("Fall")) goCharacter.animation.Play("Walk"); if(bGoingLeft) { transform.eulerAngles = new Vector3(0, 180, 0); bGoingLeft = false; eFacing = Facings.Left; } if(!bAttacking || !bGrounded) { RaycastHit hit; if(Physics.Raycast(transform.position, transform.right, out hit, fWidth, lmGroundLayer.value)) { //print (hit.collider.tag); if(hit.collider.tag != "Wall") { Vector3 test = transform.position + (transform.right * fMoveSpeed * Time.deltaTime ); if( CheckCanMoveInDirection( test ) ) transform.Translate(transform.right * fMoveSpeed * Time.deltaTime,Space.World); } } else { Vector3 test = transform.position + (transform.right * fMoveSpeed * Time.deltaTime ); if( CheckCanMoveInDirection( test ) ) transform.Translate(transform.right * fMoveSpeed * Time.deltaTime,Space.World); } bMoved = true; } } SendShadowMessage("ChangeFacing" , 1); }
//handles the player crouching and informs the shadows to do the same void Crouch() { if(fYAxis < -.5f && fXAxis == 0) { bCrouch = true; eFacing = Facings.Crouch; SendShadowMessage("ChangeFacing" , 3); } }
//handles the player crouching and informs the shadows to do the same void Crouch() { eFacing = Facings.Crouch; goCharacter.animation.Play("Duck"); SendShadowMessage("ChangeFacing" , 3); }
//handles the player looking up and informs the shadows to do the same void LookUp() { goCharacter.animation.Play("LookUp"); eFacing = Facings.Up; SendShadowMessage("ChangeFacing" , 2); }
//handles if the player needs to change facing and moving right void MoveRight() { if(fYAxis != -1) { if(!goCharacter.animation.IsPlaying("Jump") && !goCharacter.animation.IsPlaying("Fall")) goCharacter.animation.Play("Walk"); if(!bGoingRight) { transform.eulerAngles = new Vector3(0, 0, 0); bGoingRight = true; eFacing = Facings.Right; } if(!bAttacking || !bGrounded) { RaycastHit hit; if(Physics.Raycast(transform.position, transform.right, out hit, fWidth, lmGroundLayer.value)) { if(hit.collider.tag != "Wall") { transform.Translate(transform.right * fMoveSpeed * Time.deltaTime,Space.World); } } else { transform.Translate(transform.right * fMoveSpeed * Time.deltaTime,Space.World); } bMoved = true; } } SendShadowMessage("ChangeFacing" , 0);//consider taking it out of if statement same in move left }
//handles the player looking up and informs the shadows to do the same void LookUp() { if(fYAxis >= .75f) { bLookUp = true; eFacing = Facings.Up; SendShadowMessage("ChangeFacing" , 2); } else { bLookUp = false; } }
// Update is called once per frame //checks to handle if the player has moved or if he was grounded but now is not or if he was not grounded but now is void Update() { if(fCurIdleTimer > 0) fCurIdleTimer -= Time.deltaTime; if(!bIncorporeal && fadeScript.bDemoOver) bIncorporeal = true; if(fCurComboResetTime > 0.0f) { fCurComboResetTime -= Time.deltaTime; if(fCurComboResetTime <= 0.0f) { bFirstAttack = true; bSecondAttack = false; bThirdAttack = false; } } if(fHealth > 0.0f) { if(Mathf.Abs(transform.position.x - goActivePlayer.transform.position.x) > fMaxDistanceFromActivePlayer && bIncorporeal) { transform.position = goActivePlayer.transform.position; } if(Input.GetKeyDown(KeyCode.Backslash)) { Hurt(50); } //if not the active player, update that script if (bIncorporeal) FindActivePlayer(); if(eFacing != Facings.Idle) { if(bGrounded && fXAxis == 0 && fYAxis == 0) { eFacing = Facings.Idle; SendShadowMessage("ChangeFacing" , 4); } } if(fAttackPauseTime > 0.0f) { fAttackPauseTime -= Time.deltaTime; if(fAttackPauseTime <= 0.0f) { bAttacking = false; foreach(GameObject go in goRightHandWeapons) { go.collider.enabled = false; } foreach(GameObject go in goLeftHandWeapons) { go.collider.enabled = false; } } } if(fCurAttackTime > 0) { fCurAttackTime -= Time.deltaTime; } if(eFacing != Facings.Crouch) { bCrouch = false; } if(!(fYAxis <.75f)) { bLookUp = true; } else { bLookUp = false; } //end of stuff from update if(bGrounded) { RaycastHit hit; if( Physics.Raycast(transform.position+ transform.right*fWidth/2, -transform.up, out hit, fGroundDistance*2 + fHeight/2, 1 << lmGroundLayer) || Physics.Raycast(transform.position - transform.right*fWidth/2, -transform.up, out hit, fGroundDistance*2 + fHeight/2, 1 << lmGroundLayer)) { if(hit.collider.tag != "Ground") { bGrounded = false; bCanJump = false; fCurFallTime = 0.0f; } } else { bGrounded = false; bCanJump = false; fCurFallTime = 0.0f; } } if(!bGrounded) { if(!bCanJump) { bJumping = false; if(fCurJumpTime == 0.0f || fCurJumpTime > fMinJumpTime) { if(fCurFallTime >= 0.0f) { transform.Translate((-transform.up * fFallSpeed * Time.deltaTime) + transform.up*fFallSpeed *Time.deltaTime* (((fMaxFallTime-fCurFallTime)/fMaxFallTime))); fCurFallTime += Time.deltaTime; } else { transform.Translate(-transform.up * fFallSpeed * Time.deltaTime, Space.World); } bMoved = true; } else { bCanJump = true; Jump(); bCanJump = false; bStoppedJump = true; } } } if(bMoved) { SendShadowMessage("AddPosition" , transform.position); SendShadowMessage("Move"); } CheckForGroundPassThrough(); SendAnimatorBools(); bMoved = false; vPreviousPosition = transform.position; if(bAttacking) ComboHandler(); } }
void Update() { if(!goCharacter.animation.IsPlaying("Idle")) { if(bGrounded && fXAxis != 1 && fXAxis != 1 && fYAxis != 1 && fYAxis != -1) { eFacing = Facings.Idle; goCharacter.animation.Play("Idle"); SendShadowMessage("ChangeFacing" , 4); } } if(fAttackPauseTime > 0.0f) { fAttackPauseTime -= Time.deltaTime; if(fAttackPauseTime <= 0.0f) { bAttacking = false; } } if(fCurRopeScaleTime < fMaxRopeScaleTime) { fCurRopeScaleTime += Time.deltaTime; goRopeAttackBox.transform.localScale = new Vector3(fOriginalRopeXScale * fCurRopeScaleTime/fMaxRopeScaleTime, 1, 1); if(fCurRopeScaleTime > fMaxRopeScaleTime) goRopeAttackBox.transform.localScale = new Vector3(fOriginalRopeXScale, 1, 1); } //if currently attacking resolve it if(fCurAttackTime > 0) { if(bRopeAttack && fCurRopeScaleTime >= fMaxRopeScaleTime) { RopeHandler(); fCurAttackTime -= Time.deltaTime; } else if (bSwordAttack) { fCurAttackTime -= Time.deltaTime; } else if(bRangedAttack) { fCurAttackTime -= Time.deltaTime; } else { fCurAttackTime -= Time.deltaTime; } if(fCurAttackTime <= 0) { goRopeAttackBox.SetActive(false); } } }
//TODO: change Initialize to take a filepath to a file for that character, parse the file and add all expressions and stuff from here public void Initialize(string name) { //reference to this code later mName = name; mGObject = new GameObject(name); mGObject.transform.position = new Vector3(-30, 0, zValue); mPortrait = mGObject.AddComponent<SpriteRenderer>(); //mExpressionRend = mGObject.AddComponent<SpriteRenderer>(); currentFacing = Facings.left; mPoses = new Dictionary<string,string>(); mExpressions = new Dictionary<string,string>(); }
void ChangeFacing(int newFacing) { switch(newFacing) { case 0: eFacing = Facings.Left; bGoingLeft = true; vDirection = new Vector3(1.0f, 0, 0); break; case 1: eFacing = Facings.Right; bGoingLeft = false; vDirection = new Vector3(-1.0f, 0, 0); break; case 2: eFacing = Facings.Up; bLookUp = true; bCrouch = false; vDirection = new Vector3(0, 1.0f, 0); break; case 3: eFacing = Facings.Crouch; bCrouch = true; bLookUp = false; vDirection = new Vector3(0, -1.0f, 0); break; case 4: eFacing = Facings.Idle; bIdle = true; bCrouch= false; bLookUp = false; if(transform.eulerAngles == new Vector3(0, 0, 0)) vDirection = new Vector3(1.0f, 0, 0); else vDirection = new Vector3(-1.0f, 0, 0); break; default: eFacing = Facings.Right; break; } SetWeaponModels(); foreach(GameObject go in goLeftHandWeapons) { go.collider.enabled = false; } foreach(GameObject go in goRightHandWeapons) { go.collider.enabled = false; } }
void Update() { if(Input.GetKeyDown(KeyCode.Backslash)) Hurt(2); //if not the active player, update that script if (bIncorporeal) FindActivePlayer (); if(!goCharacter.animation.IsPlaying("Idle")) { if(bGrounded && !(fXAxis > .5f) && !(fXAxis < -.5f) && !(fYAxis >= .5f) && !(fYAxis <= -.5f)) { eFacing = Facings.Idle; goCharacter.animation.Play("Idle"); SendShadowMessage("ChangeFacing" , 4); } } if(fAttackPauseTime > 0.0f) { fAttackPauseTime -= Time.deltaTime; if(fAttackPauseTime <= 0.0f) { bAttacking = false; } } if(fCurRopeScaleTime < fMaxRopeScaleTime) { fCurRopeScaleTime += Time.deltaTime; foreach(GameObject pivot in goRopePivotPoints) { pivot.transform.localScale = new Vector3(fOriginalRopeXScale * fCurRopeScaleTime/fMaxRopeScaleTime, .1f, .1f); if(fCurRopeScaleTime > fMaxRopeScaleTime) pivot.transform.localScale = new Vector3(fOriginalRopeXScale, .1f, .1f); } } //if currently attacking resolve it if(fCurAttackTime > 0) { if(bRopeAttack && fCurRopeScaleTime >= fMaxRopeScaleTime) { RopeHandler(); fCurAttackTime -= Time.deltaTime; } else if (bSwordAttack) { fCurAttackTime -= Time.deltaTime; } else if(bRangedAttack) { fCurAttackTime -= Time.deltaTime; } else { fCurAttackTime -= Time.deltaTime; } if(fCurAttackTime <= 0) { foreach(GameObject attackbox in goRopeAttackBoxs) attackbox.SetActive(false); } } //check if already too far away from active, pop back in view( to shadow's location //if( Vector3.Distance( transform.position, goActivePlayer.transform.position ) < fMaxDistanceFromActivePlayer ) //{ // transform.position = ( goActivePlayer.transform.position + new Vector3( -3 * goActivePlayer.transform.right.x , 0 , 0) ); //} /*if(!goCharacter.renderer.isVisible) { if(bMoreThan1Player) { FindActivePlayer(); Vector3 vToActivePlayer = goActivePlayer.transform.position - transform.position; transform.Translate(vToActivePlayer.normalized * fMoveSpeed * Time.deltaTime * 3.0f); } }*/ if(eFacing == Facings.Crouch) { bCrouch = true; } else { bCrouch = false; } }
public void SetForMovement(Positions position, Facings facing, float fadeSpeed, float easeSpeed) { if(position != Positions.Offscreen) mPortrait.color = new Color( 1f, 1f, 1f, 0f ); //mExpressionRend.color = new Color( 1f, 1f, 1f, 0f ); easeDuration = easeSpeed; deltaAlpha = fadeSpeed; positionToGoTo = position; //find facing if( facing == Facings.auto ) { if( position == Positions.Left1 || position == Positions.Left2 || position == Positions.Centre ) facing = Facings.right; else facing = Facings.left; } if( facing != currentFacing ) { //flip the sprite Vector3 scale = mPortrait.transform.localScale; scale.x *= -1; mPortrait.transform.localScale = scale; //set new currentFacing currentFacing = facing; } mGObject.transform.position = FindStartPlace( position ); }
public void ChangePosition(string character, Positions newPosition = Positions.Offscreen, Facings facing = Facings.auto, float fadeSpeed = 0, float easeSpeed = 0) { if(fadeSpeed == 0) { fadeSpeed = defaultDeltaAlpha; } if (easeSpeed == 0) { easeSpeed = defaultEasingDuration; } changingPortraits.Add(character); if(newPosition == Positions.Offscreen) fadeSpeed *= -1; Debug.Log( "<color=green>[Char Man]</color> Char trying to change pose:" + character + "To Position -" + newPosition.ToString()); Debug.Assert( IsCharacter( character ), "CHRACTER IS NOT A CHARACTER" ); characterList[character.ToLower()].SetForMovement(newPosition, facing, fadeSpeed, easeSpeed); }