예제 #1
0
        private void CalculateItemCard(TempPlayer player)
        {
            ItemCard card = Constants.itemCards[player.selectedCardID];



            if (player.initiative && card.initiativeEffect != Constants.NoEffectID)
            {
                if (Constants.effects[card.initiativeEffect].selfEffect == 0)
                {
                    TempPlayer enemy = player == p1 ? p2 : p1;
                    enemy.AddEffect(card.initiativeEffect, card.initiativeValue, card.initiativeDuration);
                }
                else
                {
                    player.AddEffect(card.initiativeEffect, card.initiativeValue, card.initiativeDuration);
                }
            }


            //Use Pred Effects
            player.UseEffects(true);

            //No Actions here

            //Use Post Effects
            player.UseEffects(false);
        }
예제 #2
0
 public static void RemoveArmNegativeEffects(TempPlayer player, int value)
 {
     if (player.effects.ContainsKey(Constants.InjuredArmID))
     {
         player.effects.Remove(Constants.InjuredArmID);
     }
 }
예제 #3
0
        public static void ShootInLeg(TempPlayer player, int value)
        {
            ServerMatchManager manager = MatchMaker.matches[player.matchID];

            TempPlayer other = manager.p1 == player ? manager.p2 : manager.p1;

            other.AddEffect(Constants.InjuredLegID, -10, 5);
        }
예제 #4
0
 public static void HealInLeg(TempPlayer player, int value)
 {
     player.results.healing /= 2;
     if (player.effects.ContainsKey(Constants.InjuredLegID))
     {
         player.effects.Remove(Constants.InjuredLegID);
     }
 }
예제 #5
0
        private void CalculateAttackCard(TempPlayer player)
        {
            AttackCard card = Constants.attackCards[player.selectedCardID];

            //Add initiative if player was first
            if (player.initiative && card.initiativeEffect != Constants.NoEffectID)
            {
                if (Constants.effects[card.initiativeEffect].selfEffect == 0)
                {
                    TempPlayer enemy = player == p1 ? p2 : p1;
                    enemy.AddEffect(card.initiativeEffect, card.initiativeValue, card.initiativeDuration);
                }
                else
                {
                    player.AddEffect(card.initiativeEffect, card.initiativeValue, card.initiativeDuration);
                }
            }



            //Save temp results for match
            player.results.dmgPerBullet = card.damage;
            player.results.bulletsSpent = card.bullets;
            player.results.accuracy    += card.accuracy; //+ because default value for accuracy is 100

            //DETECT Other player for shooting
            TempPlayer other = player == p1 ? p2 : p1;

            switch (player.bodyPart)
            {
            case "Head":
                player.AddEffect(Constants.ShootInHeadEffectID, 0, 0);
                break;

            case "Arm":
                player.AddEffect(Constants.ShootInArmEffectID, 0, 0);
                break;

            case "Leg":
                player.AddEffect(Constants.ShootInLegEffectID, 0, 0);
                break;

            case "Body":
                player.AddEffect(Constants.ShootInBodyEffectID, 0, 0);
                break;
            }


            //Use PrefEffects
            player.UseEffects(true);



            player.MakeShots(other);

            //Use Post Effects
            player.UseEffects(false);
        }
예제 #6
0
        public static void ShootInArm(TempPlayer player, int value)
        {
            ServerMatchManager manager = MatchMaker.matches[player.matchID];

            TempPlayer other = manager.p1 == player ? manager.p2 : manager.p1;

            other.AddEffect(Constants.InjuredArmID, -10, 5);
            //player.AddEffect(, 0, 10000); //TODO: CHECK IF IT'S Ok or change to some other value for duration
        }
예제 #7
0
 public void RestartMatch()
 {
     p1       = new TempPlayer(p1.connectionID, p1.username);
     p2       = new TempPlayer(p2.connectionID, p2.username);
     p1.Ready = false;
     p2.Ready = false;
     ServerTCP.PACKET_LoadMatch(p1.connectionID, matchID);
     ServerTCP.PACKET_LoadMatch(p2.connectionID, matchID);
     isActive = true;
 }
예제 #8
0
        public bool CheckHit(TempPlayer p2)
        {
            Random r   = new Random();
            bool   hit = r.Next(0, 100) < results.accuracy;

            if (hit)
            {
                return(p2.results.evasion < r.Next(0, 100));
            }

            return(false);
        }
예제 #9
0
        public static void Boom(TempPlayer player, int value)
        {
            TempPlayer other;

            if (MatchMaker.matches[player.matchID].p1 == player)
            {
                other = MatchMaker.matches[player.matchID].p2;
            }
            else
            {
                other = MatchMaker.matches[player.matchID].p1;
            }
            other.ReceivePureDamage(value);
        }
예제 #10
0
        public void MakeShots(TempPlayer p2)
        {
            results.bulletsSpent = Math.Min(n_bullets, results.bulletsSpent);


            //Check Do we hit or not
            if (CheckHit(p2))
            {
                p2.results.selfdamage += results.dmgPerBullet * results.bulletsSpent;
            }

            //In any case we spent bullet
            n_bullets -= results.bulletsSpent;

            n_bullets = Math.Min(n_bullets, max_bullets);
        }
예제 #11
0
        private void CalculateHealCard(TempPlayer player)
        {
            HealCard card = Constants.healCards[player.selectedCardID];

            if (player.initiative && card.initiativeEffect != Constants.NoEffectID)
            {
                if (Constants.effects[card.initiativeEffect].selfEffect == 0)
                {
                    TempPlayer enemy = player == p1 ? p2 : p1;
                    enemy.AddEffect(card.initiativeEffect, card.initiativeValue, card.initiativeDuration);
                }
                else
                {
                    player.AddEffect(card.initiativeEffect, card.initiativeValue, card.initiativeDuration);
                }
            }

            player.results.healing += card.heal;


            switch (player.bodyPart)
            {
            case "Head":
                player.AddEffect(Constants.HealInHeadEffectID, 0, 0);
                break;

            case "Arm":
                player.AddEffect(Constants.HealInArmID, 0, 0);
                break;

            case "Leg":
                player.AddEffect(Constants.HealInLegID, 0, 0);
                break;

            case "Body":
                player.AddEffect(Constants.HealInBodyID, 0, 0);
                break;
            }

            player.UseEffects(true);



            player.UseEffects(false);
        }
예제 #12
0
        public static void SearchingLoop()
        {
            while (players.Count != 0)
            {
                if (players.Count >= 2)
                {
                    TempPlayer player1 = players[0];
                    players.RemoveAt(0);
                    TempPlayer player2 = players[0];
                    players.RemoveAt(0);
                    matches[matchID] = new ServerMatchManager(matchID, player1, player2);
                    matches[matchID].InitializeMatch();

                    matchID++;
                }
            }
            isSearching = false;
        }
예제 #13
0
        public ServerMatchManager(int _matchID, TempPlayer _player1, TempPlayer _player2)
        {
            p1      = _player1;
            p2      = _player2;
            matchID = _matchID;

            p1.matchID         = matchID;
            p2.matchID         = matchID;
            matchSQLConnection = new MySqlConnection(MySQL.CreateConnectionString());
            try
            {
                matchSQLConnection.Open();
                Console.WriteLine("Match №{0} Succesfully connected to MySQL Server '{1}'", matchID, matchSQLConnection.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
예제 #14
0
 public static void InjuredLeg(TempPlayer player, int value)
 {
     player.results.evasion -= 10;
 }
예제 #15
0
 public static void HealInHead(TempPlayer player, int value)
 {
     player.results.healing = 0;
 }
예제 #16
0
 private void CalculateNoCard(TempPlayer player)
 {
     player.UseEffects(false);
     player.UseEffects(true);
 }
예제 #17
0
 public static void HealInArm(TempPlayer player, int value)
 {
     player.results.healing /= 2;
     player.effects.Remove(Constants.InjuredArmID);
 }
예제 #18
0
 public static void DecreaseAccuracy(TempPlayer player, int value)
 {
     //TODO: Rename this function to DecreaseEnemyAccuracy
     player.results.accuracy -= value;
 }
예제 #19
0
 public static void InjuredArm(TempPlayer player, int value)
 {
     player.results.accuracy -= 10;
 }
예제 #20
0
 public static void AddBullet(TempPlayer player, int value)
 {
     player.n_bullets = Math.Min(player.n_bullets + value, player.max_bullets);
 }
예제 #21
0
 public static void HealInBody(TempPlayer player, int value)
 {
 }
예제 #22
0
 public static void Reload(TempPlayer player, int value)
 {
     player.n_bullets = value;
 }
예제 #23
0
 public static void ShootInHead(TempPlayer player, int value)
 {
     player.results.accuracy    -= 50;
     player.results.dmgPerBullet = player.results.dmgPerBullet * 2;
 }
예제 #24
0
 public static void AddHeal(TempPlayer player, int value)
 {
     player.results.healing += value;
 }
예제 #25
0
 public void DealPureDamage(TempPlayer p2, int damage)
 {
     p2.results.selfdamage += damage;
 }
예제 #26
0
 public static void FullReload(TempPlayer player, int value)
 {
     player.n_bullets = player.max_bullets;
 }
예제 #27
0
 //Temporary just make reload when choose reload card;
 private void CalculateSpecialCard(TempPlayer player)
 {
     player.UseEffects(true);
     player.n_bullets = player.max_bullets;
     player.UseEffects(false);
 }
예제 #28
0
 public static void ShootInBody(TempPlayer player, int value)
 {
 }
예제 #29
0
 public static void AddEvasion(TempPlayer player, int value)
 {
     player.results.evasion += value;
 }
예제 #30
0
 public static void AddAccuracy(TempPlayer player, int value)
 {
     player.results.accuracy += value;
 }