// Use this for initialization void Start() { ATK_text = GameObject.Find("ATK").GetComponent <Text>(); DPS_text = GameObject.Find("DPS").GetComponent <Text>(); SPD_text = GameObject.Find("SPD").GetComponent <Text>(); playerBuff = GameObject.Find("Player").GetComponent <PlayerBuff>(); }
private void AbortBuffInternal(PlayerBuff buff) { if (Buffs.Contains(buff)) { buff.End(); Buffs.Remove(buff); } }
// Use this for initialization void Start() { anim = GetComponent <Animator>(); playerRigidbody = GetComponent <Rigidbody>(); playerSkill = GetComponent <PlayerSkill>(); playerBuff = GetComponent <PlayerBuff>(); floorMask = LayerMask.GetMask("Floor"); }
public void EndBuff(PlayerBuff buff) { PlayerBuff oldBuff = playerBuffs.FirstOrDefault(o => o.BuffName == buff.BuffName); if (oldBuff != null) { oldBuff.EndBuff(); } }
public void AddPlayerBuff(PlayerBuff playerBuff) { if (this.playerBuff != null) { this.playerBuff.Destroy(); } this.playerBuff = playerBuff; }
private void ProcessBuffs() { PlayerBuff buff = null; while (Buffs.Any() && (buff = Buffs.Last()).ToEnd < Mathf.Epsilon) { buff.End(); Buffs.Remove(buff); } }
public int CheckBuff(PlayerBuff a) { foreach (PlayerBuff b in currentPlayerBuff) { if (b.ToString().Equals(a.ToString())) { return(currentPlayerBuff.IndexOf(b)); } } return(-1); }
public void PushEffect(PlayerBuff buff) { if (buff) { ToBuff.Add(buff); } else { Debug.LogError("Tried to push null buff!", this); } }
private static float SkillBuffModifier(Skill.Type type, float amount) { if (PlayerBuff.HasBuff <Productive>()) { var statIncModifier = new StatIncreaseArgs(amount); PlayerBuff.GetBuff <Productive>()?.TakeEffect(statIncModifier); amount = statIncModifier.Amount; } return(amount); }
public void AbortBuff(PlayerBuff buff) { if (buff) { BuffsToAbort.Add(buff); } else { Debug.LogError("Tried to abort null buff!", this); } }
public PlayerBuff Clone() { PlayerBuff buff = new PlayerBuff(); buff.BuffName = BuffName; buff.attribute = attribute; buff.BuffAbsAmount = BuffAbsAmount; buff.BuffAbsPerLevelAmount = BuffAbsPerLevelAmount; buff.BuffRelAmount = BuffRelAmount; buff.BuffRelPerLevelAmount = BuffRelPerLevelAmount; buff.BuffRunTime = BuffRunTime; return(buff); }
// Use this for initialization void Awake() { anim = GetComponent <Animator>(); playerAudio = GetComponent <AudioSource>(); playerMovement = GetComponent <PlayerMovement>(); playerShooting = GetComponentInChildren <PlayerShooting>(); playerBuff = GetComponent <PlayerBuff>(); playerDie = GameObject.Find("You_Die").GetComponent <YouDie>(); damageText = Resources.Load("Prefabs/UI/DamageText") as GameObject; clear = GameObject.Find("Clear").GetComponent <Clear>(); cuurenthealth = startinghealth; }
IEnumerator Co_AddBuff(SideEffectExecute buffSee, int buffId) { PlayerBuff pb = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.PlayerBuff].AllocateGameObject <PlayerBuff>(Content); AudioManager.Instance.SoundPlay("sfx/OnBuffAdd", 0.5f); pb.SetRotation(ClientPlayer.WhichPlayer); pb.Init(buffSee, buffId); PlayerBuffs.Add(buffId, pb); yield return(new WaitForSeconds(0.2f * BattleEffectsManager.AnimationSpeed)); BattleEffectsManager.Instance.Effect_Main.EffectEnd(); yield return(null); }
public override void Drain(float timeScale) { float multiplier = (GameLibOfMethods.isSleeping) ? 0.5f : 1; float drainAmount = data.drainPerHour * timeScale * multiplier; if (PlayerBuff.HasBuff <Suppression>()) { var statModifier = new StatDecreaseArgs(drainAmount); PlayerBuff.GetBuff <Suppression>()?.TakeEffect(statModifier); drainAmount = statModifier.Amount; } Add(drainAmount); }
private List <string> HandlePlayerBuff(GameState gameState, PlayerBuff buff) { switch (buff.BuffId) { case (int)BuffId.Healing: return(HealPlayer(gameState)); case (int)BuffId.OnFire: return(PlayerOnFire(gameState)); default: return(new List <string>()); } }
public override void Use() { CurrentAction.ApplyStatsOnUse(); if (shouldCancel && !PlayerBuff.HasBuff <DeepSleep>()) { FinishUsing(true); } else if (!CurrentAction.ValidateStats()) { useState = ObjectUseState.Preparation; GameClock.ResetSpeed(); ExitAfterDelay(false); } }
public void GainNewBuff(PlayerBuff newBuff, int stack) { if (CheckBuff(newBuff) == -1) { currentPlayerBuff.Add(newBuff); newBuff.ActivateBuff(); newBuff.GainStack(stack - 1); UpdateBuffDisplay(); } else { currentPlayerBuff[CheckBuff(newBuff)].GainStack(stack); UpdateBuffDisplay(); } }
// Use this for initialization void Start() { shootablemask = LayerMask.GetMask("Shootable"); gunAudio = GetComponent <AudioSource>(); gunParticle = GetComponent <ParticleSystem>(); gunLine = GetComponent <LineRenderer>(); gunLight = GetComponent <Light>(); playerBuff = GameObject.Find("Player").GetComponent <PlayerBuff>(); if (Application.loadedLevelName == "BattleRoom") { enemy_Player = GameObject.Find("EnemyPlayer").GetComponent <EnemyPlayerInfo>(); } }
public bool CreatePlayerBuff(PlayerBuff playerBuff) { outpostwarsEntities entities = new outpostwarsEntities(); try { // Add tew New Player into the player Collection entities.PlayerBuffs.Add(playerBuff); // Save changes return(entities.SaveChanges() == 1); } catch (DbEntityValidationException ex) { LogCriticalError(ex); } return(false); }
public override void Interact() { var result = TrySetCurrentAction("Sleep"); if (result) { if (PlayerBuff.HasBuff <Insomnia>()) { PlayerChatLog.Instance.AddChatMessege("I can't sleep."); return; } BeginUsing(); } else { result.PrintErrorMessage(); } }
public void AddBuff(PlayerBuff buff) { PlayerBuff oldBuff = playerBuffs.FirstOrDefault(o => o.BuffName == buff.BuffName); PlayerBuff newBuff = null; if (oldBuff == null) { newBuff = buff.Clone(); playerBuffs.Add(newBuff); } else { newBuff = oldBuff; } if (newBuff != null) { newBuff.StartBuff(this); } }
public virtual void Finish() { foreach (Skill.Type type in RequiredSkills.Keys) { Stats.AddXP(type, XPbonus); } WorkedToday = true; var salary = WagePerHour * (float)System.TimeSpan.FromSeconds(JobManager.Instance.CurrentWorkingTime).TotalHours; if (PlayerBuff.HasBuff <Motivated>()) { var statIncrease = new StatIncreaseArgs(salary); PlayerBuff.GetBuff <Motivated>()?.TakeEffect(statIncrease); salary = statIncrease.Amount; } Stats.AddMoney(salary); }
void StartSpell(GameObject spell, bool isFacingLeft) { GameObject tempSpell = InstantiateGameObject(spell); if (tempSpell.GetComponent <PlayerWeapon>() != null) { if (isFacingLeft) { tempSpell.GetComponent <PlayerWeapon>().Setup(leftDir); } else { tempSpell.GetComponent <PlayerWeapon>().Setup(rightDir); } } else if (tempSpell.GetComponent <PlayerBuff>() != null) { PlayerBuff tempBuff = tempSpell.GetComponent <PlayerBuff>(); tempBuff.Setup(); if (tempBuff.invulDuration > 0) { isInvul = true; invulEndTime = Time.timeSinceLevelLoad + tempBuff.invulDuration; // Update HUD gameManager.StartInvulDurationAnim(tempBuff.invulDuration); } if (tempBuff.fasterSpeedDuration > 0) { isFaster = true; fasterEndTime = Time.timeSinceLevelLoad + tempBuff.fasterSpeedDuration; playerController.ApplySpeedBuff(tempBuff.speedMultiplier); // When the player animator animates slide, it will call the SetToSlideOffset() in PlayerBuffs cript playerAnimator.AddPlayerBuff(tempBuff); } } }
private static float StatBuffModifier(Status.Type type, float amount) { switch (type) { case Status.Type.Mood when amount > 0 && PlayerBuff.HasBuff <Freedom>(): var statIncModifier = new StatIncreaseArgs(amount); PlayerBuff.GetBuff <Freedom>()?.TakeEffect(statIncModifier); amount = statIncModifier.Amount; break; case Status.Type.Health when PlayerBuff.HasBuff <Suppression>(): { var statDecModifier = new StatDecreaseArgs(amount); PlayerBuff.GetBuff <Suppression>()?.TakeEffect(statDecModifier); amount = statDecModifier.Amount; break; } } return(amount); }
IEnumerator <float> JumpOffFromBed(bool cancel) { Player.anim.SetBool("Sleeping", false); yield return(0f); while (true) { var state = Player.anim.GetCurrentAnimatorStateInfo(0); if (!state.IsName("JumpOffToBed")) { Debug.Log("Something is wrong.. this finished before firing the method. Make sure you don't call this from FixedUpdate."); break; } if (state.normalizedTime >= 40 / 50f) { break; } yield return(0f); } //Covers.sortingOrder = 0; HandlePlayerSprites(enable: true); void action() { Player.col.enabled = true; //SpriteControler.Instance.ChangeSortingOrder(0); //Covers.sortingOrder = 0; GameLibOfMethods.player.transform.parent.transform.parent = null; PlayerBuff.Remove <DeepSleep>(); } PlayerCommands.JumpOff(useableFunctionality.CustomSpeedToPosition, action); //try { FinishUsing(cancel); } //catch { Debug.Log("TODO: Fix error on bed after animations btw."); } }
public IEnumerator <float> GradualUse() { float t = 0; float GetProgress() => (t += GameTime.Time.deltaTime) / UsageTime; void ApplyGradualBonusGains() { Stats.Status(Type.Hunger).Add((Stats.Status(Type.Hunger).MaxAmount *HungerPercentBonus) / UsageTime * Time.deltaTime); Stats.Status(Type.Energy).Add((Stats.Status(Type.Energy).MaxAmount *EnergyPercentBonus) / UsageTime * Time.deltaTime); Stats.Status(Type.Health).Add((Stats.Status(Type.Health).MaxAmount *HealthPercentBonus) / UsageTime * Time.deltaTime); Stats.Status(Type.Mood).Add((Stats.Status(Type.Mood).MaxAmount *MoodPercentBonus) / UsageTime * Time.deltaTime); Stats.Status(Type.Thirst).Add((Stats.Status(Type.Thirst).MaxAmount *ThirstPercentBonus) / UsageTime * Time.deltaTime); } void ApplyGradualStatGains() { Stats.Status(Type.Hunger).Add((Hunger / UsageTime) * Time.deltaTime); Stats.Status(Type.Energy).Add((Energy / UsageTime) * Time.deltaTime); Stats.Status(Type.Health).Add((Health / UsageTime) * Time.deltaTime); Stats.Status(Type.Mood).Add((Mood / UsageTime) * Time.deltaTime); Stats.Status(Type.Thirst).Add((Thirst / UsageTime) * Time.deltaTime); Stats.Status(Type.Bladder).Add((Bladder / UsageTime) * Time.deltaTime); } while (GetProgress() < 1 && !cancel) { ApplyGradualBonusGains(); ApplyGradualStatGains(); yield return(0f); } PlayerBuff.GetRandomBuff(); yield return(0f); }
private void OnBuffsChanged() { var currentBuffs = PlayerBuff.GetAll(); for (int i = 0; i < currentBuffs.Count; i++) { if (_buffs.Count < i + 1) { _buffs.Add(Instantiate(buffItem, transform).Initialize(currentBuffs[i])); } else { _buffs[i].Initialize(currentBuffs[i]); } } if (_buffs.Count > currentBuffs.Count) { for (int i = currentBuffs.Count; i < _buffs.Count; i++) { _buffs[i].Disable(); } } }
private void PushBuffInternal(PlayerBuff buff) { buff.Init(this); buff.Begin(); Buffs.Add(buff); }
public void ApplyPlayerBuff(PlayerBuff buff, GameObject target) { StartCoroutine(StartBuff(buff, target)); }
IEnumerator StartBuff(PlayerBuff buff, GameObject target) { Vector3 startScale = target.transform.localScale; target.transform.localScale = buff.EnlargePlayerSize; print("buffed"); var stats = target.GetComponent <combat>(); float startD = stats.dmgBase; float startA = stats.armor; float startR = stats.rangedBaseDmg; stats.dmgBase += buff.DamageBoost; stats.armor += buff.ArmorBoost; stats.rangedBaseDmg += buff.RangedDamageBoost; var movement = target.GetComponent <Movement>(); float startSpeed = movement.max_spd; movement.SetMaxSpeed(buff.MovementSpeedBoost); // movement. if (buff.CanCutTrees) { float increment = buff.Duration / _checkRate; LayerMask mask = LayerMask.GetMask("ObjectLayer"); for (int i = 0; i < _checkRate; i++) { var colliders = Physics2D.CircleCastAll(target.transform.position, buff.CuttingRadius, Vector2.zero, 0f, mask); if (colliders != null) { foreach (var collider in colliders) { if (collider.transform.CompareTag("puu")) { collider.transform.parent.gameObject.GetComponent <Resource>().Hit(100); // .Vibrate(); } } } yield return(new WaitForSeconds(increment)); } } else { yield return(new WaitForSeconds(buff.Duration)); } movement.SetMaxSpeed(startSpeed); stats.dmgBase -= buff.DamageBoost; stats.armor -= buff.ArmorBoost; stats.rangedBaseDmg -= buff.RangedDamageBoost; Debug.LogFormat("alku: {0}, {1}, {2} loppu: {3}, {4}, {5}", startD, startA, startR, stats.dmgBase, stats.armor, stats.rangedBaseDmg); target.transform.localScale = startScale; Destroy(this); }