Example #1
0
        public Dictionary <string, AdventurerModel> SetupAdventurers()
        {
            var firstAdv = new AdventurerModel()
            {
                Name              = "Adv1",
                VerticalAxe       = 0,
                HorizontalAxe     = 0,
                MovementsSequence = "GAA",
                Orientation       = 'S'
            };
            var secondAdv = new AdventurerModel()
            {
                Name              = "007",
                VerticalAxe       = 3,
                HorizontalAxe     = 0,
                MovementsSequence = "AADAA",
                Orientation       = 'N'
            };

            return(new Dictionary <string, AdventurerModel>()
            {
                { firstAdv.Name, firstAdv },
                { secondAdv.Name, secondAdv }
            });
        }
Example #2
0
        private void AdvanceAdventurer(string[,] map, AdventurerModel adventurer)
        {
            var row    = adventurer.VerticalAxe;
            var column = adventurer.HorizontalAxe;

            switch (adventurer.Orientation)
            {
            case (Constants.NorthOrientation):
                row--;
                break;

            case (Constants.EastOrientation):
                column++;
                break;

            case (Constants.SouthOrientation):
                row++;
                break;

            case (Constants.WestOrientation):
                column--;
                break;

            default:
                break;
            }
            CheckActionsOnMovingFromCell(map, adventurer, column, row);
        }
 private string SetLineFromAdventurer(AdventurerModel adventurer)
 {
     return(string.Format("{0} - {1} - {2} - {3} - {4} - {5}",
                          Constants.AdventurerIndicator, adventurer.Name,
                          adventurer.HorizontalAxe.ToString(), adventurer.VerticalAxe.ToString(),
                          adventurer.Orientation, adventurer.CollectedTreasures.ToString()));
 }
Example #4
0
    public AdventurerModel GenerateRandom(ref GameObject roomObject, int level, Enums.UnitRarity rarity)
    {
        //GameObject newAdventurer = new GameObject ();
        AdventurerModel adventurerScript = roomObject.AddComponent <AdventurerModel> ();

        NameData name = dataBase.GetRandomName();

        adventurerScript._unitName        = name.title;
        adventurerScript._unitDescription = name.subtitle;
        adventurerScript._unitNameDelim   = (name.delimiter == "/" ? ", " : " ");

        int statMod      = 0,
            healthMod    = 0;
        float statMult   = 1.0f,
              healthMult = 1.0f;

        statMod   += (5 + level);
        healthMod += level * 5;

        switch (rarity)
        {
        case Enums.UnitRarity.e_rarity_COMMON:
            statMult   = 1f;
            healthMult = 1f;
            break;

        case Enums.UnitRarity.e_rarity_RARE:
            statMult   = 1.1f;
            healthMult = 1.1f;
            break;

        case Enums.UnitRarity.e_rarity_EPIC:
            statMult   = 1.3f;
            healthMult = 1.3f;
            break;

        case Enums.UnitRarity.e_rarity_LEGEND:
            statMult   = 1.5f;
            healthMult = 1.5f;
            break;
        }



        adventurerScript.totalHealth   = (int)(Random.Range(healthMod, healthMod + healthMod) * healthMult);
        adventurerScript.dexterity     = (int)(Random.Range(statMod, statMod + statMod) * statMult);
        adventurerScript.strength      = (int)(Random.Range(statMod, statMod + statMod) * statMult);
        adventurerScript.wisdom        = (int)(Random.Range(statMod, statMod + statMod) * statMult);
        adventurerScript.attack_damage = (int)(Random.Range(statMod, statMod + statMod) * statMult);

        adventurerScript.rarity        = rarity;
        adventurerScript.level         = level;
        adventurerScript.currentHealth = adventurerScript.totalHealth;


        roomObject.name = adventurerScript._unitName + adventurerScript._unitNameDelim + adventurerScript._unitDescription;

        return(adventurerScript);
    }
Example #5
0
 public void ResolveChallengeFailure(PartyController party, RoomModel room)
 {
     foreach (GameObject adventurer in party.GetAdventurers())
     {
         AdventurerModel a = adventurer.GetComponent <AdventurerModel>();
         a.applyDamage(room.room_attack);
     }
 }
Example #6
0
 //Returns true if each adventurer in the party isDead
 public bool isPartyDead()
 {
     foreach (GameObject adventurer in mModel._Adventurers)
     {
         AdventurerModel ad = adventurer.GetComponent <AdventurerModel> ();
         if (!ad.isDead)
         {
             return(false);
         }
     }
     return(true);
 }
Example #7
0
        /// <summary>
        /// Construire l'aventurier et la case qui lui contient
        /// </summary>
        /// <param name="map">L'objet contenant la carte, les aventurires et l'input</param>
        /// <param name="line">contenu de la ligne de l'input</param>
        /// <param name="lineIndex">numéro de la ligne dans l'input</param>
        /// <param name="priority">priorité de l'aventurier dans les déplacements</param>
        private void SetMapAdventurer(MapModel map, string[] line, int lineIndex, ref int priority)
        {
            var adventurer = new AdventurerModel(line, priority);

            if (map.Adventurers.ContainsKey(adventurer.Name))
            {
                throw new DuplicatedAdventurerException(lineIndex);
            }
            map.Adventurers.Add(adventurer.Name, adventurer);
            MapHelper.SetAdventurerCell(map.Map, adventurer);
            priority++;
        }
Example #8
0
 public static void SetCellAndAdventurerAfterLeaving(string[,] map, AdventurerModel adventurer, int newRow, int newColumn)
 {
     if (map[adventurer.VerticalAxe, adventurer.HorizontalAxe].Contains(Constants.TreasureIndicator))
     {
         map[adventurer.VerticalAxe, adventurer.HorizontalAxe] = map[adventurer.VerticalAxe, adventurer.HorizontalAxe].Split('+')[1];
     }
     else
     {
         map[adventurer.VerticalAxe, adventurer.HorizontalAxe] = string.Empty;
     }
     adventurer.VerticalAxe   = newRow;
     adventurer.HorizontalAxe = newColumn;
 }
Example #9
0
        private void CheckActionsOnMovingToTreasure(string[,] map, AdventurerModel adventurer, int column, int row)
        {
            adventurer.CollectedTreasures++;
            var treasuresCount = Convert.ToInt32(MapHelper.GetTreasureValueFromCell(map[row, column]));

            treasuresCount--;
            if (treasuresCount == Constants.Zero)
            {
                MapHelper.SetAdventurerCell(map, adventurer);
            }
            else
            {
                MapHelper.SetAdventurerAndTreasureCell(map, adventurer, treasuresCount);
            }
        }
Example #10
0
        private void CheckActionsOnMovingFromCell(string[,] map, AdventurerModel adventurer, int column, int row)
        {
            if (CanAdventurerMove(map, column, row))
            {
                return;
            }

            MapHelper.SetCellAndAdventurerAfterLeaving(map, adventurer, row, column);
            if (string.IsNullOrEmpty(map[row, column]))
            {
                MapHelper.SetAdventurerCell(map, adventurer);
            }
            else if (map[row, column].StartsWith(Constants.TreasureIndicator))
            {
                CheckActionsOnMovingToTreasure(map, adventurer, column, row);
            }
        }
Example #11
0
    //  TODO aherrera : DEBUG SCRIPT; kill this before it's too late
    public void AddRandomParty()
    {
        GameObject      new_Adventurer       = Instantiate(AdventurerPrefab);
        AdventurerModel new_model            = AdventurerGenerator.instance.GenerateRandom(ref new_Adventurer, 1, Enums.UnitRarity.e_rarity_COMMON);
        GameObject      new_party            = new GameObject();
        PartyModel      new_party_model      = new_party.AddComponent <PartyModel> ();
        PartyController new_party_controller = new_party.AddComponent <PartyController> ();

        //AdventurerPacket newpackofcigs = go_adventurerpacket.AddComponent<AdventurerPacket>();
        new_party.name = checkDictionaryForKey(new_party_controller.GetAdventureTitle());
        new_party_controller.InitializeParty();
        new_party_model._Adventurers.Add(new_Adventurer);

        RoomModel room_model = mDungeonModel.GetRoom(new_party_controller.GetCurrentRoomIndex());

        AddNewParty(new_party, true);
        new_party_controller.BeginRoom(room_model.timer_frequency);
    }
Example #12
0
    public AdventurerModel Generate(string name             = "Default", string description = "Default Description",
                                    Enums.UnitRarity rarity = Enums.UnitRarity.e_rarity_COMMON,
                                    int totalHealth         = 10, int dex = 1, int str = 1, int wis = 1, int atk = 0, int level = 1)
    {
        GameObject      newAdventurer    = new GameObject();
        AdventurerModel adventurerScript = newAdventurer.AddComponent <AdventurerModel> ();

        adventurerScript._unitName        = name;
        adventurerScript._unitDescription = description;
        adventurerScript.rarity           = rarity;
        adventurerScript.totalHealth      = totalHealth;
        adventurerScript.dexterity        = dex;
        adventurerScript.strength         = str;
        adventurerScript.wisdom           = wis;
        adventurerScript.attack_damage    = atk;
        adventurerScript.level            = level;

        return(adventurerScript);
    }
Example #13
0
    public AdventurerModel GenerateUnique()
    {
        GameObject      newAdventurer    = new GameObject();
        AdventurerModel adventurerScript = newAdventurer.AddComponent <AdventurerModel> ();
        AdventurerData  adventurerData   = dataBase.GetRandomAdventurer();

        adventurerScript._unitName        = adventurerData.name;
        adventurerScript._unitDescription = adventurerData.description;
        adventurerScript.rarity           = EnumUtility.StringToRarity(adventurerData.rarity);
        adventurerScript.totalHealth      = adventurerData.max_health;
        adventurerScript.dexterity        = adventurerData.dex_mod;
        adventurerScript.strength         = adventurerData.str_mod;
        adventurerScript.wisdom           = adventurerData.wis_mod;
        adventurerScript.attack_damage    = adventurerData.attackDamage;

        newAdventurer.name = adventurerScript._unitName + ", " + adventurerScript._unitDescription;

        return(adventurerScript);
    }
Example #14
0
    public virtual bool challengeParty(List <GameObject> adventureParty)
    {
        bool retval = true;

        foreach (GameObject adventurer in adventureParty)
        {
            AdventurerModel a = adventurer.GetComponent <AdventurerModel> ();
            if (!a.isDead)
            {
                if (!challengeAdventurer(a))
                {
                    //Adventurer has lost
                    retval = false;
                    break;
                }
            }
        }

        return(retval);
    }
Example #15
0
        /// <summary>
        /// Permet de réaliser un mouvement pour un aventurier (rotation ou avancement)
        /// </summary>
        /// <param name="map">la carte dans laquelle l'aventurier se déplace</param>
        /// <param name="adventurer">l'aventurier qui va se déplacer</param>
        public void MoveAdventurer(string[,] map, AdventurerModel adventurer)
        {
            switch (adventurer.MovementsSequence[0])
            {
            case (Constants.ForwardDirection):
                AdvanceAdventurer(map, adventurer);
                break;

            case (Constants.RightDirection):
                TurnAdventurerRight(adventurer);
                break;

            case (Constants.LeftDirection):
                TurnAdventurerLeft(adventurer);
                break;

            default:
                break;
            }
            adventurer.MovementsSequence = adventurer.MovementsSequence.Remove(0, 1);
        }
Example #16
0
        private void TurnAdventurerRight(AdventurerModel adventurer)
        {
            switch (adventurer.Orientation)
            {
            case (Constants.NorthOrientation):
                adventurer.Orientation = Constants.EastOrientation;
                break;

            case (Constants.EastOrientation):
                adventurer.Orientation = Constants.SouthOrientation;
                break;

            case (Constants.SouthOrientation):
                adventurer.Orientation = Constants.WestOrientation;
                break;

            case (Constants.WestOrientation):
                adventurer.Orientation = Constants.NorthOrientation;
                break;

            default:
                break;
            }
        }
Example #17
0
 public virtual void onFailRoom(ref AdventurerModel adventurer)
 {
     adventurer.applyDamage(m_attack_damage);
     DebugLogger.DebugUnitDamage(m_attack_damage, adventurer);
 }
Example #18
0
    public virtual bool challengeAdventurer(AdventurerModel adventurerChallenging)
    {
        bool retval = challengeUnit(adventurerChallenging);

        return(retval);
    }
Example #19
0
 public static void SetAdventurerAndTreasureCell(string[,] map, AdventurerModel adventurer, int treasuresCount)
 {
     map[adventurer.VerticalAxe, adventurer.HorizontalAxe] = string.Format(Constants.AdventurerAndTreasureCell, adventurer.Name, treasuresCount.ToString());
 }
Example #20
0
 public static void SetAdventurerCell(string[,] map, AdventurerModel adventurer)
 {
     map[adventurer.VerticalAxe, adventurer.HorizontalAxe] = string.Format(Constants.AdventurerOnlyCell, adventurer.Name);
 }