예제 #1
0
        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);
        }
예제 #2
0
    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);
        }
    }
예제 #3
0
    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;
    }
예제 #4
0
        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;
        }
예제 #5
0
        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);
        }
예제 #6
0
        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));
        }
예제 #7
0
 void OnTargetLost(Alive target)
 {
     if (!IsDead() && (target != null))
     {
         walker.Hunt(target);
     }
 }
예제 #8
0
    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;
        }
    }
예제 #9
0
 public void ClearOwner()
 {
     hBar.gameObject.SetActive(false);
     rBar.gameObject.SetActive(false);
     buffFrame.gameObject.SetActive(false);
     owner = null;
 }
예제 #10
0
        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;
        }
예제 #11
0
 public override void PlayerLeftServer(Player p)
 {
     Alive.Remove(p);
     Infected.Remove(p);
     AssignFirstZombie();
     UpdateAllPlayerStatus();
 }
예제 #12
0
 void OnHuntDone(Alive target)
 {
     if (!IsDead() && (target != null)) {
         visualController.Face( target.transform.position.x < myTr.position.x );
         fighter.Fight( target );
     }
 }
예제 #13
0
 void checkAliveCollision(Alive obj)
 {
     if (isInCollision(this, obj))
     {
         dealDamage(obj);
     }
 }
예제 #14
0
 public void Start()
 {
     health    = gameObject.GetComponentInChildren <Slider>();
     charcontr = GetComponent <CharacterController>();
     target    = GameObject.FindGameObjectWithTag("Player").transform;
     Living   += GenerateBoom;
 }
예제 #15
0
 public void Evolve()
 {
     if (_isNextGenerationAlive != IsCurrentlyAlive)
     {
         IsCurrentlyAlive = _isNextGenerationAlive;
     }
 }
예제 #16
0
    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(); };
    }
예제 #18
0
    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;
    }
예제 #19
0
        //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++;
        }
예제 #20
0
 void Start()
 {
     charController   = GetComponent <CharController>();
     alive            = GetComponent <Alive>();
     visualController = GetComponent <VisualController> ();
     visualController.FaceRight();
 }
예제 #21
0
 void OnAttack(Alive target)
 {
     if (!IsDead() && (target != null)) {
         visualController.Face( target.transform.position.x < myTr.position.x );
         visualController.PlayAttack();
     }
 }
예제 #22
0
 private void ClearCommands()
 {
     currentTarget = null;
     fighter.StopFight();
     walker.StopHunt();
     walker.StopWalk();
     CommandIssued = false;
 }
예제 #23
0
 public Entity(Vector2 position, Vector2 velocity, Texture2D texture)
 {
     sprite = new Sprite(texture);
     Velocity = velocity;
     this.position = position;
     CombatState = new CombatStats();
     Status = new Alive();
 }
예제 #24
0
        override public void OnUse(GameObject player)
        {
            Alive alive = player.GetComponent <Alive>();

            alive.Heal(healValue, player);

            Instantiate(effect, player.transform);
        }
예제 #25
0
    void dealDamage(Alive objet)
    {
        int initialLife = objet.getLife();

        objet.takeDamage(life);

        life -= initialLife;
    }
예제 #26
0
    public void Setup(GameObject player)
    {
        myPlayer = player;

        Alive alive = player.GetComponent <Alive>();

        alive.onDamage += Damaged;
    }
예제 #27
0
    // 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;
    }
예제 #28
0
 void Start()
 {
     charController = GetComponent <CharController>();
     fighter        = GetComponent <Fighter>();
     alive          = GetComponent <Alive>();
     soldierType    = GetComponent <SoldierType>();
     walker         = GetComponent <Walker> ();
 }
예제 #29
0
 private void ClearCommands()
 {
     currentTarget = null;
     fighter.StopFight();
     walker.StopHunt();
     walker.StopWalk();
     CommandIssued = false;
 }
예제 #30
0
 void OnHuntDone(Alive target)
 {
     if (!IsDead() && (target != null))
     {
         visualController.Face(target.transform.position.x < myTr.position.x);
         fighter.Fight(target);
     }
 }
예제 #31
0
 public void SetTarget(Alive target)
 {
     if (selectedCharacter != null) {
         selectedCharacter.Command_Attack( target );
         target.SendMessage("OnTargeted", SendMessageOptions.DontRequireReceiver);
         currentlyTargetedChar = true;
     }
 }
예제 #32
0
 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;
 }
예제 #33
0
 void OnAttack(Alive target)
 {
     if (!IsDead() && (target != null))
     {
         visualController.Face(target.transform.position.x < myTr.position.x);
         visualController.PlayAttack();
     }
 }
예제 #34
0
        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();
            }
        }
예제 #35
0
 public void Command_Attack(Alive target)
 {
     if (target.Equals(currentTarget)) {
         return;
     }
     ClearCommands();
     currentTarget = target;
     walker.Hunt(target);
     CommandIssued = true;
 }
예제 #36
0
    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;
        }
    }
예제 #37
0
    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;
    }
예제 #38
0
 public Entity()
 {
     Velocity = new Vector2(0, 0);
     position = new Vector2(0, 0);
     Status = new Alive();
 }
예제 #39
0
    void Start()
    {
        myTr = transform;
        bCollider = GetComponent<BoxCollider2D>();
        visualController = GetComponent<VisualController>();
        walker = GetComponent<Walker>();
        fighter = GetComponent<Fighter>();
        alive = GetComponent<Alive>();

        CommandIssued = false;
    }
예제 #40
0
 void OnTargetDead(Alive target)
 {
     CommandIssued = false;
 }
예제 #41
0
 void OnTargetLost(Alive target)
 {
     if (!IsDead() && (target != null)) {
         walker.Hunt(target);
     }
 }
예제 #42
0
 void Start()
 {
     charController = GetComponent<CharController>();
     alive = GetComponent<Alive>();
 }
예제 #43
0
    // 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;
    }
예제 #44
0
 public void Fight(Alive target)
 {
     fighting = true;
     StartCoroutine( "FightCoroutine", target );
 }
예제 #45
0
 void OnTargetDead(Alive target)
 {
     FightClosestTarget();
 }
예제 #46
0
 public void Hunt(Alive target)
 {
     hunting = true;
     StartCoroutine( "HuntCoroutine", target );
 }