public void Load() { PlayerController controller = GameManager.Player; PlayerInventory inventory = controller.inventory; Alive alive = controller.alive; GameManager.Player.gameObject.transform.position = this.PlayerPosition; inventory.SetGold(this.PlayerGold, ShopCoin.Gold); inventory.SetGold(this.PlayerSecret, ShopCoin.Secret); if (ActiveItem.itemObj != null) { inventory.EquipItem(this.ActiveItem); } if (PassiveItem.itemObj != null) { inventory.EquipItem(this.PassiveItem); } if (WeaponItem.itemObj != null) { inventory.EquipItem(this.WeaponItem); } inventory.OverrideInventory(this.Items); controller.canDash = this.CanDash; controller.canTeleport = this.CanTeleport; controller.canExplode = this.CanExplode; controller.canWallJump = this.CanWalljump; alive.OverrideHealth(this.Health); }
void ExecuteAttack(Alive a, bool ignoreCooldown, bool ignoreSlow = false, int customDamage = 0) { if (!ignoreCooldown && actCoolDown != 0) { return; } if (!ignoreCooldown) { ApplyCooldown(); } if (!ignoreSlow) { ApplySlow(); } bool received = a.TakeDamage(customDamage == 0 ? Damage : customDamage, this.gameObject); if (a.TryGetComponent <Motor>(out Motor m) && received) { float height = m.WallColliderSize.y / 2; Vector2 playerPos = (Vector2)a.transform.position + new Vector2(0, height); Vector2 direction = ((Vector2)transform.position - playerPos).normalized * -1; direction += new Vector2(0, 0.5f); Force f = new Force(pushForce); f.ForceApplied = direction * pushForce.ForceToApply; f.ActualForce = direction * pushForce.ForceToApply; m.AddForce(f, false, true, true); } }
public IEnumerator Cast(Image img) { castingFinished = false; Alive tempCardTarget = parentDeck.Owner.target; castingInterrupted = false; parentDeck.Owner.UseResource(resourceCost); parentDeck.Owner.casting = true; parentDeck.Owner.CooldownManagement.TriggerCardCooldownOnDeck(cardName); parentDeck.Owner.CooldownManagement.TriggerGcdOnDeck(); float time = 0; float speed = 1f; while ((time < castTime) && (CheckConditionsWhileCasting(tempCardTarget))) { yield return(null); time += speed * Time.deltaTime; img.fillAmount = (time / castTime); if (!CheckConditionsWhileCasting(tempCardTarget)) { castingInterrupted = true; } } img.fillAmount = 0f; if (!castingInterrupted) { Play(tempCardTarget); } castingFinished = true; parentDeck.Owner.casting = false; }
public void MakeTurn() { foreach (var creature in Alive.Where(c => c != Player)) { creature.MakeAutoTurn(); } foreach (var projectile in _projectiles) { projectile.Move(); var projectileRect = projectile.ToRectangle(); foreach (var creature in Alive.Where(creature => projectile.Side != creature.Side && Geometry.CheckRectangleIntersection(projectileRect, creature.ToRectangle()))) { creature.TakeDamage(projectile.Damage); projectile.Collide(); break; } foreach (var dummy in Walls.Where(wall => Geometry.CheckRectangleIntersection(wall.ToRectangle(), projectileRect))) { projectile.Collide(); } } _projectiles.RemoveWhere(p => p.Live <= 0); _aliveCreatures.RemoveWhere(c => !c.IsAlive); Player.MakeTurn(PlayersTurn); PlayersTurn = Turn.None; }
void StartRound(List <Player> players) { TimeSpan duration = Map.Config.RoundTime; Map.Message("This round will last for &a" + duration.Shorten(true, true)); RoundEnd = DateTime.UtcNow.Add(duration); Player[] online = PlayerInfo.Online.Items; foreach (Player p in online) { if (p.level != Map || p.Game.Referee) { continue; } Alive.Add(p); } Infected.Clear(); Random rnd = new Random(); Player first = null; do { first = QueuedZombie != null?PlayerInfo.FindExact(QueuedZombie) : players[rnd.Next(players.Count)]; QueuedZombie = null; } while (first == null || first.level != Map); Map.Message("&c" + first.DisplayName + " &Sstarted the infection!"); InfectPlayer(first, null); }
private void Heartbeat() { Alive alive = new Alive(); this.Transmit(alive.Serialize()); Scheduler.Schedule(this.thread, Job.Create(new Action(this.Heartbeat)), new TimeSpan(0, 0, 30)); }
void OnTargetLost(Alive target) { if (!IsDead() && (target != null)) { walker.Hunt(target); } }
private IEnumerator HuntCoroutine(Alive target) { Transform attackableSpot; if (huntRandomAttackSpot) { attackableSpot = target.GetRandomAttackableSpot(); } else { attackableSpot = target.GetClosestAttackableSpot(myTr.position); } //while ( hunting && !IsCloseEnough(attackableSpot.position + personalOffset) ) { while (hunting && (target != null) && !IsCloseToFight(target.transform.position)) { WalkTo(attackableSpot.position + personalOffset); yield return(new WaitForSeconds(.5f)); } StopWalk(); if (hunting) { SendMessage("OnHuntDone", target, SendMessageOptions.DontRequireReceiver); hunting = false; } }
public void ClearOwner() { hBar.gameObject.SetActive(false); rBar.gameObject.SetActive(false); buffFrame.gameObject.SetActive(false); owner = null; }
public void ResetState() { Status = ZombieGameStatus.NotStarted; MaxRounds = 0; RoundInProgress = false; RoundStart = DateTime.MinValue; RoundEnd = DateTime.MinValue; Player[] online = PlayerInfo.Online.Items; Alive.Clear(); Infected.Clear(); Lottery.Clear(); Bounties.Clear(); RecentMaps.Clear(); foreach (Player pl in online) { pl.Game.Referee = false; pl.Game.RatedMap = false; pl.Game.ResetZombieState(); ResetInvisibility(pl); pl.SetPrefix(); if (pl.level == null || !pl.level.name.CaselessEq(CurLevelName)) { continue; } HUD.Reset(pl); } LastLevelName = ""; CurLevelName = ""; CurLevel = null; }
public override void PlayerLeftServer(Player p) { Alive.Remove(p); Infected.Remove(p); AssignFirstZombie(); UpdateAllPlayerStatus(); }
void OnHuntDone(Alive target) { if (!IsDead() && (target != null)) { visualController.Face( target.transform.position.x < myTr.position.x ); fighter.Fight( target ); } }
void checkAliveCollision(Alive obj) { if (isInCollision(this, obj)) { dealDamage(obj); } }
public void Start() { health = gameObject.GetComponentInChildren <Slider>(); charcontr = GetComponent <CharacterController>(); target = GameObject.FindGameObjectWithTag("Player").transform; Living += GenerateBoom; }
public void Evolve() { if (_isNextGenerationAlive != IsCurrentlyAlive) { IsCurrentlyAlive = _isNextGenerationAlive; } }
private IEnumerator FightCoroutine(Alive target) { //Transform attackableSpot = target.GetClosestAttackableSpot( myTr.position ); //while ( fighting && !target.IsDead && IsCloseEnough(attackableSpot.position) ) { while (fighting && (target != null) && !target.IsDead && IsCloseToFight(target.transform.position)) { SendMessage("OnAttack", target, SendMessageOptions.DontRequireReceiver); yield return(new WaitForSeconds(.4f)); target.GetHit(this); yield return(new WaitForSeconds(attackRate)); } if (fighting && !target.IsDead) { SendMessage("OnTargetLost", target, SendMessageOptions.DontRequireReceiver); } if (target.IsDead) { SendMessage("OnTargetDead", target, SendMessageOptions.DontRequireReceiver); } fighting = false; }
void Start() { this.myAlive = this.GetComponent <Alive>(); this.playerTransform = GameManager.Player.gameObject.transform; this.myAlive.onDamage += (dmg, dealer) => { Attacked(); }; }
private IEnumerator FightCoroutineRange(Alive target) { //Transform attackableSpot = target.GetClosestAttackableSpot( myTr.position ); //while ( fighting && !target.IsDead && IsCloseEnough(attackableSpot.position) ) { while (fighting && (target != null) && !target.IsDead) { SendMessage("OnAttack", target, SendMessageOptions.DontRequireReceiver); // A remplacer par une coroutine qui lancera la suite quand la flèche atteindra sa cible yield return(new WaitForSeconds(1f)); // target.GetHit( this ); yield return(new WaitForSeconds(attackRate)); } if (fighting && !target.IsDead) { SendMessage("OnTargetLost", target, SendMessageOptions.DontRequireReceiver); } if (target.IsDead) { SendMessage("OnTargetDead", target, SendMessageOptions.DontRequireReceiver); } fighting = false; }
//Adds stats of the new Entity to the Lists public void AddEntity(int[] stats, string[] traits) { ID.Add(next_ID); Alive.Add(next_ID); Str.Add(stats[0]); Agi.Add(stats[1]); Int.Add(stats[2]); //Behaviour.Add(traits); Behaviour.Add(traits); ////selects the corresponding Behaviour switch (traits[1]) { case "Friendly": Friendlies.Add(next_ID); break; case "Hostile": Hostiles.Add(next_ID); break; case "Neutral": Neutrals.Add(next_ID); break; default: Console.WriteLine("Error, assuming Neutral"); Neutrals.Add(next_ID); break; } switch (traits[2]) { case "Melee": AttackDamage.Add(stats[0] + stats[1]); break; case "Ranged": AttackDamage.Add(stats[1] + stats[2]); break; } next_ID++; }
void Start() { charController = GetComponent <CharController>(); alive = GetComponent <Alive>(); visualController = GetComponent <VisualController> (); visualController.FaceRight(); }
void OnAttack(Alive target) { if (!IsDead() && (target != null)) { visualController.Face( target.transform.position.x < myTr.position.x ); visualController.PlayAttack(); } }
private void ClearCommands() { currentTarget = null; fighter.StopFight(); walker.StopHunt(); walker.StopWalk(); CommandIssued = false; }
public Entity(Vector2 position, Vector2 velocity, Texture2D texture) { sprite = new Sprite(texture); Velocity = velocity; this.position = position; CombatState = new CombatStats(); Status = new Alive(); }
override public void OnUse(GameObject player) { Alive alive = player.GetComponent <Alive>(); alive.Heal(healValue, player); Instantiate(effect, player.transform); }
void dealDamage(Alive objet) { int initialLife = objet.getLife(); objet.takeDamage(life); life -= initialLife; }
public void Setup(GameObject player) { myPlayer = player; Alive alive = player.GetComponent <Alive>(); alive.onDamage += Damaged; }
// Use this for initialization void Start() { myTr = transform; alive = GetComponent <Alive>(); personalOffset = new Vector3(UnityEngine.Random.Range(-.1f, .1f), UnityEngine.Random.Range(-.1f, .1f), 0f); enabled = false; }
void Start() { charController = GetComponent <CharController>(); fighter = GetComponent <Fighter>(); alive = GetComponent <Alive>(); soldierType = GetComponent <SoldierType>(); walker = GetComponent <Walker> (); }
void OnHuntDone(Alive target) { if (!IsDead() && (target != null)) { visualController.Face(target.transform.position.x < myTr.position.x); fighter.Fight(target); } }
public void SetTarget(Alive target) { if (selectedCharacter != null) { selectedCharacter.Command_Attack( target ); target.SendMessage("OnTargeted", SendMessageOptions.DontRequireReceiver); currentlyTargetedChar = true; } }
public Person(string name, int age, Alive alive, AbilityToKill abilityToKill, int hitPoints) { this.HitPoints = hitPoints; this.AbilityToKill = abilityToKill; this.Alive = alive; this.Name = name; this.Age = age; }
void OnAttack(Alive target) { if (!IsDead() && (target != null)) { visualController.Face(target.transform.position.x < myTr.position.x); visualController.PlayAttack(); } }
void DoRound() { if (!Running) { return; } List <Player> players = DoRoundCountdown(); if (players == null) { return; } RoundInProgress = true; Random random = new Random(); Player first = PickFirstZombie(random, players); CurLevel.ChatLevel(first.color + first.name + " %Sstarted the infection!"); first.Game.Infected = true; PlayerMoneyChanged(first); UpdatePlayerColor(first, InfectCol); RoundInProgress = true; int roundMins = random.Next(CurLevel.MinRoundTime, CurLevel.MaxRoundTime); string suffix = roundMins == 1 ? " %Sminute!" : " %Sminutes!"; CurLevel.ChatLevel("The round will last for &a" + roundMins + suffix); RoundEnd = DateTime.UtcNow.AddMinutes(roundMins); timer = new System.Timers.Timer(roundMins * 60 * 1000); timer.Elapsed += new ElapsedEventHandler(EndRound); timer.Enabled = true; Player[] online = PlayerInfo.Online.Items; foreach (Player p in online) { if (p.level == null || p.level != CurLevel || p.Game.Referee) { continue; } if (p != first) { Alive.Add(p); } } Infected.Clear(); Infected.Add(first); UpdateAllPlayerStatus(); DoCoreGame(random); if (!Running) { Status = ZombieGameStatus.LastRound; return; } else { HandOutRewards(); } }
public void Command_Attack(Alive target) { if (target.Equals(currentTarget)) { return; } ClearCommands(); currentTarget = target; walker.Hunt(target); CommandIssued = true; }
private IEnumerator HuntCoroutine(Alive target) { Transform attackableSpot; if (huntRandomAttackSpot) { attackableSpot = target.GetRandomAttackableSpot(); } else { attackableSpot = target.GetClosestAttackableSpot(myTr.position); } //while ( hunting && !IsCloseEnough(attackableSpot.position + personalOffset) ) { while ( hunting && (target != null) && !IsCloseToFight(target.transform.position) ) { WalkTo( attackableSpot.position + personalOffset ); yield return new WaitForSeconds(.5f); } StopWalk(); if (hunting) { SendMessage("OnHuntDone", target, SendMessageOptions.DontRequireReceiver); hunting = false; } }
private IEnumerator FightCoroutine(Alive target) { //Transform attackableSpot = target.GetClosestAttackableSpot( myTr.position ); //while ( fighting && !target.IsDead && IsCloseEnough(attackableSpot.position) ) { while ( fighting && (target != null) && !target.IsDead && IsCloseToFight(target.transform.position) ) { SendMessage("OnAttack", target, SendMessageOptions.DontRequireReceiver); yield return new WaitForSeconds(.4f); target.GetHit( this ); yield return new WaitForSeconds( attackRate ); } if (fighting && !target.IsDead) { SendMessage("OnTargetLost", target, SendMessageOptions.DontRequireReceiver); } if (target.IsDead) { SendMessage("OnTargetDead", target, SendMessageOptions.DontRequireReceiver); } fighting = false; }
public Entity() { Velocity = new Vector2(0, 0); position = new Vector2(0, 0); Status = new Alive(); }
void Start() { myTr = transform; bCollider = GetComponent<BoxCollider2D>(); visualController = GetComponent<VisualController>(); walker = GetComponent<Walker>(); fighter = GetComponent<Fighter>(); alive = GetComponent<Alive>(); CommandIssued = false; }
void OnTargetDead(Alive target) { CommandIssued = false; }
void Start() { charController = GetComponent<CharController>(); alive = GetComponent<Alive>(); }
// Use this for initialization void Start() { myTr = transform; alive = GetComponent<Alive>(); personalOffset = new Vector3(UnityEngine.Random.Range(-.1f, .1f), UnityEngine.Random.Range(-.1f, .1f), 0f); enabled = false; }
public void Fight(Alive target) { fighting = true; StartCoroutine( "FightCoroutine", target ); }
void OnTargetDead(Alive target) { FightClosestTarget(); }
public void Hunt(Alive target) { hunting = true; StartCoroutine( "HuntCoroutine", target ); }