private void HitSignalProcessing(HitState state, GameObject collisionObject) { if (collisionObject.name == NameManager.NAME_PLATFORM) { switch (state) { case HitState.Enter: _isOnPlatform = true; break; case HitState.Exit: LandingAssessment.ResetPlatformTime(); _isOnPlatform = false; break; case HitState.Stay: LandingAssessment.CheckWinningConditions(_hitShipSystem.transform); break; default: throw new ArgumentOutOfRangeException(nameof(state), state, "New state? Do I need to know about this?"); } } else { if (!_isOnPlatform && collisionObject.name == NameManager.NAME_STAGE) { CrashAssessment.Crash(); } } }
virtual protected void InitState() { State moveState = new MoveState(); State attackState = new AttackState(); State hitState = new HitState(); State skillOneState = new SkillOne(); State skillTwoState = new SkillTwo(); State skillThreeState = new SkillThree(); State idleState = new IdleState(); moveState.Init(this); attackState.Init(this); hitState.Init(this); skillOneState.Init(this); skillTwoState.Init(this); skillThreeState.Init(this); idleState.Init(this); _stateDic.Add(eSTATE.MOVE, moveState); _stateDic.Add(eSTATE.ATTACK, attackState); _stateDic.Add(eSTATE.HIT, hitState); _stateDic.Add(eSTATE.SKILLONE, skillOneState); _stateDic.Add(eSTATE.SKILLTWO, skillTwoState); _stateDic.Add(eSTATE.SKILLTHREE, skillThreeState); _stateDic.Add(eSTATE.IDLE, idleState); }
public static HitState ConvertBattleHitState2HitState(DamageModelBase model) { HitState result = HitState.Miss; if (model == null) { return(result); } switch (model.GetHitState()) { case BattleHitStatus.Clitical: if (model.GetGurdEffect()) { } return(HitState.CriticalDamage); case BattleHitStatus.Normal: if (model.GetGurdEffect()) { } return(HitState.NomalDamage); default: return(HitState.Miss); } }
public static FSMStateMachine GetCharacterEditorFSM(Creature owner) { FSMTranslationMap translationMap = new FSMTranslationMap(); DeadState dead = new DeadState(owner); AttackState attackState = new AttackState(owner); IdleState idle = new IdleState(owner); WalkState walk = new WalkState(owner); HitState hitState = new HitState(owner); RunState runState = new RunState(owner); HitMoveState hitMoveState = new HitMoveState(owner); HitFlyState hitFlyState = new HitFlyState(owner); translationMap.addState(dead); translationMap.addState(idle); translationMap.addState(walk); translationMap.addState(runState); translationMap.addState(hitState); translationMap.addState(hitMoveState); translationMap.addState(attackState); translationMap.addState(hitFlyState); translationMap.MixAll(); translationMap.check(); FSMStateMachine fsm = new FSMStateMachine(translationMap); return(fsm); }
/// <summary> /// Sets the color for the given hit state. /// </summary> /// <remarks>If the color is null, it will ensure that the /// color currently assigned is removed, if any.</remarks> public void SetColor(HitState hitState, Color color) { if (color != null) colors[hitState] = color; else colors.Remove(hitState); }
protected virtual void PlayHpGaugeDamage(UIBattleShip ship, HitState iState) { BattleHitStatus status = BattleHitStatus.Normal; switch (iState) { case HitState.Miss: status = BattleHitStatus.Miss; break; case HitState.CriticalDamage: status = BattleHitStatus.Clitical; break; } if (this._clsHougekiModel != null) { UICircleHPGauge circleHPGauge = BattleTaskManager.GetPrefabFile().circleHPGauge; circleHPGauge.SetHPGauge(this._clsHougekiModel.Defender.MaxHp, this._clsHougekiModel.Defender.HpBefore, this._clsHougekiModel.Defender.HpAfter, this._clsHougekiModel.GetDamage(), status, this._clsHougekiModel.Defender.IsFriend()); Vector3 damagePosition = (!this._clsHougekiModel.Defender.IsFriend()) ? new Vector3(280f, -125f, 0f) : new Vector3(-500f, -125f, 0f); circleHPGauge.SetDamagePosition(damagePosition); circleHPGauge.Play(delegate { }); } }
void OnTriggerEnter(Collider col) { if (this.enabled) { if (!firsttimehit) { if (col.gameObject.tag.Equals(GameConstant.KNOB_COL)) { movePositionUp = col.gameObject.GetComponent <KnobController> ().upPosition [1].position; movePositionDown = col.gameObject.GetComponent <KnobController> ().downPosition [1].position; rotationSpeed = 1.8f; curRadiusState = RadiusState.None; curMovementState = MovementState.None; OnMoveUp(); } else if (col.gameObject.tag.Equals(GameConstant.POCKET_COL)) { if (!firsttimehit) { curRadiusState = RadiusState.None; curMovementState = MovementState.None; firsttimehit = true; ballholder = col.gameObject.GetComponent <BallHolder> (); curMovementState = MovementState.JumpUpSide; } } else if (col.gameObject.tag.Equals(GameConstant.OBSTACLE_COL)) { Debug.Log("Obstacle......"); if (curHitState == HitState.Obstacle) { curRadiusState = RadiusState.None; curMovementState = MovementState.CurveMovement; AddRouletteChild(); } if (col.gameObject.name.Equals(GameConstant.OBSTACLE_NAME)) { curHitState = HitState.Obstacle; if (rotationSpeed >= 2f) { reduceSpeedFactor = reduceSpeedFactor * 3.2f; } else if ((rotationSpeed >= 1.5f) && (rotationSpeed < 2f)) { reduceSpeedFactor = reduceSpeedFactor * 2.5f; } else if ((rotationSpeed >= 1f) && (rotationSpeed < 1.5f)) { reduceSpeedFactor = reduceSpeedFactor * 2.0f; } } } else if (col.gameObject.tag.Equals(GameConstant.CONE_COL)) { rigidbody.isKinematic = false; curMovementState = MovementState.InsideSlotMove; } } } }
private void Update() { // Empieza a cargar el bateo if (hitState == HitState.IDLE && Input.GetKeyDown(KeyCode.Space) && Time.time > nextTimeHit) { Debug.Log("Cargando fuerza ..."); hitState = HitState.CHARGING; actualTimeForce = 0.0f; OnCharging?.Invoke(true); //Seleccion de fuerza StartCoroutine(SetForceCoroutine()); } //Cuando se suelta la tecla, se batea else if (hitState == HitState.CHARGING && Input.GetKeyUp(KeyCode.Space)) { //Debug.Log("Fuerza seleccionada. Inicio de bateo."); //Debug.Log("Tiempo tardado: " + actualTimeForce); //Animación bateo hitState = HitState.BALLHIT;//Estado de bateo //la barra no se ve OnCharging?.Invoke(false); // Corrutina tiempo de duración del bateo StartCoroutine(SetInitHitCoroutine()); nextTimeHit = Time.time + timeHit + timeWaitAfterHit; //Tiempo de estar sin poder batear de nuevo la pelota //Debug.Log("Siguiente bateo en: " + nextTimeHit); //Debug.Log(Time.time); } }
/// <summary> /// Corrutina para elegir la fuerza /// </summary> /// <returns></returns> private IEnumerator SetForceCoroutine() { while (hitState == HitState.CHARGING && actualTimeForce < maxForceTime + extraForceTime) { //No se ha llegado al final de la barra de fuerza. Cargando fuerza if (actualTimeForce < maxForceTime) { OnSetttingForce?.Invoke(actualTimeForce / maxForceTime); } //Tiempo extra antes de ser stuneado //else //Debug.Log("Se acaba el tiempo para elegir fuerza!"); actualTimeForce += Time.deltaTime; yield return(new WaitForEndOfFrame()); } if (hitState == HitState.CHARGING && actualTimeForce >= extraForceTime + maxForceTime) { //Debug.Log("Se acabó el tiempo de elegir fuerza. Jugador Stuneado"); hitState = HitState.IDLE; nextTimeHit = Time.time + timeStun; OnCharging?.Invoke(false); } }
public void HandleHitEvent(string from, int damage) { // 이미 죽어있다면 무시 if (myContext.WorldState.AnimState == PlayerContext.DEATH) { return; } HitState hitState = new HitState { From = from, To = myContext.Client.Name, Damage = damage }; myContext.WorldState.Hit = true; myContext.UpdateHitState(hitState); myContext.WorldState.Health -= damage; healthText.text = myContext.WorldState.Health.ToString(); if (myContext.WorldState.Health <= 0) { Debug.Log("Death!!"); myContext.WorldState.DeathPoint++; myContext.WorldState.AnimState = PlayerContext.DEATH; healthText.text = "Death"; killLogMgr.PostKillLog(hitState.From, hitState.To); StartCoroutine(RespawnPlayer(respawnTime)); } }
public JudgeType Judgement(Note destNode, ref float curTime) { /* 노트가 판정선에 도달하는 시간과 현재 지난 시간의 차이를 비교 */ /* 차이가 판정값보다 작다면, 판정 처리 */ float difference = destNode.JudgeTime - curTime; if (difference < 0f) { hitState = HitState.MISS; return(JudgeType.MISS); } else if (difference - GameManager.Instance.PerfectJudgeTime <= Mathf.Epsilon) { hitState = HitState.HIT; return(JudgeType.PERFECT); } else if (difference - GameManager.Instance.GreatJudgeTime <= Mathf.Epsilon) { hitState = HitState.HIT; return(JudgeType.GREAT); } else if (difference - GameManager.Instance.GoodJudgeTime <= Mathf.Epsilon) { hitState = HitState.HIT; return(JudgeType.GOOD); } else { hitState = HitState.IGNORE; return(JudgeType.IGNORE); } }
public static HitState ConvertBattleHitState2HitState(DamageModelBase model) { HitState result = HitState.Miss; if (model == null) { return(result); } BattleHitStatus hitState = model.GetHitState(); if (hitState != BattleHitStatus.Normal) { if (hitState != BattleHitStatus.Clitical) { result = HitState.Miss; } else { if (model.GetGurdEffect()) { } result = HitState.CriticalDamage; } } else { if (model.GetGurdEffect()) { } result = HitState.NomalDamage; } return(result); }
private void SwitchToNotHit() { isHit = false; currentStateTime = 0f; currentHitState = HitState.Normal; player.GetComponent <Animator>().SetBool("Invincible", false); player.GetComponent <Animator>().SetBool("Critical", false); }
// Start is called before the first frame update void Start() { characterController = GetComponent <CharacterController>(); playerController = GetComponent <PlayerController>(); Player.Instance.TakeDamage += DamagedStager; hitState = HitState.None; combatState = PlayerCombatState.None; }
// Test public void ProcessNote(HitState hitState, JudgeType type) { if (type == JudgeType.IGNORE) { return; } UIManager.Instance.UpdateRecord(hitState, type); }
private void UpdateReset() { if (glow <= targetGlow + 1.0f) { hitState = HitState.Ready; return; } glow = Mathf.Lerp(glow, targetGlow, Time.deltaTime * speed); }
// Slash : initial swing // then he starts charging up // if you release the key and the charge is still held, he spins // otherwise he returns to idle ////////////////////////////// UTILITIES ///////////////////////////////// void BeginHit() { currentHitState = HitState.Slash; sound.clip = player.slash; sound.Play(); firstFrame = false; canInterrupt = false; isAction = true; }
public override void OnCollisionEnter(Collider2D other, HitState hitstate) { if (other.Owner is AI) { Chase.doChase = true; } //FIX //if (other.Owner is Bomb) // Chase.doChase = true; }
/// <summary> /// Se comprueba si la bola ha entrado en el trigger de bateo /// Golpea la bola /// </summary> /// <param name="collision"></param> private void OnTriggerEnter2D(Collider2D collision) { Ball ball = collision.GetComponent <Ball>(); //Obtenemos la referencia de la pelota if (ball != null && hitState == HitState.BALLHIT) { ball.Hit(GetForceMultiplier()); hitState = HitState.PLATFORM; OnHit?.Invoke(); } }
private void UpdateHit() { if (glow >= targetGlow - 1.0f) { targetGlow = defaultGlow; hitState = HitState.Reset; return; } glow = Mathf.Lerp(glow, targetGlow, Time.deltaTime * speed); }
public void HitAnimation(HitState hit) { switch (hit) { case HitState.HitGroundFront: anim.SetTrigger("Hit_Ground_Front"); break; case HitState.HitGroundBack: anim.SetTrigger("Hit_Ground_Back"); break; case HitState.DownGroundFront: anim.SetTrigger("Down_Ground_Front"); break; case HitState.DownGroundBack: anim.SetTrigger("Down_Ground_Back"); break; case HitState.HitAirFront: anim.SetTrigger("Hit_Air_Front"); break; case HitState.DownAirFront1: anim.SetTrigger("Down_Air_Front_First"); break; case HitState.DownAirFront2: if (Flat.Instance.GetGround()) { anim.SetTrigger("Down_Air_Front_Second"); } Debug.Log("?2"); break; case HitState.HitAirBack: anim.SetTrigger("Hit_Air_Back"); break; case HitState.DownAirBack1: anim.SetTrigger("Down_Air_Back_First"); break; case HitState.DownAirBack2: if (Flat.Instance.GetGround()) { anim.SetTrigger("Down_Air_Back_Second"); } Debug.Log("?2"); break; } }
public override void Reset() { spinning = poking = slashing = false; currentHitState = HitState.Bye; charge = attackTime = spinTime = 0f; firstFrame = true; moveSpeed = 7f; player.SetIdle(); // When the state is Hit, Player doesn't switch states in FixedUpdate() automatically so // Link continues to hit when the arrow keys are pressed. }
private void OnCollisionEnter(Collision collision) { if (collision.transform.tag == "EnemySword" || collision.transform.tag == "PlayerSword") { hitState = HitState.Blocked; } if (collision.transform.tag == "Player") { GetComponent <Collider>().isTrigger = true; hitState = HitState.Hit; } }
void Combo_CD_animatorPlay(HitState state) { if (!JH_Eff_UI_Combo_CD_Star.activeSelf) { JH_Eff_UI_Combo_CD_Star.SetActive(true); } if (Combo_CD_animator.GetInteger("state") == (int)state) { Combo_CD_animator.SetInteger("state", 0); } Combo_CD_animator.SetInteger("state", (int)state); }
private void OnCollisionStay(Collider2D other, HitState hitState) { bool isWall = Map.GetSwap((int)other.Center.X, (int)other.Center.Y); if (isWall) { int spriteSize = 1; float deadzone = 0.15f; float offset = 0.25f; //Top & Bottom Collision (Player) bool yLeft = collider2D.internalTransform.Position.X <other.internalTransform.Position.X + spriteSize + deadzone && collider2D.internalTransform.Position.X> other.internalTransform.Position.X + spriteSize - offset - deadzone; bool yRight = collider2D.internalTransform.Position.X + spriteSize <other.internalTransform.Position.X + offset + deadzone && collider2D.internalTransform.Position.X + spriteSize> other.internalTransform.Position.X - deadzone; //Left & Right Collision (Player) bool xTop = collider2D.internalTransform.Position.Y <other.internalTransform.Position.Y + spriteSize + deadzone && collider2D.internalTransform.Position.Y> other.internalTransform.Position.Y + spriteSize - offset - deadzone; bool xBottom = collider2D.internalTransform.Position.Y + spriteSize <other.internalTransform.Position.Y + deadzone + offset && collider2D.internalTransform.Position.Y + spriteSize> other.internalTransform.Position.Y - deadzone; float swapDist = 0.05f; if (hitState.normal.Y > 0 && yLeft) { Transform.Position += new Vector2(swapDist, 0f); } else if (hitState.normal.Y > 0 && yRight) { Transform.Position += new Vector2(-swapDist, 0f); } else if (hitState.normal.Y < 0 && yLeft) { Transform.Position += new Vector2(swapDist, 0f); } else if (hitState.normal.Y < 0 && yRight) { Transform.Position += new Vector2(-swapDist, 0f); } else if (hitState.normal.X > 0 && xTop) { Transform.Position += new Vector2(0f, swapDist); } else if (hitState.normal.X > 0 && xBottom) { Transform.Position += new Vector2(0f, -swapDist); } else if (hitState.normal.X < 0 && xTop) { Transform.Position += new Vector2(0f, swapDist); } else if (hitState.normal.X < 0 && xBottom) { Transform.Position += new Vector2(0f, -swapDist); } } }
/// <value> /// Get the color for the given hit state. /// </value> /// <remarks>If there is no color for hitState, the one for HitState.None will be returned.</remarks> public Color GetColor(HitState hitState) { if (colors.ContainsKey(hitState)) return colors[hitState]; else if (hitState.IsSelected() && colors.ContainsKey(HitState.Selected)) return colors[HitState.Selected]; else if (hitState.IsHovering() && colors.ContainsKey(HitState.Hovering)) return colors[HitState.Hovering]; else if (colors.ContainsKey(HitState.None)) return colors[HitState.None]; else return null; }
void EndOfLife(HitState state) { // TODO: initiate feedback then schedule kill all involved objects // TODO: sound effects should be played by game controller since they should play regardless of active state or destroy MeshRenderer mr = m_outcome.GetComponent <MeshRenderer>(); bool emit_particle = false; int score = 0; switch (state) { case HitState.Early: mr.material.mainTexture = m_outcomeMiss; score = GameController.Score_Early; m_gameCont.OnMiss(); break; case HitState.Hit: m_audioSource.clip = m_hitSound; m_audioSource.Play(); mr.material.mainTexture = m_outcomeHit; emit_particle = true; score = GameController.Score_Hit; break; case HitState.Miss: m_audioSource.clip = m_missSound; m_audioSource.Play(); mr.material.mainTexture = m_outcomeMiss; score = GameController.Score_Miss; m_gameCont.OnMiss(); break; case HitState.Perfect: // TODO: Perfect should have a special sound! m_audioSource.clip = m_hitSound; m_audioSource.Play(); mr.material.mainTexture = m_outcomePerfect; emit_particle = true; score = GameController.Score_Perfect; break; } m_gameCont.AddScore(score); m_outcome.SetActive(true); if (emit_particle) { GameObject particle_effect = Instantiate(m_particleFeedback, transform.position, transform.rotation); particle_effect.transform.position = new Vector3(transform.position.x, transform.position.y, 0.5f); // 0.5f is effects front } m_bDone = true; Destroy(gameObject, 1.0f); }
/// <summary> /// Corrutina de tiempo de espera del bateo /// informa al MoonshotManager de que empiece la fase de plataformas /// </summary> /// <returns></returns> IEnumerator SetInitHitCoroutine() { //Se está bateando yield return(new WaitForSeconds(timeHit)); if (hitState != HitState.PLATFORM) { hitState = HitState.IDLE; } else { MoonshotManager.Instance.StartPlatformPhase(); OnHitPhase?.Invoke(false); } }
public void UpdateRecord(HitState hitState, JudgeType type) { if (hitState.Equals(HitState.HIT)) { combo++; ShowCombo(); } else { if (combo > SingletonData.Instance.resultData.maxCombo) { SingletonData.Instance.resultData.maxCombo = combo; } combo = 0; } ShowJudge(type); }
public bool IsColliding(FloorTile floorTile) { if (hitbox.Intersects(floorTile.leftHitbox)) { currentHitState = HitState.left; return true; } else if (hitbox.Intersects(floorTile.rightHitbox)) { currentHitState = HitState.right; return true; } else { return false; } }
public static AudioSource PlayDamageSE(HitState iState, bool isTorpedo) { switch (iState) { case HitState.CriticalDamage: return((!isTorpedo) ? KCV.Utils.SoundUtils.PlaySE(SEFIleInfos.SE_907) : KCV.Utils.SoundUtils.PlaySE(SEFIleInfos.SE_910)); case HitState.Gard: case HitState.NomalDamage: return((!isTorpedo) ? KCV.Utils.SoundUtils.PlaySE(SEFIleInfos.SE_906) : KCV.Utils.SoundUtils.PlaySE(SEFIleInfos.SE_909)); case HitState.Miss: return(KCV.Utils.SoundUtils.PlaySE(SEFIleInfos.SE_908)); default: return(null); } }
public void Int() { DeAttachedChild(); curRadiusState = RadiusState.InitialDecRadius; curHitState = HitState.None; transform.position = startPosition; curMovementState = MovementState.Normal; outerRadius = 1.67f; rotationSpeed = 3.4f; reduceSpeedFactor = rotationSpeed / 350f; slotInsideMovementSpeed = 1f; timer = 0f; tempTimer = 0f; angle = 0; initialMovementTime = Random.Range(10f, 15f); rigidbody = this.GetComponent <Rigidbody> (); hitPoint = 2f; firsttimehit = false; }
private void UpdateWorldState(WorldState worldState) { if (worldState.ClntName != myContext.Client.Name) { GameObject player = playerMap[worldState.ClntName].Player; Text healthText = player.transform.GetChild(1).GetChild(0).GetComponent <Text>(); playerMap[worldState.ClntName].UpdateTransform(worldState.Transform); playerMap[worldState.ClntName].WorldState.Health = worldState.Health; playerMap[worldState.ClntName].WorldState.KillPoint = worldState.KillPoint; playerMap[worldState.ClntName].WorldState.DeathPoint = worldState.DeathPoint; playerMap[worldState.ClntName].WorldState.AnimState = worldState.AnimState; if (worldState.AnimState == PlayerContext.DEATH) { healthText.text = "Death"; } else { healthText.text = worldState.Health.ToString(); } if (worldState.Fired) { Transform firePos = player.transform.GetChild(0); GameObject _bullet = Instantiate(pfBullet, firePos.position, firePos.rotation); _bullet.GetComponent <BulletCtrl>().Shooter = worldState.ClntName; Debug.Log(_bullet.GetComponent <BulletCtrl>().Shooter); } if (worldState.Hit && worldState.AnimState == PlayerContext.DEATH) { HitState hitState = worldState.HitState; killLogMgr.PostKillLog(hitState.From, hitState.To); if (hitState.From == myContext.Client.Name) { //만약 내가 죽였다면, kill point 올리기 myContext.WorldState.KillPoint++; } } } }
/// <summary> /// Forcably sets the hit state. /// </summary> /// <remarks>This should only be done if you know what you're doing. /// Otherwise, use IsHovering, IsSelected, etc.</remarks> public virtual void SetHitState(object sender, HitState newVal) { _hitState = newVal; }
/// <summary> /// Renders a rectangular background portion of a control. /// </summary> protected virtual void FillRectangle(Coord relPos, Coord size, Corner rounded, FillType fillType, HitState hitState, AnchorLocation location) { var point = Context.Push(); var coord = new Coord(point.X + relPos.X, point.Y + relPos.Y); switch (fillType) { case FillType.Background: Context.Cairo.Pattern = GenerateGradient(coord, size, location, GetColor(ColorType.BackgroundStart, hitState), GetColor(ColorType.BackgroundStop, hitState)); break; case FillType.Editable: Context.Cairo.Pattern = GenerateGradient(coord, size, location, GetColor(ColorType.EditableStart, hitState), GetColor(ColorType.EditableStop, hitState)); break; case FillType.Highlight: Context.Cairo.Pattern = GenerateGradient(coord, size, location, GetColor(ColorType.HighlightStart, hitState), GetColor(ColorType.HighlightStop, hitState)); break; case FillType.Selection: Context.Cairo.Color = SelectionColor.ToCairo(); break; } // draw the rectangle Context.Cairo.Operator = Cairo.Operator.Source; RectanglePath(coord.Round + 1, size.Floor - 2, rounded); Context.Cairo.Fill(); Context.Pop(); }
private void Hit( HitState state ) { _hitState = state; _hitTime = DateTime.Now; GameContent.GetSound( "hit" ).Play( ); }
/// <summary> /// Gets called whenever the hit state of the renderable changes. /// </summary> private void OnHitStateChanged(object sender, HitState oldVal) { if (HitStateChanged != null && oldVal != HitState) HitStateChanged(sender, new HitStateChangedEvent(oldVal, HitState, this)); }
/// <summary> /// Sets the hovering state on a region (and unsets it on the other one). /// </summary> protected void Hover(Region region) { if (region == Region.Button1) { if ((HitState1 &= HitState.Hovering) == 0) // wasn't hovering before MakeDirty(); HitState1 |= HitState.Hovering; HitState2 &= ~HitState.Hovering; } else if (region == Region.Button2) { if ((HitState2 &= HitState.Hovering) == 0) // wasn't hovering before MakeDirty(); HitState2 |= HitState.Hovering; HitState1 &= ~HitState.Hovering; } else // nothing is hovering { HitState1 &= ~HitState.Hovering; HitState2 &= ~HitState.Hovering; } }
/// <summary> /// Selects the given region (and deselects the other one). /// </summary> public void Select(Region region) { Select(); if (region == Region.Button1) { HitState1 |= HitState.Selected; HitState2 &= ~HitState.Selected; } else if (region == Region.Button2) { HitState2 |= HitState.Selected; HitState1 &= ~HitState.Selected; } else // nothing is selected { HitState1 &= ~HitState.Selected; HitState2 &= ~HitState.Selected; } }
/// <value> /// Get the color for the given hit state. /// </value> public Color this[HitState hitState] { get {return GetColor(hitState);} set {SetColor(hitState, value);} }
public override void Deselect() { base.Deselect(); HitState1 &= ~HitState.Selected; HitState2 &= ~HitState.Selected; }
public void SwitchToInvincible() { currentHitState = HitState.Invincible; player.GetComponent<Animator>().SetBool("Invincible", true); }
private void SwitchToCritical() { currentHitState = HitState.Critical; player.GetComponent<Animator>().SetBool("Invincible", false); player.GetComponent<Animator>().SetBool("Critical", true); }
// met à jour la collision dans la structure liée à la caméra private void UpdateHitState(Camera cam, HitState state,Vector3 position) { Ray ray = cam.ScreenPointToRay (position); state.m_collision = Physics.Raycast(ray, out state.m_hit,cam.farClipPlane, state.m_layerMask.value); }
public void Hit(Unit source) { if (isHit || isInvunerable) { return; } this.health--; if (this.health < 0) { this.Die(); return; } ResetTongue(); isHit = true; jumping = false; falling = false; fallCount = 0.0; jumpCount = 0.0; if (source.location.X > this.location.X) { //hit left this.currentHitState = HitState.hitLeft; } else { //hit right this.currentHitState = HitState.hitRight; } }
/// <summary> /// Returns the color associated with the given type and hit state. /// </summary> public Color GetColor(ColorType colorType, HitState hitState) { return GetColorGroup(colorType).GetColor(hitState); }
/// <summary> /// Renders a triangle portion of a control. /// </summary> protected virtual void FillTriangle(Coord size, HitState hitState, AnchorLocation triDirection, AnchorLocation gradDirection) { var point = Context.Push(); // Create the gradient Cairo.LinearGradient grad = GenerateGradient(point.Coord(), size / 2.0, gradDirection, GetColor(ColorType.BackgroundStart, hitState), GetColor(ColorType.BackgroundStop, hitState)); // draw the triangle Context.Cairo.Operator = Cairo.Operator.Source; Context.Cairo.Pattern = grad; switch (triDirection) { case AnchorLocation.NE: Context.Cairo.RelLineTo(size.X, 0); Context.Cairo.RelLineTo(0, size.Y); break; case AnchorLocation.NW: Context.Cairo.RelLineTo(size.X, 0); Context.Cairo.RelLineTo(-size.X, size.Y); break; case AnchorLocation.SE: Context.Cairo.MoveTo(size.X, 0); Context.Cairo.RelLineTo(0, size.Y); Context.Cairo.RelLineTo(-size.X, 0); break; case AnchorLocation.SW: Context.Cairo.RelLineTo(0, size.Y); Context.Cairo.RelLineTo(size.X, 0); break; case AnchorLocation.N: Context.Cairo.RelMoveTo(0, size.Y); Context.Cairo.RelLineTo(size.X, 0); Context.Cairo.RelLineTo(-size.X/2.0, size.Y); break; case AnchorLocation.E: Context.Cairo.RelLineTo(0, size.Y); Context.Cairo.RelLineTo(size.X, -size.Y/2.0); break; case AnchorLocation.S: Context.Cairo.RelLineTo(size.X, 0); Context.Cairo.RelLineTo(-size.X/2.0, size.Y); break; case AnchorLocation.W: Context.Cairo.RelMoveTo(size.X, 0); Context.Cairo.RelLineTo(0, size.Y); Context.Cairo.RelLineTo(-size.X, -size.Y/2.0); break; default: throw new Exception(triDirection.ToString() + " is currently not a valid triangle location"); } Context.Cairo.Fill(); Context.Pop(); }
/// <summary> /// Outlines a rectangle with the given size. /// </summary> /// <param name="relPos"> /// The relative position of the rectangle. /// </para> /// <param name="size"> /// The size of the rectangle to outline (assumed to be at 0,0 origin). /// </param> /// <param name="hitState"> /// Used to look up which color to use for the stroke. /// </param> protected virtual void StrokeRectangle(Coord relPos, Coord size, Corner rounded, HitState hitState) { var point = Context.Push(); var coord = new Coord(point.X + relPos.X, point.Y + relPos.Y).HalfCeiling; // draw the rectangle Context.Cairo.Operator = Cairo.Operator.Source; Context.Cairo.Color = GetColor(ColorType.Stroke, hitState).ToCairo(); if (hitState.IsFocused()) Context.Cairo.LineWidth = 2 * StrokeWidth; else Context.Cairo.LineWidth = StrokeWidth; RectanglePath(coord, size.Floor-1, rounded); Context.Cairo.Stroke(); Context.Pop(); }
private void SwitchToNotHit() { isHit = false; currentStateTime = 0f; currentHitState = HitState.Normal; player.GetComponent<Animator>().SetBool("Invincible", false); player.GetComponent<Animator>().SetBool("Critical", false); }
public object Update( KeyboardState keyboard, MouseState mouseState, bool newMouseLeftClick, bool newMouseRightClick, double secondsElapsed ) { if (keyboard.IsKeyDown( Keys.A ) && keyboard.IsKeyDown( Keys.W )) { MoveStraight( Vector2.Normalize(new Vector2(-1f,-1f)), secondsElapsed ); } else if (keyboard.IsKeyDown( Keys.W ) && keyboard.IsKeyDown( Keys.D )) { MoveStraight( Vector2.Normalize( new Vector2( 1f, -1f ) ), secondsElapsed ); } else if (keyboard.IsKeyDown( Keys.D ) && keyboard.IsKeyDown( Keys.S )) { MoveStraight( Vector2.Normalize( new Vector2( 1f, 1f ) ), secondsElapsed ); } else if (keyboard.IsKeyDown( Keys.A ) && keyboard.IsKeyDown( Keys.S )) { MoveStraight( Vector2.Normalize( new Vector2( -1f, 1f ) ), secondsElapsed ); } else if (keyboard.IsKeyDown( Keys.A )) { MoveStraight( Vector2.UnitX * -1f, secondsElapsed ); } else if (keyboard.IsKeyDown( Keys.D )) { MoveStraight( Vector2.UnitX, secondsElapsed ); } else if (keyboard.IsKeyDown( Keys.W )) { MoveStraight( Vector2.UnitY * -1f, secondsElapsed ); } else if (keyboard.IsKeyDown( Keys.S )) { MoveStraight( Vector2.UnitY, secondsElapsed ); } _targetPos = new Vector2( mouseState.X, mouseState.Y ); if (_hitState == HitState.None1 && newMouseRightClick) { Hit( HitState.LeftHand ); } else if (_hitState == HitState.LeftHand && IsHitOld) { _hitState = HitState.None2; } else if (_hitState == HitState.None2 && newMouseRightClick) { Hit( HitState.RightHand ); } else if (_hitState == HitState.RightHand && IsHitOld) { _hitState = HitState.None1; } if (mouseState.LeftButton == ButtonState.Pressed && ( DateTime.Now - _lastBulletShoot ).TotalSeconds > RELOAD_SECONDS) { return ShootBullet( ); } else { return null; } }