protected override void Start() { root = new Sequence(); seqDeath = new Sequence(); inAttackRange = new InAttackRange(this); isDead = new IsDead(this); death = new Death(this); base.Start(); Init(); StartCoroutine("BehaviorProcess"); //inst_Character = CharacterManager.getInstance(); //target = inst_Character.GetComponent<Transform>(); raidMonster = true; skillSet[0] = 1; skillSet[1] = 2; skillSet[2] = 3; skillSet[3] = 4; skillSet[4] = 5; currentHP = maxHP; currentSkill = 0; }
/// <summary> /// Смерть персонажа /// </summary> /// <param name="animation">анимация смерти</param> /// <param name="rebound">отскок персонажа</param> public void DamageToCharacter(bool animation, bool rebound) { if (_character.Life) { _character.Life = false; _character.Rigidbody.velocity = Vector2.zero; if (animation) { _character.SetAnimation(Character.Animations.Dead); _character.SetSound(Character.Sounds.Dead); _character.PlayingSound.PlaySound(); _character.PolygonCollider.isTrigger = true; } if (rebound) { _character.Rigidbody.AddForce(new Vector2(UnityEngine.Random.Range(-135, -100) * _character.Transform.localScale.x, UnityEngine.Random.Range(160, 190))); _character.BloodEffect.Play(); } IsDead?.Invoke(); } }
// Use this for initialization void Start() { wanderDir = UnityEngine.Random.value < .5f; Observable.Timer(TimeSpan.FromSeconds(UnityEngine.Random.value), TimeSpan.FromSeconds(.8f)) .Do(_ => CheckDestroy()) .Where(_ => CurHp > 0) .SelectMany(_ => { if (!target.Value) { return(Wander()); } var tgtdir = target.Value.transform.position.x < transform.position.x ? Dir.left : Dir.right; return(CanMoveTo(tgtdir) ? Move(tgtdir, .5f) : Attack(tgtdir, .4f, .2f)); }) .TakeUntil(IsDead.Where(x => x)) .Subscribe() .AddTo(this); m_sensor.OnTriggerEnterAsObservable() .Select(c => c.GetComponent <GameCharacter>()) .Where(x => x && x.faction != faction) .Subscribe(other => { target.Value = other; }) .AddTo(this); }
public string ToString(string format, IFormatProvider formatProvider) { switch (format) { case null: case "N": return(ToString()); case "I": return(Id.ToString()); case "NA": return(Name); case "PC": return(PeopleCount.ToString()); case "B": return(Birthyear.ToString()); case "ID": return(IsDead.ToString()); case "C": return(Country); case "All": return(String.Format("#ID:{0}\tName:{1}\tPeople Count:{2}\tBirthyear:{3}\tIsDead:{4}\tCountry:{5}", Id, Name, PeopleCount, Birthyear, IsDead, Country)); default: throw new FormatException(String.Format("Format {0} not supported", format)); } }
public void PlayerHit(int Damage) { Streak = 0; HP -= Damage; if (HP <= 0) { HP = 0; Died = true; IsDead?.Invoke(this, this); } }
private void Start() { var blockInput = false; SwipeControl.Direction .Where(_ => !blockInput) .SelectMany(dir => { blockInput = true; if (CanMoveTo(dir)) { return(Move(dir, .5f)); } SoundController.Play("swing"); return(Attack(dir, .2f, .2f)); }) .TakeUntil(IsDead.Where(x => x)) .Subscribe(_ => blockInput = false) .AddTo(this); Rb.OnCollisionEnterAsObservable() .Select(x => x.collider.GetComponent <ICollisionTriggerable>()) .Where(x => x != null) .Subscribe(ctr => ctr.Trigger()) .AddTo(this); //botkill reward and sound var botkillObs = target .Where(x => x) .Select(tgt => tgt.IsDead.Where(x => x).Take(1)) .Switch() .Do(_ => { Money.Current += GameController.Instance.botKillReward; }) .Publish(); var thr = botkillObs.Throttle(TimeSpan.FromSeconds(1.4f)); botkillObs.Buffer(thr) .Where(x => x.Count > 1) .Subscribe(_ => SoundController.Play("botkill")) .AddTo(this); botkillObs.Connect().AddTo(this); }
/* * Function: GetState * ---------------------------- * A method to get the current state of the game, which is then transmitted to the server * * return: a string containing the current state of the game * */ private string GetState() { string state = ""; //Get current state state += EnemyTeamFlagInSight().ToString(); state += " " + FriendlyTeamFlagInSight().ToString(); state += " " + IsDamaged.ToString(); state += " " + HasFlag.ToString(); state += " " + IsDead.ToString(); state += " " + FriendlyFlagTaken.ToString(); state += " " + EnemyFlagTaken.ToString(); state += " " + NumbEnemiesSpotted(); state += " " + GetAgentLowHealth().ToString(); state += " " + LowestHealthEnemyHigherThanAgent().ToString(); state += " " + TotalEnemyHealthHigherThanAgent().ToString(); //state += " " + IsMyTeamWinning().ToString(); return(state); }
override protected void Start() { root = new Sequence(); seqDeath = new Sequence(); seqChase = new Sequence(); seqAttack = new Sequence(); selMove = new Selector(); selChase = new Selector(); patrol = new Patrol(this); isDead = new IsDead(this); death = new Death(this); inSight = new InSight(this); chase = new Chase(this); isDamaged = new IsDamaged(this); inAttackRange = new InAttackRange(this); attack = new Attack(this); base.Start(); Init(); StartCoroutine("BehaviorProcess"); }
public bool IsDeadByDammage(int dammage) { _healthBar.Health -= dammage; Color = Color.Red; SpriteText dmg = new SpriteText(_contentManager.Load <SpriteFont>("Fonts/Font")) { Position = new Vector2(Position.X + Rectangle.Width / 2 - 20, Position.Y - 20), Text = dammage.ToString(), LifeTime = 50 }; _dammageTakenList.Add(dmg); if (_healthBar.Health < 0) { IsDead.Invoke(this, new EventArgs()); return(true); } else { return(false); } }
public override int GetHashCode() { int hash = 1; if (X != 0F) { hash ^= X.GetHashCode(); } if (Y != 0F) { hash ^= Y.GetHashCode(); } if (Vx != 0F) { hash ^= Vx.GetHashCode(); } if (Vy != 0F) { hash ^= Vy.GetHashCode(); } if (Rotation != 0F) { hash ^= Rotation.GetHashCode(); } if (Omega != 0F) { hash ^= Omega.GetHashCode(); } if (InitLife != 0F) { hash ^= InitLife.GetHashCode(); } if (Life != 0F) { hash ^= Life.GetHashCode(); } if (Scale != 0F) { hash ^= Scale.GetHashCode(); } if (Alpha != 0F) { hash ^= Alpha.GetHashCode(); } if (Mass != 0F) { hash ^= Mass.GetHashCode(); } if (IsDead != false) { hash ^= IsDead.GetHashCode(); } if (ColorR != 0F) { hash ^= ColorR.GetHashCode(); } if (ColorG != 0F) { hash ^= ColorG.GetHashCode(); } if (ColorB != 0F) { hash ^= ColorB.GetHashCode(); } if (CurrentAnimationFrame != 0) { hash ^= CurrentAnimationFrame.GetHashCode(); } return(hash); }
private void Start() { IsDead.AsObservable() .Where(x => x); }