public void ResPhasetest() { Player p1 = new Player(0); Player p2 = new Player(1); IGame game = mocks.Stub <IGame>(); Card attack = new Attack(CardSuit.Spade, 1); Phase a = new ActionPhase(p1); PhaseList ret = a.advance(new UseCardAction(attack, p2), game); Phase b = ret.pop(); AttackPhase b2 = b as AttackPhase; Miss miss = new Miss(CardSuit.Diamond, 2); p1.handCards.Add(attack); p2.handCards.Add(miss); p1.health = 1; Player[] p = new Player[1]; p[0] = p1; ret = b.advance(null, game); Phase c = ret.pop(); ResponsePhase c_ = c as ResponsePhase; Assert.IsNull(c_.responseYesOrNo(true, game)); }
public void Res3Phasetest() { // ActionPhase produces attackPhase Player p1 = mocks.Stub <Player>(0); Player p2 = mocks.Stub <Player>(1); IGame game = mocks.Stub <IGame>(); Card attack = new Attack(CardSuit.Spade, 1); // ActionPhase produces attackPhase ActionPhase a = new ActionPhase(p1); PhaseList ret = a.advance(new UseCardAction(attack, p2), game); Phase b = ret.pop(); AttackPhase b2 = b as AttackPhase; Miss miss = new Miss(CardSuit.Diamond, 2); p1.handCards.Add(attack); p1.handCards.Add(miss); p1.health = 1; Player[] p = new Player[1]; p[0] = p1; // AttackPhase produces responsePhase ret = b.advance(null, game); Phase c = ret.pop(); ResponsePhase c_ = c as ResponsePhase; Assert.AreEqual(c_.ToString(), "Response Phase of 1"); }
public void Res5Phasetest() { SunQuan p1 = new SunQuan(0); LiuBei p2 = new LiuBei(1); List <Card> x = new List <Card>(); Player[] p = new SunQuan[1]; p[0] = p1; Miss miss = new Miss(CardSuit.Diamond, 2); Card attack = new Attack(CardSuit.Spade, 1); x.Add(miss); x.Add(attack); Game game = new Game(p, new CardSet(x)); // ActionPhase produces attackPhase ActionPhase a = new ActionPhase(p1); PhaseList ret = a.advance(new UseCardAction(attack, p2), game); Phase b = ret.pop(); AttackPhase b2 = b as AttackPhase; p1.handCards.Add(attack); p1.handCards.Add(miss); p1.health = 1; // AttackPhase produces responsePhase ret = b.advance(null, game); Phase c = ret.pop(); ResponsePhase c_ = c as ResponsePhase; Assert.IsInstanceOfType(a.responseAbilityActionSun(new AbilityActionSun(attack), game), typeof(PhaseList)); }
void Awake() { deploySolders = this.GetComponent <DeploySoldiers> (); armyManagement = this.GetComponent <ArmyManagement> (); globalFunctions = this.GetComponent <GlobalFunctions> (); phases = this.GetComponent <Phases> (); attackPhase = this.GetComponent <AttackPhase> (); }
// Use this for initialization void Start() { currentPhase = CurrentPhase.None; _attackPhase = new AttackPhase(); currentUnitSelected = null; Current = this; }
// Walk to the next choice spot and then pick a new option once there private void HandleEnd() { if (MoveToTarget(config.moveSpeed)) { GetNextOption(); curPhase = AttackPhase.Start; } }
private void StartPhase2() { this._movement.MoveInDirection(Direction.None); this._animator.SetTrigger(AnimatorHelper.GetAnimatorParameterFromDirection(Direction.South)); this._currentAttackPhase = AttackPhase.Phase2; Invoke(nameof(this.FreezeRotationAndStartFire), 1f); InvokeRepeating(nameof(this.ShuffleDragons), 0f, this._shuffleDragonsInterval); }
// Walk to the starting position of the current attack private void HandleStart() { // Start the attack once boss has reached target position if (MoveToTarget(config.dashSpeed)) { curPhase = AttackPhase.Attack; StartAttack(); } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Update Movement End Check //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private void UpdateMovementEndCheck() { // If it's expected that we will reach the target vector within the next frame or so. Set to fadeout animation. if (Vector2.Distance(Position.Get(), m_vTargetPos) < (m_fSpeed * Time.deltaTime * DISTANCE_TOLERANCE)) { m_fFadeoutStartAlpha = SpriteColour.a; m_eAttackPhase = AttackPhase.FADEOUT; } }
public override void OnHitByAttack(AttackCollisionData xAtColData, AttackPhase xAtPhase) { base.OnHitByAttack(xAtColData, xAtPhase); fFurthestAllowedDistance = 500f; AddHitEffect(); if (Utils.GetTheGame().xNetworkInfo.enCurrentRole == NetworkHelperInterface.NetworkRole.Server) { SendClientInstruction(0); } }
protected void Start() { // Vector3 tempLocalPos = transform.localPosition; // bool onRightSide = (transform.localPosition.x > 0f) ? true : false; // tempLocalPos.x = Mathf.Abs(tempLocalPos.x); // initialLocalPosition = tempLocalPos; // Debug.Log($"Initial Local Postition: {initialLocalPosition}"); // Debug.Break(); phase = AttackPhase.Startup; }
private void Start() { jumping = false; rigidbody = this.GetComponent<Rigidbody2D>(); direction = new Vector2(); attackPhase = AttackPhase.NONE; nextAttackPhase = 0.0f; flipPhase = FlipPhase.NONE; nextFlipPhase = 0.0f; }
public void AttackHitTest() { Player p1 = mocks.Stub <Player>(0); Player p2 = mocks.Stub <Player>(1); IGame game = mocks.Stub <IGame>(); Card attack = new Attack(CardSuit.Spade, 1); // ActionPhase produces attackPhase Phase a = new ActionPhase(p1); PhaseList ret = a.advance(new UseCardAction(attack, p2), game); Phase b = ret.pop(); Assert.IsInstanceOfType(b, typeof(AttackPhase)); AttackPhase b2 = b as AttackPhase; Assert.AreEqual(attack, b2.attack); Assert.AreEqual(a, b2.actionPhase); Assert.AreEqual(p1, b2.player); Assert.AreEqual(p2, b2.targets[0]); Assert.AreEqual(a, ret.pop()); Assert.IsTrue(ret.isEmpty()); // AttackPhase produces responsePhase ret = b.advance(null, game); Phase c = ret.pop(); Assert.IsInstanceOfType(c, typeof(ResponsePhase)); ResponsePhase c_ = c as ResponsePhase; Assert.AreEqual(p2, c_.player); Phase c2 = ret.pop(); Assert.IsInstanceOfType(c2, typeof(AttackPhase)); Assert.AreEqual(b, c2); Assert.IsTrue(ret.isEmpty()); // response with cancel ret = c.advance(new YesOrNoAction(false), game); Assert.IsTrue(ret.isEmpty()); // attackPhase produces harmPhase ret = c2.advance(null, game); Phase d = ret.pop(); Assert.IsInstanceOfType(d, typeof(HarmPhase)); HarmPhase d2 = d as HarmPhase; Assert.AreEqual(p2, d2.player); Assert.AreEqual(p1, d2.source); Assert.AreEqual(1, d2.harm); Assert.IsTrue(ret.isEmpty()); ret = d.advance(null, game); Assert.IsTrue(ret.isEmpty()); }
void Start () { babaYaga = GameObject.FindGameObjectWithTag("BabaYaga"); maxPestelStrikes = 2 + babaYaga.GetComponent<BabaYaga>().aggressionPhase; pestelStrikeIntervals = 5 - (babaYaga.GetComponent<BabaYaga>().aggressionPhase); returning = false; strikeSpeed = strikeSpeed + (babaYaga.GetComponent<BabaYaga>().aggressionPhase * 50); animator = GetComponent<Animator>(); attackPhase = AttackPhase.Rising; pestelStrikes = 1; }
void Awake() { entity = GetComponent <Entity>(); moveTarget = transform.position; attackPhase = AttackPhase.Approach; preferredCirclingDistance = Random.Range( preferredCirclingDistance, preferredCirclingDistance + 1f); attackFrequency = Random.Range(4, 7); }
public override void OnHitByAttack(AttackCollisionData xAtColData, AttackPhase xAtPhase) { if ((!(xAtPhase.xStats.sAttackHandle != "Bomb") || CAS.DifficultySetting >= 3) && iCounter >= 30) { if (iCounter < iExplodeAt - 5) { iCounter = iExplodeAt - 5; } _ = iTimesHit; _ = iTimesToHitBeforeDestroy; } }
private void HandleThrust() { if (curState == States.Attack) { Attack(player); } if (MoveToTarget(config.thrust.movement.x)) { EndAttack(); SelectPosition(quarter, true); curPhase = AttackPhase.End; } }
public void UpdateApproach() { // move toward the attack target moveTarget = attackTarget.transform.position; StepTowards(moveTarget); // are we close enough to enter circle state? float distance = GetDistanceToAttackTarget(); if (distance < preferredCirclingDistance) { attackPhase = AttackPhase.Circle; } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Reset //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public void Reset() { m_ttFadeinTimer.Reset(); m_ttFadeoutTimer.Reset(); Impacted = false; m_ImpactTargetCollider = null; CollisionDetector = true; m_eAttackPhase = AttackPhase.FADEIN; m_vDirection = (m_vTargetPos - (Vector2)transform.position).normalized; Color alpha = SpriteColour; alpha.a = 0.0f; SpriteColour = alpha; }
public void ZhangFeiAbtestnomocknull1() { { IGame game = mocks.Stub <IGame>(); Player p = new ZhangFei(1); Attack card = new Attack(CardSuit.Club, 1); ActionPhase acpha = new ActionPhase(p); Player[] ls = new Player[1]; ls[0] = new LiuBei(2); AttackPhase pha = new AttackPhase(p, card, ls, acpha); pha.actionPhase.attackCount = 1; Assert.IsFalse(p.canNotAttack(null, game)); } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Fade in //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private void FadeIn() { m_ttFadeinTimer.Update(); if (m_ttFadeinTimer.TimeUp()) { SpriteColour = Color.white; m_eAttackPhase = AttackPhase.MOVING; } else { Color alpha = SpriteColour; alpha.a = Mathf.Lerp(0.0f, 1.0f, m_ttFadeinTimer.GetCompletionPercentage()); SpriteColour = alpha; } }
protected virtual void FixedUpdate() { if (startupDuration > 0f) { startupDuration -= Time.fixedDeltaTime; if (phase != AttackPhase.Startup) { phase = AttackPhase.Startup; // Debug.Log(phase); } } else if (activeDuration > 0f) { if (activeDuration != Mathf.Infinity) { activeDuration -= Time.fixedDeltaTime; Color hitboxColor = new Color(255f, 0f, 0f, 96f); hitboxes[0].shape.gameObject.GetComponent <Renderer>().material.SetColor("_Color", hitboxColor); if (phase != AttackPhase.Active) { phase = AttackPhase.Active; // Debug.Log(phase); } } } else { recoveryDuration -= Time.fixedDeltaTime; hitboxes[0].shape.gameObject.GetComponent <Renderer>().material.SetColor("_Color", Color.red); if (phase != AttackPhase.Recovery) { phase = AttackPhase.Recovery; // Debug.Log(phase); } } if (startupDuration <= 0f && activeDuration > 0f) { hitboxes[0].shape.enabled = true; } if (recoveryDuration <= 0f) { hitboxes[0].shape.enabled = false; gameObject.SetActive(false); } }
public void AttackMissTest() { Player p1 = mocks.Stub <Player>(0); Player p2 = mocks.Stub <Player>(1); IGame game = mocks.Stub <IGame>(); Card attack = new Attack(CardSuit.Spade, 1); Miss miss = new Miss(CardSuit.Diamond, 2); // ActionPhase produces attackPhase Phase a = new ActionPhase(p1); PhaseList ret = a.advance(new UseCardAction(attack, p2), game); Phase b = ret.pop(); Assert.IsInstanceOfType(b, typeof(AttackPhase)); AttackPhase b2 = b as AttackPhase; Assert.AreEqual(attack, b2.attack); Assert.AreEqual(a, b2.actionPhase); Assert.AreEqual(p1, b2.player); Assert.AreEqual(p2, b2.targets[0]); Assert.AreEqual(a, ret.pop()); Assert.IsTrue(ret.isEmpty()); // AttackPhase produces responsePhase ret = b.advance(null, game); Phase c = ret.pop(); Assert.IsInstanceOfType(c, typeof(ResponsePhase)); ResponsePhase c_ = c as ResponsePhase; Assert.AreEqual(p2, c_.player); Phase c2 = ret.pop(); Assert.IsInstanceOfType(c2, typeof(AttackPhase)); Assert.AreEqual(b, c2); Assert.IsTrue(ret.isEmpty()); // response with cancel ret = c.advance(new CardAction(miss), game); Assert.IsTrue(ret.isEmpty()); // attackPhase produces nothing ret = c2.advance(null, game); Assert.IsTrue(ret.isEmpty()); }
private void CheckHealthAndUpdateCurrentAttackPhase() { if (this._currentHealth <= 2f * this.MaxHealth / 3f && this._currentAttackPhase == AttackPhase.Phase1) { this._currentAttackPhase = AttackPhase.Phase2; this.StartPhase2(); } if (this._currentHealth <= this.MaxHealth / 3f && this._currentAttackPhase == AttackPhase.Phase2) { this._currentAttackPhase = AttackPhase.Phase3; this.StartPhase3(); } if (this._currentHealth <= 0) { this._isDead = true; } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * Derived Method: On Collision //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private void OnTriggerEnter2D(Collider2D collider) { if (!Impacted && collider.tag.Contains("Enemy")) { Enemy_Base enemy = collider.gameObject.GetComponent <Enemy_Base>(); if (enemy.Hurtable && ImpactPossible(collider)) { m_ImpactTargetCollider = collider; enemy.IsFrozen = true; // Also freeze it from moving Vector3 impactPosition = Position; Position.Set(enemy.Position); // Lock fireball impact animation to the current position of the enemy CollisionDetector = false; // Turn off the Collision Detector Impacted = true; m_eAttackPhase = AttackPhase.IMPACT; StartCoroutine(OnImpact(enemy, impactPosition)); } } }
protected virtual void OnEnable() { // transform.eulerAngles = new Vector3(0f, 0f, hitboxes[0].knockbackAngle); startupDuration = hitboxes[0].startup * Time.fixedDeltaTime; if (hitboxes[0].timeActive == 0) { activeDuration = Mathf.Infinity; } else { activeDuration = hitboxes[0].timeActive * Time.fixedDeltaTime; } recoveryDuration = hitboxes[0].recovery * Time.fixedDeltaTime; Vector3 tempLocalPos = transform.localPosition; // bool onRightSide = (transform.localPosition.x > 0f) ? true : false; // tempLocalPos.x = Mathf.Abs(tempLocalPos.x); initialLocalPosition = tempLocalPos; phase = AttackPhase.Startup; initialKnockbackAngle = hitboxes[0].knockbackAngle; }
public void UpdateClose() { // calculate vector to target Vector3 attackDirection = transform.position - attackTarget.transform.position; // if within attack distance, switch mode if (attackDirection.magnitude <= closeDistance) { attackPhase = AttackPhase.Attack; //Slasher slasher = GetComponent<Slasher>(); //slasher.DashForward(); } // otherwise keep closing else { attackDirection = VectorUtil.Set2DLength(attackDirection, attackDirection.magnitude * 0.1f); // maybe keep circling while closing? attackDirection = VectorUtil.RotateByDegrees(attackDirection, 1); moveTarget = attackTarget.transform.position + attackDirection; StepTowards(moveTarget); } }
public void ChangePhase(AttackPhase phase) { if (this.enabled == false) { return; } this.phase = phase; if (this.phase == AttackPhase.Idle) { anim.CrossFadeInFixedTime("Idle", 0.5f); } else if (this.phase == AttackPhase.RockStorm) { cycle = AttackCycle.RockStorm; anim.SetBool("punching", false); anim.SetBool("rockstorm", true); } else if (this.phase == AttackPhase.ThrowRocks) { anim.CrossFadeInFixedTime("throwDebris", 0.5f); } }
private void HandleBeam() { if (!atCorner) { if (MoveToTarget(config.beam.movement.x)) { atCorner = true; BeginAttack(config.beam); } } else { HandleProjectile(); // Walk to nearest choice spot once attack is done if (curState != States.Attack) { curPhase = AttackPhase.End; SelectPosition(quarter, true); } } }
void OnCollisionEnter2D(Collision2D coll) { if (coll.contacts[0].normal.y == 1.0f) { jumping = false; if (attackPhase == AttackPhase.MIDDLE) { nextAttackPhase = Time.time + 0.1f; speed = normalSpeed * 0.5f; // Hit the enemy. if (coll.gameObject.tag == "Enemy") { Enemy enemy = coll.gameObject.GetComponent<Enemy>(); if (enemy != null) { SoundSingleton.Singleton.PlaySmashEnemy (); enemy.setLife(enemy.getLife() - 1); } } } attackPhase = AttackPhase.END; } if (coll.gameObject.tag == "Wall") { if (flipPhase == FlipPhase.NONE) { flipPhase = FlipPhase.TOUCHING; } } }
private void Update() { if (GameManager.endGame) { return; } if (movingRight) { direction.x = 1.0f; } else { direction.x = -1.0f; } if (attackPhase == AttackPhase.END && Time.time > nextAttackPhase) { speed += normalSpeed * Time.deltaTime; if (speed > normalSpeed) { speed = normalSpeed; attackPhase = AttackPhase.NONE; } } if (flipPhase == FlipPhase.FLIPPLING && Time.time > nextFlipPhase) { flipPhase = FlipPhase.NONE; } if (playerStats.IsDead() == false) { if (Input.GetKeyDown(KeyCode.Space) || (Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Began)) { action = true; } else { action = false; } } if ((int)attackPhase > 0) { if (Time.time > nextAttackPhase) { if (attackPhase == AttackPhase.BEGIN) { SoundSingleton.Singleton.PlayAttackPlayer (); rigidbody.velocity = new Vector2(0.0f, 0.0f); rigidbody.AddForce(new Vector2(0.0f, -jumpSpeed * 0.8f), ForceMode2D.Impulse); attackPhase = AttackPhase.MIDDLE; } } } else { if (action) { if (flipPhase == FlipPhase.TOUCHING) { flipPhase = FlipPhase.FLIPPLING; movingRight = !movingRight; Vector3 theScale = transform.localScale; theScale.x *= -1; transform.localScale = theScale; nextFlipPhase = Time.time + 1.0f; } else if (!jumping) { rigidbody.AddForce(new Vector2(0.0f, jumpSpeed), ForceMode2D.Impulse); jumping = true; } else { if (attackPhase == AttackPhase.NONE) { attackPhase = AttackPhase.BEGIN; nextAttackPhase = Time.time + 0.05f; } } } } if (animator != null) { animator.SetBool("movingRight", movingRight); animator.SetBool("jumping", jumping); animator.SetBool("attacking", (attackPhase == AttackPhase.MIDDLE)); } }
void StrikeTheBlood() { if (pestelStrikes <= maxPestelStrikes) { if (attackPhase == AttackPhase.Rising) { animator.Play("FreeIdle"); if (transform.position.y < targetHeight) { transform.Translate(new Vector3(0, 1) * Time.deltaTime * strikeSpeed, Space.World); } else { intervalTimer = pestelStrikeIntervals; attackPhase = AttackPhase.Moving; } } if (attackPhase == AttackPhase.Striking) { if (transform.position.y > floor) { transform.Translate(new Vector3(0, -1) * Time.deltaTime * strikeSpeed, Space.World); animator.Play("Striking"); } else { pestelStrikes++; attackPhase = AttackPhase.Rising; } } if (attackPhase == AttackPhase.Moving) { intervalTimer -= Time.deltaTime; if (intervalTimer <= 0) { animator.Play("StrikeSignal"); } else { animator.Play("FreeIdle"); float playerPositionX = GameObject.FindGameObjectWithTag("Player").transform.position.x; int fudgeFactor = 1; if (transform.position.x >= playerPositionX - fudgeFactor && transform.position.x <= playerPositionX + fudgeFactor) { //do nothing. } else if (playerPositionX < transform.position.x) { transform.Translate(new Vector3(-1, 0) * Time.deltaTime * 180, Space.World); } else if (playerPositionX > transform.position.x) { transform.Translate(new Vector3(1, 0) * Time.deltaTime * 180, Space.World); } } } } else { returning = true; } }
public void OnAttackComplete() { attackPhase = AttackPhase.Circle; attackFrequency = Random.Range(2, 5); }
//called by animator public void Strike () { attackPhase = AttackPhase.Striking; }
public void StartPhase1() { Debug.Log("Start phase 1"); this._currentAttackPhase = AttackPhase.Phase1; }
private void EndSpin() { curPhase = AttackPhase.End; SelectPosition(quarter, true); }