Ejemplo n.º 1
0
    public List <Treasure> getTreasureList(TreasureType color)
    {
        switch (color)
        {
        case TreasureType.blue:
            return(blueTreasure);

            break;

        case TreasureType.green:
            return(greenTreasure);

            break;

        case TreasureType.red:
            return(redTreasure);

            break;

        case TreasureType.yellow:
            return(yellowTreasure);

            break;

        default:
            Debug.LogError("Trying to get an unset treasure list");
            return(null);

            break;
        }
    }
Ejemplo n.º 2
0
        /// <Summary>
        /// Copy constructor of base parts.
        /// </Summary>
        /// <param name="baseParts">Base parts data for copying.</param>
        public AriadneEventParts(AriadneEventParts baseParts)
        {
            eventCategory = baseParts.eventCategory;
            eventTrigger  = baseParts.eventTrigger;
            eventPos      = baseParts.eventPos;

            startCondition     = baseParts.startCondition;
            startFlagName      = baseParts.startFlagName;
            startItemId        = baseParts.startItemId;
            startNum           = baseParts.startNum;
            comparisonOperator = baseParts.comparisonOperator;

            hasExecutedFlag  = baseParts.hasExecutedFlag;
            executedFlagName = baseParts.executedFlagName;

            doorKeyType = baseParts.doorKeyType;

            destDungeon = baseParts.destDungeon;
            destMap     = baseParts.destMap;
            destPos     = baseParts.destPos;
            direction   = baseParts.direction;

            treasureType = baseParts.treasureType;
            itemId       = baseParts.itemId;
            itemNum      = baseParts.itemNum;

            msgList = new List <string>();
            foreach (string msg in baseParts.msgList)
            {
                msgList.Add(msg);
            }
        }
Ejemplo n.º 3
0
        private void SetTreasureType()
        {
            _treasureType = TreasureType.NONE;

            switch (_preset.Frame)
            {
            case 0:
            case 4:
            case 5:
            case 6:
                _treasureType = TreasureType.BROOM;
                break;

            case 1:
                _treasureType = TreasureType.KEY;
                break;

            case 2:
                _treasureType = TreasureType.GROWTH;
                break;

            default:
                if (_preset.Frame >= 8 && _preset.Frame <= 20)
                {
                    _treasureType = TreasureType.SECRET;
                }
                break;
            }
        }
Ejemplo n.º 4
0
    //Call after Instantiating to create a Treasure
    public void CreateTreasure(TreasureType _tt)
    {
        //Update Treasure Container Type
        treasureContainer.treasureType = _tt;
        //Add Treasure to Static List
        treasureList.Add(this);
        //Create Treasure values based on Type
        switch (_tt)
        {
        case TreasureType.Coins:
        {
            treasureContainer.treasureAmount = 100;
            GetComponentInChildren <SpriteRenderer>().sprite = coinSprite;
            break;
        }

        case TreasureType.PileOfCoins:
        {
            treasureContainer.treasureAmount = 1000;
            GetComponentInChildren <SpriteRenderer>().sprite = treasureSprite;
            transform.localScale = new Vector2(1.5f, 1.5f);
            break;
        }

        default:
        {
            Debug.LogError("Critical Logic Error - Missing Treasure Type");
            break;
        }
        }
    }
Ejemplo n.º 5
0
        protected override void Load()
        {
            treasureType    = (TreasureType)(this.Data[15] >> 4);
            treasureChestID = (byte)(this.Data[15] & 0xF);

            // TODO: ChangeBrowsableAttribute buggy? Always hides Money, never ItemCategory/-ID?
            switch (treasureType)
            {
            case TreasureType.Item:
                //this.ChangeBrowsableAttribute("TreasureItemCategory", true);
                //this.ChangeBrowsableAttribute("TreasureItemID", true);
                treasureItemCategory = (TreasureItemCategory)(this.Data[13] >> 4);
                treasureItemID       = BitConverter.ToUInt16(this.Data, 12);

                //this.ChangeBrowsableAttribute("TreasureMoney", false);
                break;

            case TreasureType.Money:
                //this.ChangeBrowsableAttribute("TreasureItemCategory", false);
                //this.ChangeBrowsableAttribute("TreasureItemID", false);

                //this.ChangeBrowsableAttribute("TreasureMoney", true);
                treasureMoney = BitConverter.ToUInt16(this.Data, 12);
                break;
            }

            base.Load();
        }
Ejemplo n.º 6
0
        public static Treasure Create(Dice dice, TreasureType treasureType)
        {
            int roll = dice.Roll(DiceType.D100);

            switch (treasureType)
            {
            case TreasureType.Incidental:
                return(roll < 11 ? new Treasure(1) : new Treasure(0));

            case TreasureType.Standard:
                return(new Treasure(1));

            case TreasureType.Double:
                return(new Treasure(2));

            case TreasureType.Triple:
                return(new Treasure(3));

            case TreasureType.None:
                return(roll == 1 ? new Treasure(1) : new Treasure(0));

            default:
                return(new Treasure(0));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets the accessible adjacent locations of a specified location.
        /// A location is accessible if it's top, bottom, left or right of the location within the grid's ranges and is not a treasure.
        /// </summary>
        /// <returns>The accessible adjacent locations.</returns>
        /// <param name="gameGrid">Game grid.</param>
        /// <param name="location">Location.</param>
        /// <param name="ignoreLocation">Ignore this location no matter what type of treasure it has.</param>
        /// <param name="currentActiveTreasure">The current active treasure is never considered a wall.</param> 
        public static List<GridLocation> GetAccessibleAdjacentLocations(GameFieldGrid gameGrid, GridLocation location, TreasureType currentActiveTreasure, GridLocation ignoreLocation = null)
        {
            var checkLocations = new List<GridLocation> ();

            // Check the item to the top.
            if(location.Row > 0)
            {
                var targetLocation = new GridLocation (location.Row - 1, location.Column);
                bool ignore = ignoreLocation != null && targetLocation.Equals (ignoreLocation);
                bool isActiveTreasure = gameGrid.GetItem (targetLocation).Treasure == currentActiveTreasure;

                if (isActiveTreasure || ignore || IsPassableTreasureType (targetLocation, gameGrid))
                {
                    checkLocations.Add (targetLocation);
                }
            }

            // Check the item below.

            if(location.Row < gameGrid.Rows - 1)
            {
                var targetLocation = new GridLocation (location.Row + 1, location.Column);
                var ignore = ignoreLocation != null && targetLocation.Equals (ignoreLocation);
                bool isActiveTreasure = gameGrid.GetItem (targetLocation).Treasure == currentActiveTreasure;

                if (isActiveTreasure || ignore || IsPassableTreasureType (targetLocation, gameGrid))
                {
                    checkLocations.Add (targetLocation);
                }
            }

            // Check the item to the left.
            if(location.Column > 0)
            {
                var targetLocation = new GridLocation (location.Row, location.Column - 1);
                var ignore = ignoreLocation != null && targetLocation.Equals (ignoreLocation);
                bool isActiveTreasure = gameGrid.GetItem (targetLocation).Treasure == currentActiveTreasure;

                if (isActiveTreasure || ignore || IsPassableTreasureType (targetLocation, gameGrid))
                {
                    checkLocations.Add (targetLocation);
                }
            }

            // Check the item to the right.
            if(location.Column < gameGrid.Columns - 1)
            {
                var targetLocation = new GridLocation (location.Row, location.Column + 1);
                var ignore = ignoreLocation != null && targetLocation.Equals (ignoreLocation);
                bool isActiveTreasure = gameGrid.GetItem (targetLocation).Treasure == currentActiveTreasure;

                if (isActiveTreasure || ignore || IsPassableTreasureType (targetLocation, gameGrid))
                {
                    checkLocations.Add (targetLocation);
                }
            }

            return checkLocations;
        }
 public void Initialize()
 {
     gold         = 0;
     health       = 0;
     sanity       = 0;
     attack       = 0;
     treasureType = TreasureType.ONE_SHOT;
 }
 public Treasure(int gold, int health, int sanity, int attack, int dieStrength, TreasureType treasureType)
 {
     this.gold         = gold;
     this.health       = health;
     this.sanity       = sanity;
     this.attack       = attack;
     this.treasureType = treasureType;
     this.dieStrength  = dieStrength;
 }
Ejemplo n.º 10
0
 public MapEventTreasure(SirokoStats status, Map map, TreasureType treasureType, string treasureName, DialogMenu dialog)
 {
     this.status       = status;
     this.map          = map;
     this.eventType    = EventType.TREASURE;
     this.treasureType = treasureType;
     this.treasureName = treasureName;
     this.dialog       = dialog;
 }
Ejemplo n.º 11
0
 public Treasure(string name, ItemLotCategory category, int itemID, TreasureType rewardType, int maxCount, params Label[] labels)
 {
     Name     = name;
     Category = category;
     ItemID   = itemID;
     Type     = rewardType;
     MaxCount = maxCount;
     Labels   = labels;
 }
 public PotentialTreasure(int min, int max, TreasureType treasureType, int treasureDiceCount, int treasureDiceSides, int multiplier = 1)
 {
     this.Min               = min;
     this.Max               = max;
     this.treasureType      = treasureType;
     this.TreasureDiceCount = treasureDiceCount;
     this.TreasureDiceSides = treasureDiceSides;
     this.Multiplier        = multiplier;
 }
Ejemplo n.º 13
0
 public void Upgrade(TreasureType t)
 {
     type = t;
     if (t == TreasureType.key)
     {
         GameObject go = Instantiate(Key);
         go.transform.SetParent(transform);
         go.transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z);
         GetComponent <MeshRenderer>().material = mat;
     }
     if (t == TreasureType.loot)
     {
         transform.localScale *= 2;
     }
 }
Ejemplo n.º 14
0
        private TreasureCard(int id)
        {
            this.id = id;
            if (id == 88)
            {
                treasure = TreasureType.gold;
            }
            else if (id == 77)
            {
                treasure = TreasureType.stone;
            }

            position  = Status.onBoard;
            ports     = new Dictionary <string, bool>();
            reachable = false;
            Console.WriteLine("[TREASURE_CARD] Created a treasure card of type - {0}({1}), {2}", treasure, id, position);
        }
        private void GenerateMeleeWeapon()
        {
            _treasureType = TreasureType.MeleeWeapon;
            switch (Globals.RollD10())
            {
            case 1:
                _treasureName = new DocContentItem("Razorchain", 84, "Table 2-25: Melee Weapons");
                break;

            case 2:
                _treasureName = new DocContentItem("Chainsword", 84, "Table 2-25: Melee Weapons");
                break;

            case 3:
                _treasureName = new DocContentItem("Chain Axe", 84, "Table 2-25: Melee Weapons");
                break;

            case 4:
                _treasureName = new DocContentItem("Relic Shield", 84, "Table 2-25: Melee Weapons");
                break;

            case 5:
                _treasureName = new DocContentItem("Relic Glaive", 84, "Table 2-25: Melee Weapons");
                break;

            case 6:
                _treasureName = new DocContentItem("Relic Flail", 84, "Table 2-25: Melee Weapons");
                break;

            case 7:
                _treasureName = new DocContentItem("Charged Gauntlet", 84, "Table 2-25: Melee Weapons");
                break;

            case 8:
                _treasureName = new DocContentItem("Power Blade", 84, "Table 2-25: Melee Weapons");
                break;

            case 9:
                _treasureName = new DocContentItem("Power Axe", 84, "Table 2-25: Melee Weapons");
                break;

            case 10:
                _treasureName = new DocContentItem("Crystalline Blade", 84, "Table 2-25: Melee Weapons");
                break;
            }
        }
Ejemplo n.º 16
0
 public Treasure(string name,
                 TreasureType treasureType,
                 TreasureSizes treasureSize,
                 string description,
                 double difficulty,
                 double rating,
                 int userId,
                 bool isChained)
 {
     Name           = name;
     TreasureType   = treasureType;
     TreasureSize   = treasureSize;
     Description    = description;
     Difficulty     = difficulty;
     Rating         = rating;
     Key            = GenerateKey();
     UserId         = userId;
     this.IsChained = isChained;
 }
Ejemplo n.º 17
0
        //public TreasureNugget startupBasicNugget(Point dimensions, AnimationData animationData, int score, int zLayer)
        public TreasureNugget startupBasicNugget(Point dimensions, int index, TreasureType type, int zLayer)
        {
            AnimationData animationData = new AnimationData(
                new string[] {
                type == TreasureType.TREASURE_GOLD ? "Media/unknown.png" : "Media/unknown.png"
            },
                0.0005);

            base.startupAnimatedGameObject(dimensions, animationData, ZLayers.PLAYER_Z, false);

            this.Visibility        = System.Windows.Visibility.Collapsed;
            this.timeSinceExposure = -1;
            enemyLogic             = new NuggetLogic(this.basicEnemyLogic);
            this._collisionName    = CollisionIdentifiers.ENEMY;
            this.Score             = 10;
            this.Type  = type;
            this.Index = index;
            return(this);
        }
Ejemplo n.º 18
0
        int CalculatePoints(TreasureSizes size, TreasureType type)
        {
            const int PointsMultiplier = 100;

            if (TreasureType.SURPRISE == type)
            {
                // when the treasure is a surpirse the user gets random points multiplier
                double[] surpriseMultipliers = new double[5] {
                    0.5, 2, 3, 4, 5
                };
                Random rd           = new Random();
                int    randomIndex  = rd.Next(0, 5);
                double randomNumber = surpriseMultipliers[randomIndex];
                return((int)(randomNumber * (int)size * PointsMultiplier));
            }
            else
            {
                return(PointsMultiplier * (int)size * (int)type);
            }
        }
Ejemplo n.º 19
0
 public IEnumerator DoCollectedThingDance(TreasureType type)
 {
     rigidbody.useGravity = false;
     rigidbody.velocity = rigidbody.velocity.SetY(0f);
     if (type == TreasureType.Little)
     {
         yield return StartCoroutine(LittleTreasureDance());
     }
     else
     {
         InputManager.Instance.PlayerInputEnabled = false;
         iTween.MoveTo(gameObject, transform.position.SetY(transform.position.y + 1), .5f);
         yield return new WaitForSeconds(.5f);
         iTween.MoveTo(gameObject, transform.position.SetY(transform.position.y - 1), .5f);
         yield return new WaitForSeconds(.5f);
         InputManager.Instance.PlayerInputEnabled = true;
     }
     rigidbody.useGravity = true;
     UserProgressStore.Instance.AddTreasure(type);
 }
Ejemplo n.º 20
0
 public List<Treasure> getTreasureList(TreasureType color)
 {
     switch (color) {
     case TreasureType.blue:
         return blueTreasure;
         break;
     case TreasureType.green:
         return greenTreasure;
         break;
     case TreasureType.red:
         return redTreasure;
         break;
     case TreasureType.yellow:
         return yellowTreasure;
         break;
     default:
         Debug.LogError ("Trying to get an unset treasure list");
         return null;
         break;
     }
 }
        private void GenerateRangedWeapon()
        {
            _treasureType = TreasureType.RangedWeapon;
            switch (Globals.RollD10())
            {
            case 1:
                _treasureName = new DocContentItem("Relic Javelin", 84, "Table 2-26: Ranged Weapons");
                break;

            case 2:
            case 3:
                _treasureName = new DocContentItem("Pistol", 84, "Table 2-26: Ranged Weapons");
                break;

            case 4:
            case 5:
                _treasureName = new DocContentItem("Rifle", 84, "Table 2-26: Ranged Weapons");
                break;

            case 6:
                _treasureName = new DocContentItem("Flamer", 84, "Table 2-26: Ranged Weapons");
                break;

            case 7:
                _treasureName = new DocContentItem("Thermal Cutter", 84, "Table 2-26: Ranged Weapons");
                break;

            case 8:
                _treasureName = new DocContentItem("Heavy Rifle", 84, "Table 2-26: Ranged Weapons");
                break;

            case 9:
                _treasureName = new DocContentItem("Hunter's Rifle", 84, "Table 2-26: Ranged Weapons");
                break;

            case 10:
                _treasureName = new DocContentItem("Scattergun", 84, "Table 2-26: Ranged Weapons");
                break;
            }
        }
        private void GenerateShipComponents()
        {
            _treasureType = TreasureType.ShipComponents;
            switch (Globals.RollD10())
            {
            case 1:
            case 2:
                _treasureName = new DocContentItem("Plasma Drive", 85, "Table 2-29: Ship Components");
                break;

            case 3:
                _treasureName = new DocContentItem("Warp Drive", 85, "Table 2-29: Ship Components");
                break;

            case 4:
                _treasureName = new DocContentItem("Gellar Field", 85, "Table 2-29: Ship Components");
                break;

            case 5:
                _treasureName = new DocContentItem("Void Shield", 85, "Table 2-29: Ship Components");
                break;

            case 6:
                _treasureName = new DocContentItem("Ship's Bridge", 85, "Table 2-29: Ship Components");
                break;

            case 7:
                _treasureName = new DocContentItem("Augur Array", 85, "Table 2-29: Ship Components");
                break;

            case 8:
            case 9:
                _treasureName = new DocContentItem("Lance", 85, "Table 2-29: Ship Components");
                break;

            case 10:
                _treasureName = new DocContentItem("Macrocannon", 85, "Table 2-29: Ship Components");
                break;
            }
        }
        private void GenerateArmour()
        {
            _treasureType = TreasureType.Armour;
            switch (Globals.RollD10())
            {
            case 1:
            case 2:
                _treasureName = new DocContentItem("Reinforced Hauberk", 84, "Table 2-27: Armour");
                break;

            case 3:
                _treasureName = new DocContentItem("Reinforced Helm", 84, "Table 2-27: Armour");
                break;

            case 4:
            case 5:
                _treasureName = new DocContentItem("Meshweave Cloak", 84, "Table 2-27: Armour");
                break;

            case 6:
                _treasureName = new DocContentItem("Carapace Chestplate", 84, "Table 2-27: Armour");
                break;

            case 7:
                _treasureName = new DocContentItem("Carapace Helm", 84, "Table 2-27: Armour");
                break;

            case 8:
                _treasureName = new DocContentItem("Assassin's Bodyglove", 84, "Table 2-27: Armour");
                break;

            case 9:
                _treasureName = new DocContentItem("Light Power Armour", 138, "Table 5-12: Armour", RuleBook.CoreRuleBook);
                break;

            case 10:
                _treasureName = new DocContentItem("Power Armour", 138, "Table 5-12: Armour", RuleBook.CoreRuleBook);
                break;
            }
        }
        /// <summary>
        /// Provides a method for determining treasure box loot.
        /// </summary>
        /// <returns>The loot.</returns>
        /// <remarks>
        /// While this method is required by the framework interface, the implementation relies upon the nested custom
        /// treasure box instance to perform the actual work.
        /// </remarks>
        public string GenerateLoot()
        {
            TreasureType treasureType = _myBox.GetTreasure();

            string loot = "";

            switch (treasureType)
            {
            case TreasureType.Normal:
                loot = "Normal";
                break;

            case TreasureType.Rare:
                loot = "Rare";
                break;

            case TreasureType.Legendary:
                loot = "Legendary";
                break;
            }

            return(loot);
        }
Ejemplo n.º 25
0
 public Treasure(string id, string name, int value, string description, TreasureType type) : base(id, name, value, description)
 {
     Type = type;
 }
Ejemplo n.º 26
0
 public void UpdatePlayer(GameMoveType move, TreasureType treasure, GridLocation location)
 {
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Gets the location of the current active treasure card.
        /// Randomization and statistics are applied to prevent the prevention from being 100% correct. This makes the AI more human.
        /// If the AI cannot remember the location, a random location will be returned.
        /// </summary>
        /// <returns>The target treasure location.</returns>
        /// <param name="gameField">Game field.</param>
        /// <param name="activeTreaure">Active treaure.</param>
        public static GridLocation GetActiveTreasureLocation(GameFieldGrid gameField, TreasureType activeTreaure)
        {
            // Find the item that has the active treasure.
            var activeTreasureItem = gameField.FirstOrDefault (item => item.Treasure == activeTreaure);
            // Get the location of the item.
            var location = gameField.GetItemLocation (activeTreasureItem);

            return location;
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Загрузка списка финансовых операций за указанную дату
        /// </summary>
        /// <param name="auth">Данные авторизации организации</param>
        /// <param name="date">Дата</param>
        /// <param name="type">Тип склада</param>
        /// <returns></returns>       
        public static List<TreasureOperation> GetTreasureDay(OrgAuth auth, DateTime date, TreasureType type)
        {
            var result = new List<TreasureOperation>();
            result.Clear();

            string url = UrlConstuctor.GetTreasureUrl(auth, date, type);

            var doc = new XmlDocument();
            XmlNodeList list;

            doc.Load(url);

            list = doc.GetElementsByTagName("error");

            if (list.Count == 0)
            {
                list = doc.GetElementsByTagName("action");
                foreach (XmlNode item in list)
                {
                    DateTime dateTime = DateTime.Parse(item.Attributes[0].Value);
                    string nick = item.ChildNodes[0].InnerText;
                    string direction = item.ChildNodes[1].InnerText;
                    float value = float.Parse(item.ChildNodes[2].InnerText);

                    var operation = new TreasureOperation(dateTime, nick, direction, value);
                    result.Add(operation);
                }
            }
            else
            {
                //Ошибка доступа!
                throw new ApiAccessError(list[0].InnerText);
            }

            return result;
        }
Ejemplo n.º 29
0
 public Treasure(int id, string name, int value, string description, string useMessage, TreasureType type, bool isAvailable) :
     base(id, name, value, description, useMessage, isAvailable)
 {
     Type = type;
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Learns about a treasure that has been discovered.
        /// </summary>
        /// <param name="treasure">Treasure.</param>
        /// <param name="location">Location.</param>
        protected void LearnAboutTreasure(TreasureType treasure, GridLocation location)
        {
            var loggingService = ServiceContainer.Resolve<ILoggingService> ();
            // Check if we already know about the treasure at the discovered location.
            TreasureChanceInfo treasureInfo = FindTreasureChanceByLocation (location);

            if(treasureInfo == null)
            {
                // Treasure is unknown. Remember now.
                treasureInfo = new TreasureChanceInfo ()
                {
                    treasureChance = ChanceRememberAnyTreasureJustUncovered,
                    // Specific chance is not used for 'None'.
                    specificTreasureChance = treasure == TreasureType.None ? 0f : ChanceRememberSpecificTreasureJustUncovered,
                    location = location,
                    treasure = treasure
                };
                this.treasureChances.Add (treasureInfo);
                #if EXTENSIVE_LOGGING
                loggingService.Log ("AI just learned about {0} at location {1}.", treasure, location);
                #endif
            }
            else
            {
                // Item was seen before. AI fully remembers where the treasure is. Update memory.
                treasureInfo.specificTreasureChance = treasure == TreasureType.None ? 0f : ChanceRememberSpecificTreasureJustUncovered;
                treasureInfo.treasureChance = ChanceRememberAnyTreasureJustUncovered;
                #if EXTENSIVE_LOGGING
                loggingService.Log ("AI updated memory about {0} at location {1}.", treasure, location);
                #endif
            }
        }
Ejemplo n.º 31
0
 /// <summary>
 /// Добавляет операции в список соответствующего склада
 /// </summary>
 /// <param name="type">Тип склада</param>
 /// <param name="operations">Список операции</param>
 public void AddTreasureDay(TreasureType type, List<TreasureOperation> operations)
 {
     //если склада нет - создаем
     if (!_treasures.ContainsKey(type))
     {
         _treasures.Add(type, new List<TreasureOperation>());
     }
     //Добавляем операции
     foreach (TreasureOperation item in operations)
     {
         _treasures[type].Add(item);
     }
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Gets the first location of a specific treasure.
        /// </summary>
        /// <returns>The item location. NULL if the treasure cannot be found.</returns>
        /// <param name="grid">Grid.</param>
        /// <param name="treasure">Treasure.</param>
        public static GridLocation GetItemLocation(this GameFieldGrid grid, TreasureType treasure)
        {
            int index = 0;
            foreach(var searchItem in grid)
            {
                if(searchItem.Treasure == treasure)
                {
                    int row = index / grid.Columns;
                    int col = index % grid.Columns;
                    return new GridLocation (row, col);
                }
                index++;
            }

            return null;
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Gets the fields that have to be followed to come to a specific location.
        /// </summary>
        /// <returns>The path to location.</returns>
        /// <param name="fromLocation">the location from where to start path finding. Must be the same that was passed to PreparePathGrid()</param>
        /// <param name="toLocation">the location to find the path to starting at the unused location.</param>
        /// <param name="gameGrid">Game grid.</param>
        /// <param name="pathGrid">Populated path grid.</param>
        /// <param name="currentActiveTreasure">The current active treasre can always be stepped onto.</param>
        public static List<GridLocation> GetPathToLocation(GameFieldGrid gameGrid, Grid2D<int> pathGrid, GridLocation fromLocation, GridLocation toLocation, TreasureType currentActiveTreasure)
        {
            if(gameGrid == null)
            {
                throw new ArgumentNullException ("gameGrid");
            }

            if(pathGrid == null)
            {
                throw new ArgumentNullException ("pathGrid");
            }

            if(toLocation == null)
            {
                throw new ArgumentNullException ("toLocation");
            }

            // This will hold the reversed path.
            var path = new List<GridLocation> {
                // The target always belongs to the path.
                new GridLocation (toLocation.Row, toLocation.Column)
            };

            // Loop until the path has been completed.
            while(true)
            {
                // From the current target location check all possible moves. The algorithm works its way from the target to the start, so the path will be reversed.
                var checkLocations = AIHelpers.GetAccessibleAdjacentLocations (gameGrid, toLocation, currentActiveTreasure, fromLocation);

                // Loop the possible moves and remember the one with the lowest distance towards the start location.
                int lowestDistance = pathFindingMaxVal;
                GridLocation lowestLocation = null;

                foreach(var adjacentLocation in checkLocations)
                {
                    int distance = pathGrid.GetItem (adjacentLocation);
                    if(distance < lowestDistance)
                    {
                        lowestDistance = distance;
                        lowestLocation = adjacentLocation;
                        // The new target location is the lowest of the possible locations.
                        toLocation = lowestLocation;
                    }
                }

                if(lowestLocation != null)
                {
                    // Insert at 0 to have the path in the correct reversed order.
                    path.Insert(0, lowestLocation);
                    if(lowestLocation.Equals(fromLocation))
                    {
                        // Reached the start location.
                        break;
                    }
                }
                else
                {
                    // No lowest location found. Bail out.
                    break;
                }
            }

            return path;
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Gets a random move. Used if the AI does not know what to do and is guessing.
 /// </summary>
 /// <returns>The random move.</returns>
 /// <param name="gameGrid">Game grid.</param>
 /// <param name="fromLocation">From location.</param>
 /// <param name="currentActiveTreasure">The current active treasure. This can also be stepped onto.</param>
 public static GameMoveType GetRandomMove(GameFieldGrid gameGrid, GridLocation fromLocation, TreasureType currentActiveTreasure)
 {
     var possibleTargetLocations = AIHelpers.GetAccessibleAdjacentLocations (gameGrid, fromLocation, currentActiveTreasure);
     var platformServices = ServiceContainer.Resolve<IPlatformServices> ();
     // Pick a random target location.
     var toLocation = possibleTargetLocations [platformServices.GetRandomNumber (0, possibleTargetLocations.Count)];
     // Return the required move to get to the picked location.
     var randomMove = AIHelpers.GetMoveToAdjacentLocation (fromLocation, toLocation);
     return randomMove;
 }
Ejemplo n.º 35
0
 public void OnTreasureCollected(TreasureType type)
 {
     StartCoroutine(_animator.DoCollectedThingDance(type));
 }
Ejemplo n.º 36
0
        /// <summary>
        /// Returns a two dimensional grid where each field contains the distance from the start point (the empty field).
        /// </summary>
        /// <returns>The path.</returns>
        /// <param name="gameGrid">Game grid.</param>
        /// <param name="fromLocation">the location to start from.</param>
        /// <param name="currentActiveTreasure">The current active treasre can always be stepped onto.</param>
        public static Grid2D<int> PreparePathGrid(GameFieldGrid gameGrid, GridLocation fromLocation, TreasureType currentActiveTreasure)
        {
            if(gameGrid == null)
            {
                throw new ArgumentNullException ("gameGrid");
            }

            if(fromLocation == null)
            {
                throw new ArgumentNullException ("fromLocation");
            }

            // Create a grid as big as the game field. The content of each item is the distance from the staring point (the empty spot).
            var pathGrid = new Grid2D<int> (gameGrid.Rows, gameGrid.Columns, pathFindingMaxVal);

            // Use a Disjkstra algorithm to find a path from the empty spot to the current active treasure.
            // First, set the presumed target location to a distance of 0.
            pathGrid.SetItem (fromLocation, 0);

            // Start calculating distances.
            while(true)
            {
                // Set to true if at least one field was changed. If nothing is changed during one loop, we're done.
                bool gridChanged = false;

                // Loop all fields until each field contains a distance value.
                for (int row = 0; row < gameGrid.Rows; row++)
                {
                    for (int col = 0; col < gameGrid.Columns; col++)
                    {
                        // Distance is one more than it was at the current location. Set for the surrounding fields.
                        int newDistance = pathGrid.GetItem (row, col);
                        if(newDistance != pathFindingMaxVal)
                        {
                            newDistance++;
                        }

                        var checkLocations = AIHelpers.GetAccessibleAdjacentLocations(gameGrid, new GridLocation(row, col), currentActiveTreasure);
                        foreach(var checkLocation in checkLocations)
                        {
                            // Remember the distance to the start point.
                            int currentDistance = pathGrid.GetItem (checkLocation);
                            if(newDistance < currentDistance)
                            {
                                pathGrid.SetItem (checkLocation, newDistance);
                                gridChanged = true;
                            }
                        }
                    }
                }

                // Bail out of the algorithm if we visited all nodes.
                if(!gridChanged)
                {
                    break;
                }
            }
            return pathGrid;
        }
Ejemplo n.º 37
0
        public static Treasure GetRandomReward(TreasureType treasureType, Random random)
        {
            List <Treasure> options = new List <Treasure>(RenewableList.Where(treasure => treasure.Type == treasureType));

            return(options.GetRandomElement(random));
        }
Ejemplo n.º 38
0
 public static Treasure GetRandomReward(TreasureType treasureType, Label[] labels, List <(ItemLotCategory, int)> usedItems, Random random)
Ejemplo n.º 39
0
        /// <summary>
        /// Получаем операции казны
        /// </summary>
        /// <param name="type">Тип казны</param>
        /// <returns></returns>
        public List<TreasureOperation> GetTreasute(TreasureType type)
        {
            List<TreasureOperation> result = new List<TreasureOperation>();

            if (_treasures.ContainsKey(type))
            {
                result = _treasures[type];
            }

            return result;
        }
Ejemplo n.º 40
0
 public void ResetTreasureType()
 {
     TreasureType = (dynamic)originalValues["TreasureType"];
 }
Ejemplo n.º 41
0
 public void ResetTreasureType()
 {
     this.TreasureType = (dynamic)base.originalValues["TreasureType"];
 }
Ejemplo n.º 42
0
        /// <summary>
        /// Создание url для доступа к API казны
        /// </summary>
        /// <param name="auth">Данные авторизации организации</param>
        /// <param name="date">Дата</param>
        /// <param name="treasureType">Тип казны</param>
        /// <returns></returns>
        public static string GetTreasureUrl(OrgAuth auth, DateTime date, TreasureType treasureType)
        {
            string result;
            string type;
            string dt = date.Day.ToString().PadLeft(2, '0') + "." + date.Month.ToString().PadLeft(2, '0') + "." +
                        date.Year;
            if (treasureType == TreasureType.Money)
            {
                type = "money";
            }
            else if (treasureType == TreasureType.Taler)
            {
                type = "talers";
            }
            else if (treasureType == TreasureType.Exp)
            {
                type = "exp";
            }
            else
            {
                throw new SetParameterError("Задан некорректный тип склада!");
            }

            result = MainUrl + "?rm=org_treasury_info";
            result += "&org_id=" + auth.Id;
            result += "&date=" + dt;
            result += "&type=" + type;
            result += "&sign=" + Md5(auth.Id + auth.Password + dt + type);
            return result;
        }
Ejemplo n.º 43
0
        /// <summary>
        /// Gets the presumed location of a treasure. This does some dice rolling to make the AI dumber.
        /// Note: this always returns NULL for treasure type 'None'.
        /// </summary>
        /// <returns>The presumed location of treasure. NULL if AI does not know where the treasure is.</returns>
        /// <param name="treasure">Treasure to look up.</param>
        protected virtual GridLocation GetPresumedLocationOfTreasure(TreasureType treasure)
        {
            if(treasure == TreasureType.None)
            {
                return null;
            }

            var loggingService = ServiceContainer.Resolve<ILoggingService>();
            loggingService.Log ("Calculating if AI remembers where '{0}' is located:", treasure);

            GridLocation location = null;
            var treasureInfo = this.FindTreasureChanceByTreasure (treasure);
            if(treasureInfo != null)
            {
                var platformServices = ServiceContainer.Resolve<IPlatformServices>();

                // The treasure location is known to the AI. Roll the dice to find out if it actually remembers the location.
                float randomPercentage = (float)platformServices.GetRandomNumber ();

                // Get the chance that indicates how well the AI remembers the location.
                float requiredPercentage = treasureInfo.specificTreasureChance;
                bool canRemember = randomPercentage <= requiredPercentage;

                loggingService.Log ("  AI has seen '{0}' before. Required chance={1:##.000}%.", treasure, requiredPercentage * 100f);
                if(canRemember)
                {
                    // The AI remembers where the requested treasure is.
                    location = treasureInfo.location;
                    loggingService.Log ("  AI remembers where '{0}' is located. Randomization returned {1:##.000}%", treasure, randomPercentage * 100f);
                }
                else
                {
                    loggingService.Log ("  AI does not remember where '{0}' is located. Randomization returned {1:##.000}%", treasure, randomPercentage * 100f);
                }
            }
            else
            {
                // AI does not know at all where the treasure is.
                loggingService.Log ("  AI has not seen '{0}' yet, thus cannot remember.", treasure);
            }

            return location;
        }
Ejemplo n.º 44
0
 public void UpdatePlayer(GameMoveType move, TreasureType treasure, GridLocation location)
 {
     // TODO: Implementation required?
     this.visualizationService.Write(this.visualizationService.screen.Rows - 1, 0, ConsoleColor.White, "Other player's move '{0}' discovered item {1} at location {2}", move, treasure, location);
 }
Ejemplo n.º 45
0
 /// <summary>
 /// Finds the treasure chance by treasure.
 /// </summary>
 /// <returns>The treasure chance by treasure. NULL, if the AI does not know anything about the treasure.</returns>
 /// <param name="treasure">Treasure.</param>
 TreasureChanceInfo FindTreasureChanceByTreasure(TreasureType treasure)
 {
     return this.treasureChances.FirstOrDefault (info => info.treasure.Equals(treasure));
 }
Ejemplo n.º 46
0
 /// <summary>
 /// Public Constructor for Treasure items
 /// </summary>
 /// <param name="id">id of treasure item</param>
 /// <param name="name">name of treasure item</param>
 /// <param name="value">value of treasure item</param>
 /// <param name="type">type of treasure item</param>
 /// <param name="description">description of treasure item</param>
 /// <param name="useMessage">on use message of treasure item</param>
 public Treasure(int id, string name, int value, TreasureType type, string description, string useMessage = "")
     : base(id, name, value, description, useMessage)
 {
     Type = type;
 }
Ejemplo n.º 47
0
 public Treasure(int itemTypeID, string name, int value, TreasureType type, string description)
     : base(itemTypeID, name, value, description)
 {
     Type = type;
 }
Ejemplo n.º 48
0
 public Treasure Clone(int itemTypeID, string name, int value, TreasureType type, string description)
 {
     return(new Treasure(ItemTypeID, Name, value, Type, Description));
 }
Ejemplo n.º 49
0
        public virtual void UpdatePlayer(GameMoveType move, TreasureType treasure, GridLocation location)
        {
            // If it's the other player's turn, we can't have a target to move to.
            this.currentPath = null;

            // Forget a bit about treasures every time a move was made.
            this.ForgetTreasures ();

            // Remember the treasure that has just been discoverd fully.
            this.LearnAboutTreasure (treasure, location);
        }