public Game1() { var graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; ScreenRectangle = new Rectangle(0, 0, 1280, 720); graphics.PreferredBackBufferWidth = ScreenRectangle.Width; graphics.PreferredBackBufferHeight = ScreenRectangle.Height; var gameStateManager = new GameStateManager(this); Components.Add(gameStateManager); this.IsMouseVisible = true; TitleIntroState = new TitleIntroState(this); StartMenuState = new MainMenuState(this); GamePlayState = new GamePlayState(this); ConversationState = new ConversationState(this); BattleState = new BattleState(this); BattleOverState = new BattleOverState(this); DamageState = new DamageState(this); LevelUpState = new LevelUpState(this); // begin game at TitleIntroState gameStateManager.ChangeState((TitleIntroState)TitleIntroState, PlayerIndex.One); CharacterManager = CharacterManager.Instance; }
public virtual void Damage(float dmg) { if (HealthState != DamageState.Invulnerable) { CurrentHp -= dmg; if (HealthRatio > 0.8f) { HealthState = DamageState.Great; } else if (HealthRatio > 0.5f) { HealthState = DamageState.Good; } else if (HealthRatio > 0.25f) { HealthState = DamageState.Bad; } else if (HealthRatio > 0) { HealthState = DamageState.Terrible; } else { CurrentHp = 0; HealthState = DamageState.Broken; Equipped = false; Destroy(); } } }
public void ShowDamage(int damage, Color textColor) { damageText.text = damage.ToString(); damageText.color = textColor; Reset(); damageState = DamageState.SizeUp; }
/// <summary> /// 初始化伤害系统数据,当系统类型为NONE时将按照自定义内容。 /// </summary> private void InitDamageSystem() { switch (curType) { case DamageSystemType.NONE: break; case DamageSystemType.BOSS: maxHealth = 90000; firstPeriodHealth = 60000; secondPeriodHealth = 30000; break; case DamageSystemType.MONSTER: maxHealth = 40; firstPeriodHealth = 0; secondPeriodHealth = 0; break; case DamageSystemType.TOWER: maxHealth = 300; firstPeriodHealth = 200; secondPeriodHealth = 100; break; } curHealth = maxHealth; curState = DamageState.FIRSTPERIOD; }
/// <summary> /// 刷新当前伤害系统状况。 /// </summary> private void CheckHealth() { if (isProtect) { curState = DamageState.PROTECT; return; } if (curHealth <= 0) { curHealth = 0; curState = DamageState.DEATH; return; } else if (curHealth <= secondPeriodHealth) { curState = DamageState.THIRDPERIOD; return; } else if (curHealth <= firstPeriodHealth) { curState = DamageState.SECONDPERIOD; return; } else if (curHealth <= maxHealth) { curState = DamageState.FIRSTPERIOD; return; } }
public static string NormalizeSequence(Animation anim, DamageState state, string sequence) { var states = new Pair <DamageState, string>[] { Pair.New(DamageState.Critical, "critical-"), Pair.New(DamageState.Heavy, "damaged-"), Pair.New(DamageState.Medium, "scratched-"), Pair.New(DamageState.Light, "scuffed-") }; // Remove existing damage prefix foreach (var s in states) { if (sequence.StartsWith(s.Second)) { sequence = sequence.Substring(s.Second.Length); break; } } foreach (var s in states) { if (state >= s.First && anim.HasSequence(s.Second + sequence)) { return(s.Second + sequence); } } return(sequence); }
public virtual void UpdateDamage(DamageState state) { switch (state) { case DamageState.Normal: _uiDamageMask.alpha = 0f; _uiDamageIcon.alpha = 0f; break; case DamageState.Shouha: _uiDamageMask.alpha = 1f; _uiDamageIcon.alpha = 1f; _uiDamageMask.spriteName = "icon-ss_burned_shoha"; _uiDamageIcon.spriteName = "icon-ss_shoha"; break; case DamageState.Tyuuha: _uiDamageMask.alpha = 1f; _uiDamageIcon.alpha = 1f; _uiDamageMask.spriteName = "icon-ss_burned_chuha"; _uiDamageIcon.spriteName = "icon-ss_chuha"; break; case DamageState.Taiha: _uiDamageMask.alpha = 1f; _uiDamageIcon.alpha = 1f; _uiDamageMask.spriteName = "icon-ss_burned_taiha"; _uiDamageIcon.spriteName = "icon-ss_taiha"; break; } }
private void setEscapeData(IEnumerable <Mem_ship> ships, IEnumerable <Mem_ship> enableTowShips) { List <int> list = new List <int>(); List <int> list2 = new List <int>(); using (IEnumerator <Mem_ship> enumerator = ships.GetEnumerator()) { while (enumerator.MoveNext()) { Mem_ship current = enumerator.get_Current(); if (current.IsFight()) { DamageState damageState = current.Get_DamageState(); bool flag = Enumerable.Contains <Mem_ship>(enableTowShips, current); if (damageState == DamageState.Taiha) { list.Add(current.Rid); } else if (damageState == DamageState.Normal && current.Stype == 2 && flag) { list2.Add(current.Rid); } } } } if (list.get_Count() > 0 && list2.get_Count() > 0) { this.EscapeShips = list; this.TowShips = list2; } }
private void InitStateMachine() { blackboard = new StateBlackboard(); blackboard.Add <bool>(BlackboardKey.DamageFlag, false); blackboard.Add <bool>(BlackboardKey.RepeatDamageFlag, false); blackboard.Add <Transform>(BlackboardKey.Transform, transform); blackboard.Add <float>(BlackboardKey.AttackRange, 0f); EnemyIdleState idleState = EnemyIdleState.Create(blackboard, animator, "Idle", 0); StateNode idleNode = new StateNode(idleState, new Condition(() => { return(true); })); SetAnimTriggerAction walkAction = new SetAnimTriggerAction(blackboard, animator, "Run"); MeleeAttackState meleeAttackState = MeleeAttackState.Create(blackboard, animator, navAgent, attackValidator.MeleeAttacks, transform, BlackboardKey.AttackRange, BlackboardKey.AnimTrigger, walkAction, 300); StateNode attackNode = new StateNode(meleeAttackState, new Condition(() => { return(target != null); })); DamageState damageState = DamageState.Create(blackboard, animator, "Damage", 500); StateNode damageNode = new StateNode(damageState, new Condition(() => { return(blackboard.Get <bool>(BlackboardKey.DamageFlag)); })); DeathState deathState = DeathState.Create(blackboard, animator, "Death", int.MaxValue); StateNode deathNode = new StateNode(deathState, new Condition(() => { return(!self.IsAlive); })); List <StateNode> nodes = new List <StateNode>(); nodes.Add(idleNode); nodes.Add(attackNode); nodes.Add(damageNode); nodes.Add(deathNode); stateMachine = new StateMachine(blackboard, nodes, idleState); }
public static string NormalizeSequence(Animation anim, DamageState state, string sequence) { var states = new Pair<DamageState, string>[] { Pair.New(DamageState.Critical, "critical-"), Pair.New(DamageState.Heavy, "damaged-"), Pair.New(DamageState.Medium, "scratched-"), Pair.New(DamageState.Light, "scuffed-") }; // Remove existing damage prefix foreach (var s in states) { if (sequence.StartsWith(s.Second)) { sequence = sequence.Substring(s.Second.Length); break; } } foreach (var s in states) if (state >= s.First && anim.HasSequence(s.Second + sequence)) return s.Second + sequence; return sequence; }
public static void SetMaxHitCount(this IDamageableComponent damageable, int newMaxHitCount) { DamageState damageState = damageable.GetDamageState(); damageState.MaxHits = newMaxHitCount; damageable.SetDamageState(damageState); }
private void OnCollisionCheck() { var pos = Holder.Transform.position + Utils.GetAngularOffset(Holder.Direction, 0.5f); Collider2D[] hits = Physics2D.OverlapBoxAll(pos, new Vector2(1f, 0.5f), 0, 1 << 9); foreach (var col in hits) { var tidmg = col.GetComponent <IDamaged>(); if (tidmg != null && tidmg.HitType == HitType.Enemy) { var state = new DamageState { Damage = Holder.Stats.atk + Stats.atk, DamageType = 0, Getter = tidmg.GameObject.GetComponent <ICharacterObject>(), Sender = Holder, KnockBack = 1f, }; if (OnHit(state)) { tidmg.GetHit(state); } } } }
public void ChangeDamageState(DamageState nextState) { if (nextState == currentDamageState) { return; } currentDamageState = nextState; if (nextState == DamageState.Malfunction) { ObjectManager.Instance.GameManager.PanelBroken(this); RegenerateWireSlots(); OpenGate(); } if (nextState == DamageState.Destroyed) { ObjectManager.Instance.GameManager.PanelDestroyed(this); RegenerateWireSlots(); } if (nextState == DamageState.Operational) { ObjectManager.Instance.GameManager.PanelMadeOperational(this); CloseGate(); } }
public virtual void InitState() { { State state = new IdleState(); state.Init(this); _stateMap[eStateType.IDLE] = state; } { State state = new MoveState(); state.Init(this); _stateMap[eStateType.MOVE] = state; } { State state = new AttackState(); state.Init(this); _stateMap[eStateType.ATTACK] = state; } { State state = new DamageState(); state.Init(this); _stateMap[eStateType.DAMAGE] = state; } { State state = new DeathState(); state.Init(this); _stateMap[eStateType.DEATH] = state; } _state = _stateMap[eStateType.IDLE]; }
protected override void OnActionStateUpdate() { if (innerTimer > 1f * attackTime) { InteractState = InteractState.EndInteract; } if (innerTimer > 0.5f * attackTime) { if (_showRange != null) { _showRange.Dispose(); _showRange = null; var state = new DamageState { Damage = Stats.atk, DamageType = 0, Getter = PlayerBehaviour.Instance, Sender = this, KnockBack = 1f, }; if (this.TargetInRangeAngle(PlayerBehaviour.Instance, attackRange, Direction)) { PlayerBehaviour.Instance.GetHit(state); } } } else { var yVelocity = 1.5f - 1.5f * (innerTimer * 4f / attackTime); Transform.GetChild(0).localPosition += new Vector3(0f, 1f, 2f) * (yVelocity * Time.deltaTime); } }
private void setEscapeData(IEnumerable <Mem_ship> ships, IEnumerable <Mem_ship> enableTowShips) { List <int> list = new List <int>(); List <int> list2 = new List <int>(); foreach (Mem_ship ship in ships) { if (ship.IsFight()) { DamageState damageState = ship.Get_DamageState(); bool flag = enableTowShips.Contains(ship); switch (damageState) { case DamageState.Taiha: list.Add(ship.Rid); break; case DamageState.Normal: if (ship.Stype == 2 && flag) { list2.Add(ship.Rid); } break; } } } if (list.Count > 0 && list2.Count > 0) { EscapeShips = list; TowShips = list2; } }
virtual protected void InitState() { { State state = new IdleState(); state.Init(this); _stateMap[eStateType.IDLE] = state; } { State state = new MoveState(); state.Init(this); _stateMap[eStateType.MOVE] = state; } { State state = new AttackState(); state.Init(this); _stateMap[eStateType.ATTACK] = state; } { State state = new DamageState(); state.Init(this); _stateMap[eStateType.DAMAGE] = state; } { State state = new DeadState(); state.Init(this); _stateMap[eStateType.DEAD] = state; } _state = _stateMap[eStateType.IDLE]; }
public override void OnChangeData(AppearanceComponent component) { base.OnChangeData(component); var sprite = component.Owner.GetComponent <ISpriteComponent>(); if (!component.TryGetData(DamageStateVisuals.State, out DamageState data)) { return; } if (_data == data) { return; } _data = data; if (_stateMap.TryGetValue(_data, out var state)) { sprite.LayerSetState(DamageStateVisualLayers.Base, state); } // So they don't draw over mobs anymore if (_data == DamageState.Dead) { _originalDrawDepth = sprite.DrawDepth; sprite.DrawDepth = (int)DrawDepth.FloorObjects; } else if (_originalDrawDepth != null) { sprite.DrawDepth = _originalDrawDepth.Value; _originalDrawDepth = null; } }
public void RemoveWakeUpMove(DamageState damageState) { int index = (int)damageState; WakeupMoves[index] = null; StartPositions[index] = TauntStartPosition.FaceDown; EndPositions[index] = TauntEndPosition.Standing; }
public void AddWakeUpMove(Skill skill, DamageState damageState) { int index = (int)damageState; WakeupMoves[index] = skill; StartPositions[index] = GetStartPosition((SkillID)skill.SkillID); EndPositions[index] = GetEndPosition((SkillID)skill.SkillID); }
// Update is called once per frame void Update() { Vector3 objScale = this.transform.localScale; switch (m_damageState) { // 拡大中 case DamageState.Big: { objScale.x += m_speed * Time.deltaTime; objScale.y += m_speed * Time.deltaTime; // 元の大きさになったら if (objScale.x > m_saveScale.x) { // 遷移 m_damageState = DamageState.Wait; // 上限設定 objScale = m_saveScale; } } break; // 止める case DamageState.Wait: { m_time += Time.deltaTime; // 一定時間たったら遷移 if (m_time > m_dispTime) { m_damageState = DamageState.Small; //m_scoreScript.DownCount(5); } } break; // 縮小中 case DamageState.Small: { objScale.x -= m_smallSpeed * Time.deltaTime; objScale.y -= m_smallSpeed * Time.deltaTime; // 小さくなったら遷移 if (objScale.x <= 0.0f) { objScale.x = 0.0f; objScale.y = 0.0f; m_damageState = DamageState.None; } } break; } this.transform.localScale = objScale; }
protected virtual int getRaigAttackValue(Mem_ship atk_ship, List <Mst_slotitem> atk_slot, Mem_ship def_ship) { int num = 150; BattleFormationKinds1 formation; BattleFormationKinds2 battleFormation; List <int> list; if (!atk_ship.IsEnemy()) { formation = this.F_Data.Formation; battleFormation = this.F_Data.BattleFormation; list = this.F_Data.SlotLevel.get_Item(this.F_SubInfo.get_Item(atk_ship.Rid).DeckIdx); BattleFormationKinds1 formation2 = this.E_Data.Formation; } else { formation = this.E_Data.Formation; battleFormation = this.E_Data.BattleFormation; list = this.E_Data.SlotLevel.get_Item(this.E_SubInfo.get_Item(atk_ship.Rid).DeckIdx); BattleFormationKinds1 formation2 = this.F_Data.Formation; } double num2 = 0.0; using (var enumerator = Enumerable.Select(atk_slot, (Mst_slotitem obj, int idx) => new { obj, idx }).GetEnumerator()) { while (enumerator.MoveNext()) { var current = enumerator.get_Current(); num2 += this.getSlotPlus_Attack(current.obj, list.get_Item(current.idx)); } } double num3 = this.valance1 + (double)atk_ship.Raig + num2; double formationParamBattle = this.formationData.GetFormationParamBattle(FormationDatas.GetFormationKinds.RAIGEKI, battleFormation); double formationParamF = this.formationData.GetFormationParamF1(FormationDatas.GetFormationKinds.RAIGEKI, formation); num3 = num3 * formationParamBattle * formationParamF; DamageState damageState = atk_ship.Get_DamageState(); double num4 = 1.0; if (damageState == DamageState.Tyuuha) { num4 = 0.8; } else if (damageState == DamageState.Taiha) { num4 = 0.0; } num3 *= num4; if (num3 > (double)num) { num3 = (double)num + Math.Sqrt(num3 - (double)num); } return((int)num3); }
public override void Initialize() { base.Initialize(); CurrentDamageState = DamageState.Alive; CurrentMobState = Behavior[CurrentDamageState]; CurrentMobState.EnterState(Owner); CurrentMobState.UpdateState(Owner); }
public MobStateChangedEvent( MobStateComponent component, DamageState?oldMobState, DamageState currentMobState) { Component = component; OldMobState = oldMobState; CurrentMobState = currentMobState; }
public void SetDamageState(DamageState damageState) { //entityPublisher.SetDamageState(damageState); DamageState = damageState; if (DamageStateChanged != null) { DamageStateChanged(damageState); } }
protected override void EnterState(DamageState state) { base.EnterState(state); if (state == DamageState.Dead) { PerformDestruction(); } }
private void InitStateMachine() { blackboard = new StateBlackboard(); blackboard.Add(BlackboardKey.AttackingFlag, false); blackboard.Add(BlackboardKey.NextAttackFlag, false); blackboard.Add(BlackboardKey.SkillFlag, false); blackboard.Add(BlackboardKey.DamageFlag, false); blackboard.Add(BlackboardKey.RepeatDamageFlag, false); blackboard.Add(BlackboardKey.AnimTrigger, string.Empty); blackboard.Add <Transform>(BlackboardKey.Target, null); blackboard.Add <Vector3>(BlackboardKey.MoveDirection, Vector3.zero); SetAnimTriggerAction setIdleTriggerAction = new SetAnimTriggerAction(blackboard, animator, "Idle"); LookAtTargetAction lookAtAction = new LookAtTargetAction(blackboard, transform); PlayerIdleState idleState = new PlayerIdleState(blackboard, setIdleTriggerAction, lookAtAction); StateNode idleNode = new StateNode(idleState, new Condition(() => { return(true); })); SetAnimTriggerAction setRunTriggerAction = new SetAnimTriggerAction(blackboard, animator, "Move"); SetMoveDirectionAction setMoveDirAction = new SetMoveDirectionAction(blackboard, transform, Camera.main.transform); MoveControllerAction moveControllerAction = new MoveControllerAction(blackboard, GetComponent <CharacterController>(), runSpeed); PlayerMoveState moveState = new PlayerMoveState(blackboard, setRunTriggerAction, setMoveDirAction, moveControllerAction, 100); StateNode moveNode = new StateNode(moveState, new Condition(() => { float horizontal = inputController.GetRuntimeInputConfig().GetBinding(InputBindingName.GAMEPLAY_HORIZONTAL).Value; float vertical = inputController.GetRuntimeInputConfig().GetBinding(InputBindingName.GAMEPLAY_VERTICAL).Value; return(Mathf.Abs(horizontal) > InputConstants.INPUT_DEAD_ZONE || Mathf.Abs(vertical) > InputConstants.INPUT_DEAD_ZONE); })); SetAnimTriggerAction setAttackTrigger = new SetAnimTriggerAction(blackboard, animator, "Attack", true); SetAnimTriggerAction setNextAttackTrigger = new SetAnimTriggerAction(blackboard, animator, "NextAttack", true); PlayerAttackState attackState = new PlayerAttackState(blackboard, setAttackTrigger, setNextAttackTrigger, lookAtAction, 500); StateNode attackNode = new StateNode(attackState, new Condition(() => { return(blackboard.Get <bool>(BlackboardKey.AttackingFlag) == true); })); SetAnimTriggerAction setSkillTrigger = new SetAnimTriggerAction(blackboard, animator, BlackboardKey.AnimTrigger, true); PlayerSkillState skillState = new PlayerSkillState(blackboard, setSkillTrigger, 400); StateNode skillNode = new StateNode(skillState, new Condition(() => { return(blackboard.Get <bool>(BlackboardKey.SkillFlag) == true); })); SetAnimTriggerAction damageAction = new SetAnimTriggerAction(blackboard, animator, "Damage", true); DamageState damageState = new DamageState(blackboard, damageAction, 600); Condition damageCondition = new Condition(() => { return(blackboard.Get <bool>(BlackboardKey.DamageFlag)); }); StateNode damageNode = new StateNode(damageState, damageCondition); DeathState deathState = DeathState.Create(blackboard, animator, "Die", int.MaxValue); StateNode deathNode = new StateNode(deathState, new Condition(() => { return(!self.IsAlive); })); List <StateNode> nodes = new List <StateNode>(); nodes.Add(idleNode); nodes.Add(moveNode); nodes.Add(attackNode); nodes.Add(skillNode); nodes.Add(damageNode); nodes.Add(deathNode); stateMachine = new StateMachine(blackboard, nodes, idleState); }
protected virtual int getRaigAttackValue(Mem_ship atk_ship, List <Mst_slotitem> atk_slot, Mem_ship def_ship) { int num = 150; BattleFormationKinds1 formation; BattleFormationKinds2 battleFormation; List <int> list; if (!atk_ship.IsEnemy()) { formation = F_Data.Formation; battleFormation = F_Data.BattleFormation; list = F_Data.SlotLevel[F_SubInfo[atk_ship.Rid].DeckIdx]; BattleFormationKinds1 formation2 = E_Data.Formation; } else { formation = E_Data.Formation; battleFormation = E_Data.BattleFormation; list = E_Data.SlotLevel[E_SubInfo[atk_ship.Rid].DeckIdx]; BattleFormationKinds1 formation3 = F_Data.Formation; } double num2 = 0.0; foreach (var item in atk_slot.Select((Mst_slotitem obj, int idx) => new { obj, idx })) { num2 += getSlotPlus_Attack(item.obj, list[item.idx]); } double num3 = valance1 + (double)atk_ship.Raig + num2; double formationParamBattle = formationData.GetFormationParamBattle(FormationDatas.GetFormationKinds.RAIGEKI, battleFormation); double formationParamF = formationData.GetFormationParamF1(FormationDatas.GetFormationKinds.RAIGEKI, formation); num3 = num3 * formationParamBattle * formationParamF; DamageState damageState = atk_ship.Get_DamageState(); double num4 = 1.0; switch (damageState) { case DamageState.Tyuuha: num4 = 0.8; break; case DamageState.Taiha: num4 = 0.0; break; } num3 *= num4; if (num3 > (double)num) { num3 = (double)num + Math.Sqrt(num3 - (double)num); } return((int)num3); }
public void ShowDamage(int damage, Color textColor) { //컬러가 먼저 바뀌면 텍스트 내용이 바뀌어도 적용되지만 //반대로 텍스트 내용이 먼저 바뀌고 색이 바뀌면 최초에는 적용이 안된다. -> 현재에는 잘된다? damageText.text = damage.ToString(); damageText.color = textColor; Reset(); //display -> sizeup damageState = DamageState.SizeUp; }
void AggregateDamageState(Bridge b, int d, ref DamageState damage) { if (b.health.DamageState > damage) { damage = b.health.DamageState; } if (b.Hut == null && d >= 0 && b.neighbours[d] != null) { AggregateDamageState(b.neighbours[d], d, ref damage); } }
/// <summary> /// ダメージエフェクト表示 /// </summary> public void DispDamage(int num) { if (m_damageState == DamageState.None) { m_damageState = DamageState.Big; m_time = 0.0f; // 減らす数値 m_text.text = "-" + num.ToString(); } }
public static string NormalizeSequence(Animation anim, DamageState state, string sequence) { // Remove any existing damage prefix sequence = UnnormalizeSequence(sequence); foreach (var s in DamagePrefixes) if (state >= s.First && anim.HasSequence(s.Second + sequence)) return s.Second + sequence; return sequence; }
public static string NormalizeSequence(Animation anim, DamageState state, string baseSequence) { var states = new Pair<DamageState, string>[] { Pair.New(DamageState.Critical, "critical-"), Pair.New(DamageState.Heavy, "damaged-"), Pair.New(DamageState.Medium, "scratched-"), Pair.New(DamageState.Light, "scuffed-") }; foreach (var s in states) if (state >= s.First && anim.HasSequence(s.Second+baseSequence)) return s.Second+baseSequence; return baseSequence; }
/// <summary> /// Constructor for a Base /// </summary> /// <param name="color">The team color of the base</param> /// <param name="position">The position to place the base at</param> /// <param name="eventId">The event ID of the base</param> /// <param name="_model">The model of the base.</param> public Base(GameSession.Alliance color, Vector3 position, int eventId, Model _model) : base(_model, position) { this.originalOwner = color; this.BaseColor = color; this.Position = position; this.eventId = eventId; this.health = Constants.MAX_BASE_HEALTH; this.destroyed = false; previousDamageState = DamageState.None; ParticleEmitter0 = new ParticleEmitter("DamagedBaseFire"); ParticleEmitter1 = new ParticleEmitter("DamagedBaseFire"); ParticleEmitter2 = new ParticleEmitter("DamagedBaseFire"); ParticleEmitter3 = new ParticleEmitter("DamagedBaseFire"); StopEmitters(); ServiceManager.Scene.Add(ParticleEmitter0, 3); ServiceManager.Scene.Add(ParticleEmitter1, 3); ServiceManager.Scene.Add(ParticleEmitter2, 3); ServiceManager.Scene.Add(ParticleEmitter3, 3); }
public void Hurt(float damage, GameObject attacker) { //Don't take damage if we are stunned if (stunAge > 0f) return; if (dashing && attacker.layer == LayerMask.NameToLayer("Enemy")) return; health.value -= damage; if (health.value <= 0) { this.Die(); } else { damageState = DamageState.STUNNED; stunAge = stunCooldown; } }
/// <summary> /// Set fires on the base depending on its damage state. /// </summary> public void SetEmitters() { if (this.DamageStatus == DamageState.Minor) { if (previousDamageState != this.DamageStatus) { ParticleEmitter0.Attach(this, "Emitter0"); ParticleEmitter0.Emitting = true; //In the case of an incrementing DamageState, we need to ensure the other emitters // are off. ParticleEmitter1.Emitting = false; ParticleEmitter2.Emitting = false; ParticleEmitter3.Emitting = false; } } else if (this.DamageStatus == DamageState.Moderate) { if (previousDamageState != this.DamageStatus) { ParticleEmitter1.Attach(this, "Emitter2"); ParticleEmitter1.Emitting = true; ParticleEmitter2.Emitting = false; ParticleEmitter3.Emitting = false; } } else if (this.DamageStatus == DamageState.Critical) { if (previousDamageState != this.DamageStatus) { ParticleEmitter2.Attach(this, "Emitter3"); ParticleEmitter3.Attach(this, "Emitter1"); ParticleEmitter2.Emitting = true; ParticleEmitter3.Emitting = true; } } if (previousDamageState != this.DamageStatus) { previousDamageState = this.DamageStatus; } }
// 啟動(需要外部關閉) public void Start() { EnableRenderer( true ) ; m_State = DamageState.Active ; }
public override void Damage(int attackPower, float magnification) { base.Damage(attackPower, magnification); animator.SetTrigger(isDamageID); currentState = new DamageState(this); }
// 一定時間啟動 public void StartByTime( float _ElapsetedTime ) { Start() ; m_State = DamageState.ActiveByTime ; m_CountDownTrigger.Setup( _ElapsetedTime ) ; m_CountDownTrigger.Rewind() ; }
// 關閉 public void Stop() { m_State = DamageState.NonActive ; if( true == IsDestroyAtEnd ) { if( null != m_EffectObj.GetObj() ) GameObject.Destroy( m_EffectObj.Obj ) ; m_EffectObj.Name = "" ; } else { // do not release just turn it off EnableRenderer( false ) ; } }
/// <summary> /// Updates the beam ship /// </summary> /// <param name="elapsedTime">The in-game time between the previous and current frame</param> public override void Update(float elapsedTime) { // Sense the player's position PlayerShip player = ScrollingShooterGame.Game.Player; Vector2 playerPosition = new Vector2(player.Bounds.Center.X, player.Bounds.Center.Y); if (timer > 0) timer -= elapsedTime; switch (behaviorState) { case BehaviorState.Flying: this.position += velocityY * elapsedTime; if (timer < 0) { if (this.position.X >= playerPosition.X - 23 && this.position.X <= playerPosition.X + 23 && this.position.Y < playerPosition.Y) { timer = 1f; behaviorState = BehaviorState.Charging; } } break; case BehaviorState.Charging: weaponFiring = true; if(timer < .9) behaviorState = BehaviorState.Firing; break; case BehaviorState.Firing: if (weaponAlive) { ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.BlueBeam, new Vector2(this.position.X + weaponFireOffset.X + 1, this.position.Y + weaponFireOffset.Y + 8)); weaponFiring = false; behaviorState = BehaviorState.Flying; } else behaviorState = BehaviorState.Fleeing; break; case BehaviorState.Fleeing: this.position += velocityY * elapsedTime; if (position.X >= ScrollingShooterGame.Game.GraphicsDevice.Viewport.Bounds.Center.X) this.position += velocityX * elapsedTime; else this.position -= velocityX * elapsedTime; break; case BehaviorState.Fragged: //the code for the ship dying will go here break; } switch (damageState) { case DamageState.Healthy: if (weaponHealth <= 0) { weaponAlive = false; damageState = DamageState.WeaponBroke; behaviorState = BehaviorState.Fleeing; } break; case DamageState.WeaponBroke: if (shipHealth <= 0) { damageState = DamageState.Dead; behaviorState = BehaviorState.Fragged; } break; case DamageState.Dead: shipAlive = false; //need code for dead ship break; } drawBounds[(int)BeamShipParts.Body] = new Rectangle((int)position.X, (int)position.Y, spriteBounds[(int)BeamShipParts.Body].Width, spriteBounds[(int)BeamShipParts.Body].Height); drawBounds[(int)BeamShipParts.Weapon] = new Rectangle((int)(position.X + weaponOffset.X), (int)(position.Y + weaponOffset.Y), spriteBounds[(int)BeamShipParts.Weapon].Width, spriteBounds[(int)BeamShipParts.Weapon].Height); drawBounds[(int)BeamShipParts.WeaponFire] = new Rectangle((int)(position.X + weaponFireOffset.X), (int)(position.Y + weaponFireOffset.Y), spriteBounds[(int)BeamShipParts.WeaponFire].Width, spriteBounds[(int)BeamShipParts.WeaponFire].Height); }
/// <summary> /// Creates a new instance of an enemy beam ship /// </summary> /// <param name="content">A ContentManager to load resources with</param> /// <param name="position">The position of the beam ship in the game world</param> public BeamShip(uint id, ContentManager content, Vector2 position) : base(id) { this.position = position; weaponAlive = true; shipAlive = true; weaponFiring = false; behaviorState = BehaviorState.Flying; damageState = DamageState.Healthy; velocityY = new Vector2(0, 35); velocityX = new Vector2(80, 0); timer = -1; spritesheet = content.Load<Texture2D>("Spritesheets/newsh2.shp.000000"); //load the body of the craft from the spritesheet spriteBounds[(int)BeamShipParts.Body].X = 100; spriteBounds[(int)BeamShipParts.Body].Y = 55; spriteBounds[(int)BeamShipParts.Body].Width = 37; spriteBounds[(int)BeamShipParts.Body].Height = 28; drawBounds[(int)BeamShipParts.Body] = new Rectangle((int)position.X, (int)position.Y, spriteBounds[(int)BeamShipParts.Body].Width, spriteBounds[(int)BeamShipParts.Body].Height); //load the weapon for the craft from the sprite sheet spriteBounds[(int)BeamShipParts.Weapon].X = 107; spriteBounds[(int)BeamShipParts.Weapon].Y = 84; spriteBounds[(int)BeamShipParts.Weapon].Width = 24; spriteBounds[(int)BeamShipParts.Weapon].Height = 28; drawBounds[(int)BeamShipParts.Weapon] = new Rectangle((int)(position.X + weaponOffset.X), (int)(position.Y + weaponOffset.Y), spriteBounds[(int)BeamShipParts.Weapon].Width, spriteBounds[(int)BeamShipParts.Weapon].Height); //load the weapon's fire animation from the sprite sheet beamSpriteSheet = content.Load<Texture2D>("Spritesheets/newsh(.shp.000000"); spriteBounds[(int)BeamShipParts.WeaponFire].X = 13; spriteBounds[(int)BeamShipParts.WeaponFire].Y = 70; spriteBounds[(int)BeamShipParts.WeaponFire].Width = 11; spriteBounds[(int)BeamShipParts.WeaponFire].Height = 11; drawBounds[(int)BeamShipParts.WeaponFire] = new Rectangle((int)(position.X + weaponFireOffset.X), (int)(position.Y + weaponFireOffset.Y), spriteBounds[(int)BeamShipParts.WeaponFire].Width, spriteBounds[(int)BeamShipParts.WeaponFire].Height); }
public void Respawn() { //goto spawn point gameObject.transform.position = spawnPoint; health.value = 100f; damageState = DamageState.STUNNED; stunAge = stunCooldown; hmdRig.GetComponent<QoobitOVR>().Realign(gameObject.transform.position,facing); }
public void Die() { if (damageState == DamageState.DEAD) return; velocity.x = velocity.z = 0f; heroAudio.Play(HeroAudio.Clip.DEATH); damageState = DamageState.DEAD; GameControl.control.lives--; /* if (GameControl.control.lives == 0) { //game over } else { */ //Respawn(); /* } */ }
// Update is called once per frame override protected void Update() { base.Update(); GetComponent<CharacterController>().Move(velocity * Time.deltaTime); //Debug.Log(GameObject.Find("Focal").transform.localPosition+" "+ GameObject.Find("Focal").transform.position); ((FistBlaster)weapon.GetComponent<Weapon>()).bulletReloadTime = 0.01f; ((FistBlaster)weapon.GetComponent<Weapon>()).clipReloadTime = 0f; weapon.GetComponent<Weapon>().weaponFireMode = (int)BlasterMode.STRAIGHT; //update viewers hmdForward = Camera.main.transform.forward; hmdForward.y = 0f; hmdForward.Normalize(); //Debug.Log(GetComponent<CharacterController>().isGrounded); if (platform != null) { jumpAllowed = true; } if (GetComponent<CharacterController>().isGrounded) { dashAllowed = true; velocity.y = 0; } else { platform = null; //jumpAllowed = false; if (!dashing) { if (scaling) { //apply gravity velocity.y += gravity *0.5f* Time.deltaTime; } else { //apply gravity velocity.y += gravity * Time.deltaTime; } } else { velocity.y = 0f; } } if (velocity.y < -terminalVelocity) velocity.y = -terminalVelocity; if (velocity.y > terminalVelocity) velocity.y = terminalVelocity; //blink stunned hero if (damageState == DamageState.STUNNED) { SetSkinnedMeshRendererEnabled(gameObject,!Root.transform.GetChild(0).GetComponent<SkinnedMeshRenderer>().enabled); stunAge -= Time.deltaTime; if (stunAge <= 0f) { damageState = DamageState.HEALTHY; SetSkinnedMeshRendererEnabled(gameObject, true); } } if (damageState != DamageState.DEAD) { applyInputsToCharacter(); } }