public void MovementVariables_addSegmentValid() { MovementVariables stuff = new MovementVariables(); Assert.AreEqual(stuff.Segment_positions.Count, 1, 0, "Segment list count initialized"); int[] coor1 = { 0, 1, 1, 0, 1, 1 }; append(stuff.Segment_positions.Last(), coor1); bool actual = stuff.add_Segment(null); Assert.IsTrue(actual); Assert.AreEqual(stuff.Segment_positions.Count, 2, 0, "Segment list count increased"); int[] coor2 = { 0, 0, 0, 0, 0, 0 }; append(stuff.Segment_positions.Last(), coor2); bool actual2 = stuff.add_Segment(null); Assert.IsFalse(actual2); Assert.AreEqual(stuff.Segment_positions.Count, 2, 0, "Segment list count constant"); // fail to add segment int[] coor3 = { -100, 0, 1, -200, 0, 2 }; append(stuff.Segment_positions.Last(), coor3); bool actual3 = stuff.add_Segment(null); Assert.IsTrue(actual3); Assert.AreEqual(stuff.Segment_positions.Count, 3, 0, "Segment list count increased"); int[] coor4 = { -100, 100, 1, -200, 0, 1 }; append(stuff.Segment_positions.Last(), coor4); bool actual4 = stuff.add_Segment(null); Assert.IsTrue(actual4); Assert.AreEqual(stuff.Segment_positions.Count, 4, 0, "Segment list count increased"); }
void Awake() { if (m_instance != null && m_instance != this) { Destroy(this.gameObject); } m_instance = this; }
private void Rotate(bool left) { Vector3 actualRotation = transform.localRotation.eulerAngles; Vector3 vector = left ? Vector3.forward : Vector3.back; actualRotation += vector * MovementVariables.GetInstance().Rotation; transform.localRotation = Quaternion.Euler(actualRotation); }
public void MovemmentVariables_initialization() { MovementVariables stuff = new MovementVariables(); Assert.AreEqual(stuff.Segment_positions.Last()[0], 0.0, 0.0, "Segment_position array initialization is wrong"); Assert.AreEqual(stuff.Segment_positions.Last().Count(), 6, 0, "Segment_position array size is wrong"); Assert.ThrowsException <System.IndexOutOfRangeException>(() => stuff.Segment_positions.Last()[7]); // have to declare the function this way because the actual argument is of type Func<Object> meaning it does not take any parameters, and accepts any return value, and because we only want to check for throwing an exception, it is fine }
private void OnValidate() { moodCommands = new MoodVariables(); expressionCommands = new ExpressionVariables(); movementCommands = new MovementVariables(); changeParameterCommands = new ParameterVariables(); tutorName = tutor.name; parameters = manager.getControllerParameters(tutorName); }
private void MovementDown() { if (m_fast) { m_pieceManager.SetVelocityDown(MovementVariables.GetInstance().ForceFast); } else { m_pieceManager.SetVelocityDown(MovementVariables.GetInstance().ForceNormal); } }
private void MovementLateral() { if (!m_right && !m_left) { m_pieceManager.SetVelocitiyLateral(0); return; } if (m_right) { m_pieceManager.SetVelocitiyLateral(MovementVariables.GetInstance().ForceLateral); } if (m_left) { m_pieceManager.SetVelocitiyLateral(-MovementVariables.GetInstance().ForceLateral); } }
public void ChangeToPinky() { currentMotor = pinky; Destroy(dummy); dummy = Instantiate(Resources.Load("pinkyDummy"), t.position - Vector3.forward, t.rotation) as GameObject; velocity = Vector2.zero; Debug.Log("Should be loading pinky now"); anim = dummy.GetComponent<tk2dSpriteAnimator>(); anim.Play(grounded? a_idle : a_fall); dummy.transform.parent = t; sprite = dummy.GetComponent<tk2dSprite>(); bc.size = new Vector3(sprite.CurrentSprite.colliderVertices[1].x * 2, sprite.CurrentSprite.colliderVertices[1].y * 2, 10); exhaling = false; agape = false; inMouth = null; mouthFull = false; Busy = false; sprinting = false; //change delegates and shit Fall = null; Gravity = null; //gonna have to replace this stuff when the time comes RunDown = PinkyRunDown; RunUp = PinkyRunUp; Direction = null; DirectionDown = null; DirectionUp = null; Run = null; JumpDown = PinkyJumpDown; DownDown = PinkyDownDown; DownUp = PinkyDownUp; OnLand += PinkyOnLand; OnLand -= MondoOnLand; OnLand -= BoogerOnLand; }
//functions that change my motor! public void ChangeToMondo() { currentMotor = mondo; Destroy(dummy); dummy = Instantiate(Resources.Load("mondoDummy"), t.position - Vector3.forward, t.rotation) as GameObject; velocity = Vector2.zero; anim = dummy.GetComponent<tk2dSpriteAnimator>(); anim.Play(grounded? a_idle : a_fall); dummy.transform.parent = t; sprite = dummy.GetComponent<tk2dSprite>(); bc.size = new Vector3(sprite.CurrentSprite.colliderVertices[1].x * 2, sprite.CurrentSprite.colliderVertices[1].y * 2, 10); sprinting = false; Run = null; RunUp = null; RunDown = null; Fall = null; Gravity = null; JumpDown = MondoJumpDown; DownDown = MondoDownDown; OnLand -= PinkyOnLand; OnLand += MondoOnLand; OnLand -= BoogerOnLand; }
public void ChangeToBoogerBoy() { currentMotor = boogerBoy; Destroy(dummy); Debug.Log("My name is " + name); dummy = Instantiate(Resources.Load("boogerDummy"), t.position - Vector3.forward, t.rotation) as GameObject; velocity = Vector2.zero; Debug.Log("Should be loading booger boy now"); anim = dummy.GetComponent<tk2dSpriteAnimator>(); anim.Play(grounded? a_idle : a_fall); dummy.transform.parent = t; sprite = dummy.GetComponent<tk2dSprite>(); bc.size = new Vector3(sprite.CurrentSprite.colliderVertices[1].x * 2, sprite.CurrentSprite.colliderVertices[1].y * 2, 10); /* exhaling = false; agape = false; inMouth = null; mouthFull = false; Busy = false; sprinting = false; */ //change delegates and shit OnLand -= PinkyOnLand; OnLand -= MondoOnLand; OnLand += BoogerOnLand; //call this on fall Fall = delegate(){ anim.Play (a_fall); }; //apply gravity Gravity = delegate(){ if (falling && velocity.y > 0){ JumpUp(); } velocity = new Vector2(velocity.x, Mathf.Max (velocity.y - boogerBoy.gravity, -BoogerFallSpeed)); }; //run button pressed: Shoot/charge Run = delegate(){ if (chargeTimer == 0){ GameObject myBooger = Instantiate(Resources.Load(boogerS), t.position + new Vector3(boogerOffsetX * FacingRightMod, boogerOffsetY, 0), t.rotation) as GameObject; myBooger.GetComponent<Booger>().FacingRight = FacingRight; } chargeTimer ++; }; //run button up: Release charge RunUp = delegate(){ if (chargeTimer > maximumCharge){ GameObject myBooger = Instantiate(Resources.Load(boogerL), t.position + new Vector3(boogerOffsetX * FacingRightMod, boogerOffsetY, 0), t.rotation) as GameObject; myBooger.GetComponent<Booger>().FacingRight = FacingRight; } else if (chargeTimer > mediumCharge){ GameObject myBooger = Instantiate(Resources.Load(boogerM), t.position + new Vector3(boogerOffsetX * FacingRightMod, boogerOffsetY, 0), t.rotation) as GameObject; myBooger.GetComponent<Booger>().FacingRight = FacingRight; } chargeTimer = 0; }; //jump button pressed: jump JumpDown = delegate(){ if (grounded){ velocity = new Vector2(velocity.x, boogerBoy.airSpeedInit); anim.Play (a_jump); jumping = true; } else if (wallHanging){ wallJumpTimer = wallJumpMax; velocity = new Vector2(FacingRight? -boogerBoy.wSpeed : boogerBoy.wSpeed, boogerBoy.jHeight); anim.Play(a_wallJump); wallHanging = false; falling = false; jumping = true; } }; //jump button released: fall JumpUp = delegate() { if (!falling) velocity = new Vector2(velocity.x, 0); }; //pressing a direction (left-right): move Direction = delegate(float amount) { if (wallJumpTimer > 0){ return; } if (dashing && grounded){ dashTimer ++; if (dashTimer >= dashMax){ dashing = false; if (controller.getL == false && !controller.getR){ anim.Play (a_endDash); } else { anim.Play (anim.GetClipByName(a_walk), anim.ClipFps * DirectionMax, anim.ClipFps); } anim.AnimationCompleted = AnimAfterDash; } } if (((amount < 0 && !canMoveLeft) || (amount > 0 && !canMoveRight)) && !grounded && !wallHanging && falling){ anim.Play(a_wallGrab); wallHanging = true; return; } if (amount < 0){ //flip sprite when appropriate if (!canMoveLeft) return; if (FacingRight) FacingRight = false; } else if (amount > 0){ if (!canMoveRight) return; if (!FacingRight) FacingRight = true; } if (!grounded) directionTimer = DirectionMax; if (directionTimer == 0){ anim.Play (a_walk); } directionTimer = Mathf.Min (directionTimer + 1, DirectionMax); velocity = new Vector2(CurMaxSpeed * (directionTimer / DirectionMax) * (amount < 0? -1 : 1), velocity.y); }; //just pressed a direction DirectionDown = delegate() { CancelInvoke("BoogerStop"); }; //direction release DirectionUp = delegate(){ Invoke ("BoogerStop", Time.deltaTime * 4); }; //double tap : Dash! DoubleTap = delegate() { if (!grounded) return; directionTimer = 5; Debug.Log ("Dash!"); dashing = true; anim.Play (a_dash); dashTimer = 0; }; //down doesn't do anything for Megaman DownDown = delegate(){ }; DownUp = delegate(){ }; }