public override void Update() { Position += Dir * (float)GameCntrl.Time(Speed); if (CheckCollision(Position + SecondPosition / 2)) { Position -= Dir * (float)GameCntrl.Time(Speed); Dir *= -1; } var player = Objects.ObjFind <Player>(0); if (player != null) { var center = Position + SecondPosition / 2; if ( player.LeftPaw.CurrentState != Paw.State.Jumping && GameMath.RectangleInRectangle(center - Mask / 2, center + Mask / 2, player.LeftPaw.Position, player.LeftPaw.Position) || player.RightPaw.CurrentState != Paw.State.Jumping && GameMath.RectangleInRectangle(center - Mask / 2, center + Mask / 2, player.RightPaw.Position, player.RightPaw.Position) ) { player.Die(); //Console.WriteLine("KILLED" + GameCntrl.ElapsedTimeTotal); } } _ang += GameCntrl.Time(3); if (_ang > Math.PI * 2) { _ang -= Math.PI * 2; } Depth = -(int)Position.Y + 1000; }
public override void Update() { Selected = false; if (DmgAnim) { _dmgFrame += GameCntrl.Time(_dmgAnimSpd); if (_dmgFrame >= _dmgMaxFrame) { _dmgFrame = 0; DmgAnim = false; } } if (Waiting) { if (BuffDialogue.Destroyed) { Waiting = false; BuffDialogue = null; } } Effects.RemoveAll(o => o.Duration <= 0); Effects.AddRange(NewEffects); NewEffects.Clear(); }
public override void Update() { if (CurrentState == State.Stepping) { var stepAnglePrev = _stepAngle; var posPrev = Position; _stepAngle += GameCntrl.Time(_stepSpd) * Inversion; var deg = MathHelper.ToRadians((float)(_startingAngle + _stepAngle)); Position = Pair.Position + new Vector2((float)Math.Cos(deg), -(float)Math.Sin(deg)) * _startingDistance; } if (CurrentState == State.Jumping && Z == 0) { Owner.PawTrail.AddPawprint(Position, (float)Owner.FacingDirection, SpritesDefault.Pawprint); } Z += (Owner.Z - Z) / ZRubberBand; if (CurrentState != State.Jumping && Math.Abs(Owner.Z - Z) < 1) { Z = 0; } Depth = -(int)Position.Y; }
public override void Update() { for (var i = 0; i < _colors.Length; i += 1) { _colors[i] += _colorDirections[i] * GameCntrl.Time(_colorChangeCycle); if (_colors[i] > 1 || _colors[i] < 0) { _colors[i] -= (_colors[i] - (int)(_colors[i])) * 2.0 * _colorDirections[i]; _colorDirections[i] *= -1; } } }
public override void Update() { base.Update(); if (_blackscreenActivated) { _blackscreenAlpha += (float)GameCntrl.Time(_blackscreenSpeed); } if (Objects.GetList <Dialogue>().Count == 0 && Units.Count == 1 && Units[0] is ArenaPlayer) { _win = true; } if (CurrentUnit >= UnitTurnOrderList.Count || UnitTurnOrderList[CurrentUnit].Destroyed) { //CurrentUnit = 0; Units[0].Initiative = true; Units[0].ReceiveInitiative(); } //Console.WriteLine(CurrentUnit + " " + UnitTurnOrderList[CurrentUnit].Waiting); }
public override void Update() { if (_typeAlarm.Update()) { TextPtr += 1; try { if (Text[TextPtr] == ' ') { TextPtr += 1; } if (Text[TextPtr] == Environment.NewLine[0]) { TextPtr += Environment.NewLine.Length; } if (TextPtr >= Text.Length) { throw new Exception(); } } catch (Exception) { _typeAlarm.Active = false; TextPtr = Text.Length - 1; _delayAlarm.Set(1 + Text.Length * 0.1); } } var str = ""; if (!_dead) { str = Text.Substring(0, TextPtr + 1); } _targetTextSize = _font.MeasureString(str); _textSize.X += (float)GameCntrl.Time((_targetTextSize.X - _textSize.X) / _textRubberBand); _textSize.Y += (float)GameCntrl.Time((_targetTextSize.Y - _textSize.Y) / _textRubberBand); _targetPos = Test.RoundVector2(Owner.Position + MainOffset); _pos.X += (float)GameCntrl.Time((_targetPos.X - _pos.X) / _posRubberBand); _pos.Y += (float)GameCntrl.Time((_targetPos.Y - _pos.Y) / _posRubberBand); if ((_targetPos - _pos).Length() > _maxBubbleDist) { var e = _targetPos - _pos; e.Normalize(); _pos = _targetPos + e * _maxBubbleDist; } if (_delayAlarm.Update()) { //Objects.Destroy(this); _dead = true; _textRubberBand = 2f / 60f; } if (_dead && _textSize.X < 4 && _textSize.Y < 4) { Objects.Destroy(this); } var phaseAdd = GameCntrl.Time(_wiggleysSpd); for (var i = 0; i < _wiggleys.Length; i += 1) { _wiggleysPhase[i] += phaseAdd; if (_wiggleysPhase[i] > Math.PI * 2) { _wiggleysPhase[i] -= Math.PI * 2; } _wiggleys[i] = new Vector2( (float)Math.Cos(_wiggleysPhase[i]), (float)Math.Sin(_wiggleysPhase[i]) ) * _wiggleysR; } }
public override void Update() { // Jump. if (_chargingJump) { LeftPaw.StopStep(); RightPaw.StopStep(); if (!_jumpChargeReady && !_jumpCharge.Active) { _jumpCharge.Set(_jumpChargeTime); } if (_jumpCharge.Update()) { _jumpChargeReady = true; } } else { if (_jumpChargeReady) { Zspd = 320; } _jumpChargeReady = false; _jumpCharge.Reset(); } // Jump. PawTrail.Update(); FacingDirection = GameMath.Direction(RightPaw.Position, LeftPaw.Position) + 90; if (FacingDirection >= 360) { FacingDirection -= 360; } Move((LeftPaw.Position + RightPaw.Position) / 2f); Depth = -(int)Position.Y; Zspd -= (float)GameCntrl.Time(Gravity); Z += (float)GameCntrl.Time(Zspd); if (Z < 0) { Z = 0; Zspd = 0; } if (Z > 0) { LeftPaw.CurrentState = Paw.State.Jumping; RightPaw.CurrentState = Paw.State.Jumping; } else { if (LeftPaw.CurrentState == Paw.State.Jumping) { LeftPaw.CurrentState = Paw.State.Resting; } if (RightPaw.CurrentState == Paw.State.Jumping) { RightPaw.CurrentState = Paw.State.Resting; } } if (_jumpCharge.Active || _jumpChargeReady) { _jumpChargeZ = -(float)Math.Sqrt(1 - _jumpCharge.Counter / _jumpChargeTime) * _jumpChargeZMax; } else { _jumpChargeZ = _jumpChargeZ / 2f; } }
public override void Update() { PawTrail.Update(); if (CurrentState == State.Patroling) { if (GameMath.Distance(Position, _patrolPoints[_currentPointIndex]) < 8) { _currentPointIndex += 1; if (_currentPointIndex == _patrolPoints.Count) { _currentPointIndex = 0; } } var vec = _patrolPoints[_currentPointIndex] - Position; vec.Normalize(); Position += vec * (float)GameCntrl.Time(_speed); if (_pawprint.Update()) { var normVec = new Vector2(vec.Y * _inverse, -vec.X * _inverse) * _stepWidth; PawTrail.AddPawprint(Position + normVec, (float)GameMath.Direction(vec), SpritesDefault.EnemyPaw); _inverse *= -1; } // Checking for player's trail. var player = Objects.ObjFind <Player>(0); if (player != null) { foreach (Pawprint myPawprint in PawTrail.Pawprints) { foreach (Pawprint playersPawprint in player.PawTrail.Pawprints) { if (!playersPawprint.Destroyed && GameMath.Distance(myPawprint.Position, playersPawprint.Position) < _detectionRadius) { _tracedPawprint = playersPawprint; CurrentState = State.Alarmed; _pursuingDelayAlarm.Set(_pursuingDelay); break; } } if (_tracedPawprint != null) { break; } } } // Checking for player's trail. } if (CurrentState == State.Alarmed) { if (_pursuingDelayAlarm.Update()) { if (!_tracedPawprint.Destroyed) { CurrentState = State.Pursuing; _origPos = Position; Position = _tracedPawprint.Position; } else { _tracedPawprint = null; CurrentState = State.Patroling; } } } if (CurrentState == State.Pursuing) { if (_pursuingAlarm.Update()) { var player = Objects.ObjFind <Player>(0); var lostTrail = false; if (player != null) { var id = player.PawTrail.Pawprints.IndexOf(_tracedPawprint); if (id == -1 || id == 0) { lostTrail = true; } else { id -= 1; _tracedPawprint = player.PawTrail.Pawprints[id]; Position = _tracedPawprint.Position; if (_tracedPawprint.Destroyed) { lostTrail = true; } } } else { lostTrail = true; } if (lostTrail) { _tracedPawprint = null; CurrentState = State.Patroling; } int x = (int)player.Position.X / Scene.CellSize; int y = (int)player.Position.Y / Scene.CellSize; if (Test.CurrentScene.TileMap[x, y] != 2 && GameMath.Distance(Position, player.Position) < _detectionRadius * 2) { player.Die(); Position = _origPos; CurrentState = State.Resting; _restingAlarm.Set(_restingTime); } } } if (CurrentState == State.Resting) { if (_restingAlarm.Update()) { CurrentState = State.Patroling; } } }