Beispiel #1
0
 public override bool Target(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     if (target != null &&
         target.ownedByPlayer != user.ownedByPlayer &&
         user.isAlive &&
         BattleBoard.GetBlockDistanceBetweenDice(user, target) <= range)
     {
         return(true);
     }
     else
     {
         if (target != null)
         {
             String failString = "";
             if (user.isAlive == false)
             {
                 failString = " as " + user.name + " is dead.";
             }
             else if (BattleBoard.GetBlockDistanceBetweenDice(user, target) > range)
             {
                 failString = " as target is out of range.";
             }
             usageDescription = name + " failed" + failString;
         }
         return(false);
     }
 }
Beispiel #2
0
 public FloorTile(Texture2D floorTileSet, int tileNo, Vector2 location)
 {
     sprite           = new Sprite(floorTileSet, GetSourceRectForTileNo(tileNo), location, Constant.l_floorTile, 0f);
     this.tileNo      = tileNo;
     walkable         = true;
     occupyingDiceman = null;
 }
Beispiel #3
0
 public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     foreach (Effect debuff in user.activeEffects)
     {
         if (!debuff.AllowedDiceAbilities()[2])
         {
             usageDescription = user.ownedByPlayer.playerName + "'s " + user.name + " is disabled!";
             return;
         }
     }
     for (int i = -range; i <= range; i++)
     {
         for (int j = -range; j <= range; j++)
         {
             if (BattleBoard.GetBoardTile(user.BoardLocX + i, user.BoardLocY + j) != null)
             {
                 target = BattleBoard.GetBoardTile(user.BoardLocX + i, user.BoardLocY + j).occupyingDiceman;
                 if (target != null && target.isAlive && target.ownedByPlayer != user.ownedByPlayer)
                 {
                     float damageDealt = user.strength * damage;
                     usageDescription = target.DamageDice(damageDealt);
                     user.Move(firedBoardLocation);
                     usageDescription += " and \n" + user.ownedByPlayer.playerName + "'s " + user.name + " vaulted away.";
                     return;
                 }
             }
         }
     }
     usageDescription = name + " failed as no enemies \nwere in range.";
 }
Beispiel #4
0
 public AbilityInput(Diceman selectedDice, Ability selectedSpell, Diceman targetedDice, Vector2 fireLocation)
 {
     this.selectedDice  = selectedDice;
     this.selectedSpell = selectedSpell;
     this.targetedDice  = targetedDice;
     this.fireLocation  = fireLocation;
 }
Beispiel #5
0
 public AbilityInput()
 {
     selectedDice  = null;
     selectedSpell = null;
     targetedDice  = null;
     fireLocation  = Vector2.Zero;
 }
Beispiel #6
0
 public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     foreach (Effect debuff in user.activeEffects)
     {
         if (!debuff.AllowedDiceAbilities()[2])
         {
             usageDescription = user.ownedByPlayer.playerName + "'s " + user.name + " is disabled!";
             return;
         }
     }
     if (target.isAlive)
     {
         float  damageDealt         = user.strength * damage;
         String damageDealtDescript = target.DamageDice(damageDealt);
         if (target.isAlive)
         {
             BattleBoard.AddEffect(new AbilityInput(
                                       user,
                                       new Stunned(0, Constant.e_stunDuration, 0, Constant.e_stunSpeed, Constant.e_stunIcon),
                                       target,
                                       Vector2.Zero));
             usageDescription = damageDealtDescript + " and is STUNNED.";
         }
         else
         {
             usageDescription = damageDealtDescript + ".";
         }
     }
     else
     {
         usageDescription = "Target is already dead.";
     }
 }
 public static int GetBlockDistanceBetweenDice(Diceman dice1, Diceman dice2)
 {
     //int dice1X = (int)GetBoardLocationFromScreenPosition(dice1.sprite.IsometricLocation).X;
     //int dice1Y = (int)GetBoardLocationFromScreenPosition(dice1.sprite.IsometricLocation).Y;
     //int dice2X = (int)GetBoardLocationFromScreenPosition(dice2.sprite.IsometricLocation).X;
     //int dice2Y = (int)GetBoardLocationFromScreenPosition(dice2.sprite.IsometricLocation).Y;
     return(Math.Max(Math.Abs(dice1.BoardLocX - dice2.BoardLocX), Math.Abs(dice1.BoardLocY - dice2.BoardLocY)));
 }
        public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
        {
            foreach (Effect debuff in user.activeEffects)
            {
                if (!debuff.AllowedDiceAbilities()[2])
                {
                    usageDescription = user.ownedByPlayer.playerName + "'s " + user.name + " is disabled!";
                    return;
                }
            }
            int            hitsCount = Constant.a_multishotHits;
            List <Diceman> diceHit   = new List <Diceman>();

            if (target.isAlive && BattleBoard.GetBlockDistanceBetweenDice(user, target) <= range)
            {
                float damageDealt = user.strength * damage;
                usageDescription = target.DamageDice(damageDealt);
                hitsCount--;
                diceHit.Add(target);
            }
            for (int i = -range; i <= range; i++)
            {
                for (int j = -range; j <= range; j++)
                {
                    if (BattleBoard.GetBoardTile(user.BoardLocX + i, user.BoardLocY + j) != null && hitsCount > 0)
                    {
                        target = BattleBoard.GetBoardTile(user.BoardLocX + i, user.BoardLocY + j).occupyingDiceman;
                        foreach (Diceman dice in diceHit)
                        {
                            if (dice == target)
                            {
                                target = null;
                            }
                        }
                        if (target != null && target.isAlive && target.ownedByPlayer != user.ownedByPlayer &&
                            BattleBoard.GetBlockDistanceBetweenDice(user, target) <= range)
                        {
                            float damageDealt = user.strength * damage;
                            if (hitsCount == Constant.a_multishotHits)
                            {
                                usageDescription = "";
                            }
                            usageDescription += target.DamageDice(damageDealt);
                            hitsCount--;
                        }
                    }
                }
            }
            if (hitsCount == Constant.a_multishotHits)
            {
                usageDescription = name + " failed as no enemies \nwere in range.";
            }
            else
            {
                usageDescription += ".";
            }
        }
Beispiel #9
0
 public override bool Target(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     if (target != null && target.isAlive)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #10
0
 public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     remainingDuration = Math.Max(0, remainingDuration - 1);
     if (remainingDuration > 0)
     {
         usageDescription = target.ownedByPlayer.playerName + "'s " + target.name + " is still " + Constant.e_stunPastName + ".";
     }
     else
     {
         usageDescription = "The " + name + " wore off!";
     }
 }
Beispiel #11
0
 public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     foreach (Effect debuff in user.activeEffects)
     {
         if (!debuff.AllowedDiceAbilities()[0])
         {
             usageDescription = user.ownedByPlayer.playerName + "'s " + user.name + " is disabled!";
             return;
         }
     }
     user.Move(firedBoardLocation);
     usageDescription = user.ownedByPlayer.playerName + " moved a " + user.name + ".";
 }
        private static bool CheckDiceMadeTurn(Diceman checkDice)
        {
            bool diceMadeTurn = true;

            for (int i = 0; i <= inputMoveIndex; i++)
            {
                if (abilityInputs[i].selectedDice != null && abilityInputs[i].selectedDice == checkDice)
                {
                    diceMadeTurn = false;
                }
            }
            return(diceMadeTurn);
        }
 private static void SetDiceDescriptText(Diceman selectedDice)
 {
     if (selectedDice != null)
     {
         dicemanDescription.text = selectedDice.name +
                                   "\nHealth : " + Math.Round(selectedDice.Health, Constant.o_roundToDigits).ToString() + "/" + Math.Round(selectedDice.MaxHealth, Constant.o_roundToDigits).ToString() +
                                   "\nStrength : " + Math.Round(selectedDice.strength, Constant.o_roundToDigits).ToString() +
                                   "\nSpeed : " + Math.Round(selectedDice.speed, Constant.o_roundToDigits).ToString();
     }
     else
     {
         dicemanDescription.text = "";
     }
 }
 public override bool Target(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     if (target != null &&
         target.ownedByPlayer != user.ownedByPlayer &&
         user.isAlive)
     {
         return(true);
     }
     else
     {
         if (user.isAlive == false)
         {
             String failString = "";
             failString       = " as " + user.name + " is dead.";
             usageDescription = name + " failed" + failString;
         }
         return(false);
     }
 }
 public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     foreach (Effect debuff in user.activeEffects)
     {
         if (!debuff.AllowedDiceAbilities()[2])
         {
             usageDescription = user.ownedByPlayer.playerName + "'s " + user.name + " is disabled!";
             return;
         }
     }
     if (target.isAlive)
     {
         usageDescription = target.ownedByPlayer.playerName + "'s " + target.name + " is now \n" + Constant.e_poisonName + ".";
         BattleBoard.AddEffect(new AbilityInput(
                                   user,
                                   new Poisoned(0, Constant.e_poisonDuration, Constant.a_poisonDamage, Constant.e_poisonSpeed, Constant.e_poisonIcon),
                                   target,
                                   Vector2.Zero));
     }
 }
 public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     remainingDuration = Math.Max(0, remainingDuration - 1);
     if (remainingDuration > 0 && target.isAlive)
     {
         float damageDealt = user.strength * damage;
         usageDescription = target.DamageDice(damageDealt);
         if (target.isAlive)
         {
             usageDescription += " and is still " + Constant.e_poisonPastName + ".";
         }
     }
     if (remainingDuration == 0 && target.isAlive)
     {
         usageDescription += " and is no longer " + Constant.e_poisonPastName + ".";
     }
     if (!target.isAlive)
     {
         usageDescription += ".";
     }
 }
 public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     foreach (Effect debuff in user.activeEffects)
     {
         if (!debuff.AllowedDiceAbilities()[1])
         {
             usageDescription = user.ownedByPlayer.playerName + "'s " + user.name + " is disabled!";
             return;
         }
     }
     if (target.isAlive)
     {
         float damageDealt = user.strength * damage;
         usageDescription  = target.DamageDice(damageDealt);
         usageDescription += ".";
     }
     else
     {
         usageDescription = "Target is already dead.";
     }
 }
Beispiel #18
0
        public override bool Target(Diceman user, Diceman target, Vector2 firedBoardLocation)
        {
            if (BattleBoard.GetBoardTile(firedBoardLocation) != null &&
                BattleBoard.GetBoardTile(firedBoardLocation).occupyingDiceman == null &&
                user.isAlive)
            {
                return(true);
            }
            String failString = "";

            if (user.isAlive == false)
            {
                failString = " as " + user.name + " is dead.";
            }
            else if (BattleBoard.GetBoardTile(firedBoardLocation).occupyingDiceman != null)
            {
                failString = " as position is occupied.";
            }
            usageDescription = name + " failed" + failString;
            return(false);
        }
Beispiel #19
0
 public override void Use(Diceman user, Diceman target, Vector2 firedBoardLocation)
 {
     foreach (Effect debuff in user.activeEffects)
     {
         if (!debuff.AllowedDiceAbilities()[2])
         {
             usageDescription = user.ownedByPlayer.playerName + "'s " + user.name + " is disabled!";
             return;
         }
     }
     if (target.isAlive)
     {
         Vector2        moveToLoc      = Vector2.Zero;
         List <Vector2> locsNearTarget = new List <Vector2>();
         for (int i = -1; i <= 1; i++)
         {
             for (int j = -1; j <= 1; j++)
             {
                 if (!(i == 0 && j == 0))
                 {
                     locsNearTarget.Add(new Vector2(target.BoardLocX + i, target.BoardLocY + j));
                 }
             }
         }
         float minDist = BattleBoard.GetRealDistanceBetweenTileLocations(new Vector2(0, 0), new Vector2(BattleBoard.board.GetLength(0), BattleBoard.board.GetLength(1)));
         for (int i = 0; i < locsNearTarget.Count; i++)
         {
             if (BattleBoard.GetRealDistanceBetweenTileLocations(user.BoardLocation, locsNearTarget[i]) < minDist)
             {
                 minDist   = BattleBoard.GetRealDistanceBetweenTileLocations(user.BoardLocation, locsNearTarget[i]);
                 moveToLoc = locsNearTarget[i];
             }
         }
         locsNearTarget.Remove(moveToLoc);
         while (user.BoardLocation != moveToLoc && !user.Move(moveToLoc))
         {
             if (locsNearTarget.Count != 0)
             {
                 minDist = BattleBoard.board.Length;
                 for (int i = 0; i < locsNearTarget.Count; i++)
                 {
                     if (BattleBoard.GetRealDistanceBetweenTileLocations(user.BoardLocation, locsNearTarget[i]) < minDist)
                     {
                         minDist   = BattleBoard.GetRealDistanceBetweenTileLocations(user.BoardLocation, locsNearTarget[i]);
                         moveToLoc = locsNearTarget[i];
                     }
                 }
                 locsNearTarget.Remove(moveToLoc);
             }
             else
             {
                 usageDescription = Constant.a_chargeTargetSurrounded;
                 return;
             }
         }
         float damageDealt = user.strength * damage;
         usageDescription  = user.ownedByPlayer.playerName + "'s " + user.name + " charged and\n";
         usageDescription += target.DamageDice(damageDealt);
         usageDescription += ".";
     }
     else
     {
         usageDescription = "Target is already dead.";
     }
 }
 public abstract bool Target(Diceman user, Diceman target, Vector2 firedBoardLocation);
 public abstract void Use(Diceman user, Diceman target, Vector2 firedBoardLocation);
Beispiel #22
0
        private void HandleMessages()
        {
            while (true)
            {
                NetIncomingMessage msg;
                while ((msg = client.ReadMessage()) != null)
                {
                    switch (msg.MessageType)
                    {
                    case NetIncomingMessageType.DiscoveryResponse:
                        NetOutgoingMessage outTrans = client.CreateMessage();
                        outTrans.Write((Byte)PacketTypes.ConnectionRequest);
                        client.Connect(msg.SenderEndPoint, outTrans);
                        break;

                    case NetIncomingMessageType.VerboseDebugMessage:
                    case NetIncomingMessageType.DebugMessage:
                    case NetIncomingMessageType.WarningMessage:
                    case NetIncomingMessageType.ErrorMessage:
                        Game1.multiplayerLobbyTest.text += msg.ReadString();
                        break;

                    case NetIncomingMessageType.StatusChanged:
                        NetConnectionStatus status = (NetConnectionStatus)msg.ReadByte();
                        if (status == NetConnectionStatus.Connected)
                        {
                            NetOutgoingMessage playerStatusMsg = client.CreateMessage();
                            playerStatusMsg.Write((Byte)PacketTypes.PlayerLogin);
                            playerStatusMsg.Write(loggedInPlayer.playerName);
                            client.SendMessage(playerStatusMsg, NetDeliveryMethod.ReliableOrdered);
                            //Game1.multiplayerLobbyTest.text += "\nclient connected";
                            //Console.WriteLine(NetUtility.ToHexString(msg.SenderConnection.RemoteUniqueIdentifier) + " connected!");
                        }
                        break;

                    case NetIncomingMessageType.Data:
                        //Game1.multiplayerLobbyTest.text += "\nReceiving incoming transmission.";
                        switch (msg.ReadByte())
                        {
                        case (Byte)PacketTypes.PlayerLogin:
                            loggedInPlayer.playerID = msg.ReadInt32();
                            if (loggedInPlayer.playerID == 1)
                            {
                                loggedInPlayer.playerColor = Constant.player1Color;
                            }
                            else
                            {
                                loggedInPlayer.playerColor = Constant.player2Color;
                            }
                            Game1.multiplayerLobbyTest.text += "\nMe = " + loggedInPlayer.playerName + " " + loggedInPlayer.playerColor.ToString();
                            if (msg.ReadBoolean())
                            {
                                int    oppId   = msg.ReadInt32();
                                String oppName = msg.ReadString();
                                opponentPlayer = new Player(oppName, oppId, (oppId == 1 ? Constant.player1Color : Constant.player2Color));
                                Game1.multiplayerLobbyTest.text += "\nOther = " + opponentPlayer.playerName + " " + opponentPlayer.playerID.ToString();
                            }
                            break;

                        case (Byte)PacketTypes.PlayerJoinedGameUpdate:
                            int    oppId2   = msg.ReadInt32();
                            String oppName2 = msg.ReadString();
                            opponentPlayer = new Player(oppName2, oppId2, (oppId2 == 1 ? Constant.player1Color : Constant.player2Color));
                            Game1.multiplayerLobbyTest.text += "\nOther = " + opponentPlayer.playerName + " " + opponentPlayer.playerID.ToString();
                            break;

                        case (Byte)PacketTypes.DiceConfiguration:
                            int    playerID      = msg.ReadInt32();
                            int    diceCount     = msg.ReadInt32();
                            Player ownedByPlayer = null;
                            if (LoggedInPlayer.playerID == playerID)
                            {
                                ownedByPlayer = LoggedInPlayer;
                            }
                            else if (OpponentPlayer.playerID == playerID)
                            {
                                ownedByPlayer = OpponentPlayer;
                            }
                            for (int i = 0; i < diceCount; i++)
                            {
                                Diceman.Class diceClass   = (Diceman.Class)msg.ReadByte();
                                int           diceID      = msg.ReadInt32();
                                float         diceHp      = msg.ReadFloat();
                                float         diceStr     = msg.ReadFloat();
                                float         diceSpd     = msg.ReadFloat();
                                Vector2       dicePos     = msg.ReadVector2();
                                String        diceAbility = msg.ReadString();
                                Diceman       newDice     = new Diceman(diceClass, ownedByPlayer, diceAbility, diceID);
                                ownedByPlayer.ownedDicemen.Add(newDice);
                                while (BattleBoard.board == null)
                                {
                                    ;
                                }
                                newDice.Summon(dicePos, diceHp, diceStr, diceSpd);
                                newDice.sprite.tintColor = ownedByPlayer.playerColor;
                            }
                            break;

                        case (Byte)PacketTypes.GameStartSync:
                            isGameStarted = true;
                            break;

                        case (Byte)PacketTypes.Disconnecting:
                            StopClient();
                            break;

                        case (Byte)PacketTypes.MovesList:
                            Game1.multiplayerLobbyTest.text += "\nGot opponent moves list.!!!!!!!!!!!!!!!";
                            int            count      = msg.ReadInt32();
                            List <Diceman> diceInGame = new List <Diceman>();
                            diceInGame.AddRange(LoggedInPlayer.ownedDicemen);
                            diceInGame.AddRange(OpponentPlayer.ownedDicemen);
                            for (int i = 0; i < count; i++)
                            {
                                int    selectedDiceID    = msg.ReadInt32();
                                String selectedSpellName = msg.ReadString();
                                int    targetedDiceID    = -1;
                                if (msg.ReadBoolean())
                                {
                                    targetedDiceID = msg.ReadInt32();
                                }
                                Vector2 fireLoc      = msg.ReadVector2();
                                Diceman selectedDice = null;
                                Diceman targetedDice = null;
                                foreach (Diceman dice in diceInGame)
                                {
                                    if (dice.DiceID == selectedDiceID)
                                    {
                                        selectedDice = dice;
                                    }
                                    if (dice.DiceID == targetedDiceID)
                                    {
                                        targetedDice = dice;
                                    }
                                }
                                Ability selectedSpell = null;
                                foreach (Ability spell in selectedDice.activeAbilities)
                                {
                                    if (spell.name == selectedSpellName)
                                    {
                                        selectedSpell = spell;
                                    }
                                }
                                opponentInputs.Add(new AbilityInput(selectedDice, selectedSpell, targetedDice, fireLoc));
                            }
                            break;

                        default:
                            break;
                        }
                        break;

                    default:
                        break;
                    }
                }
                Thread.Sleep(1);
            }
        }