Example #1
0
        public static void CreateItem(List <GameObject> itemList, Vector3 spawnPoint, System.Random random)
        {
            int item  = random.Next(0, 101);
            int level = 0;

            if (item >= Range1.x && item < Range1.y)
            {
                level = 1;
            }
            else if (item >= Range2.x && item < Range2.y)
            {
                level = 2;
            }
            else if (item >= Range3.x && item <= Range3.y)
            {
                level = 3;
            }


            spawnPoint.y -= YPositionReduction;
            GameObject gameObject = SpawnObject(spawnPoint, VestPrefab[level - 1]);

            Vest vest = gameObject.GetComponent <Vest>();

            vest.Level = level;

            itemList.Add(gameObject);
        }
Example #2
0
        private void UpdateProtectionKnowledge()
        {
            Actor.EquipmentManager.SelectHelmet();
            Actor.EquipmentManager.SelectVest();

            vestProtectionRatio   = 0.0f;
            helmetProtectionRatio = 0.0f;

            ObjectContainedInventory cellHelmet = Actor.AIInventory.GetHelmet();
            ObjectContainedInventory cellVest   = Actor.AIInventory.GetVest();
            Vest   equippedVest   = null;
            Helmet equippedHelmet = null;

            if (cellVest != null)
            {
                equippedVest = (Vest)cellVest.GetItem();
            }

            if (equippedVest != null)
            {
                hasVestEquipped      = true;
                vestProtectionRatio += equippedVest.ProtectionValue;
            }
            else
            {
                hasVestEquipped = false;
            }
            if (cellHelmet != null)
            {
                equippedHelmet = (Helmet)cellHelmet.GetItem();
            }

            if (equippedHelmet != null)
            {
                hasHelmetEquipped      = true;
                helmetProtectionRatio += equippedHelmet.ProtectionValue;
            }
            else
            {
                hasHelmetEquipped = false;
            }
            helmetProtectionRatio /= HelmetProtectionMaximum;
            vestProtectionRatio   /= VestProtectionMaximum;
        }
Example #3
0
        private float EvaluateVestValue(float distanceToItem, Item item)
        {
            float vestValueLevel = 0.0f;

            Vest  newVest = (Vest)item;
            float nonEquippedVestValueLevel = newVest.ProtectionValue;

            nonEquippedVestValueLevel = nonEquippedVestValueLevel / actor.Brain.VestProtectionMaximum;

            float equippedVestValueLevel = actor.Brain.VestProtectionRatio;


            if (equippedVestValueLevel < nonEquippedVestValueLevel)
            {
                vestValueLevel = VestGoalFactor * nonEquippedVestValueLevel / distanceToItem;
            }
            else
            {
                vestValueLevel = VestGoalFactor * (1 - actor.Brain.VestProtectionRatio) * (nonEquippedVestValueLevel) / distanceToItem;
            }

            return(vestValueLevel);
        }
Example #4
0
        //public bool IsExplorePathBlocked(Vector3 destination, float range)
        //{
        //    Vector3 direction = Vector3.zero;
        //    direction = destination - Actor.transform.position;
        //    range += SafetyMargin;
        //    return Actor.Sensor.IsGameObjectHasLineOfSightToMapPosition(Actor.transform.position, direction, range);
        //}

        private void UpdateInventoryKnowledge()
        {
            //garder meilleur bag, helmet,vest,boost,heal dans l'inventaire
            if (Actor.AIInventory.ListInventory != null)
            {
                Item item = null;
                foreach (ObjectContainedInventory cell in Actor.AIInventory.ListInventory)
                {
                    item = cell.GetItem();

                    switch (item.Type)
                    {
                    case ItemType.Helmet:
                        if (inventoryBestHelmet == null)
                        {
                            InventoryBestHelmet = cell;
                        }
                        else
                        {
                            Helmet helmet = (Helmet)item;
                            if (((Helmet)inventoryBestHelmet.GetItem()).ProtectionValue < helmet.ProtectionValue)
                            {
                                InventoryBestHelmet = cell;
                            }
                        }
                        break;

                    case ItemType.Vest:
                        if (inventoryBestVest == null)
                        {
                            InventoryBestVest = cell;
                        }
                        else
                        {
                            Vest vest = (Vest)item;
                            if (((Vest)inventoryBestVest.GetItem()).ProtectionValue < vest.ProtectionValue)
                            {
                                InventoryBestVest = cell;
                            }
                        }
                        break;

                    case ItemType.Bag:
                        if (inventoryBestBag == null)
                        {
                            InventoryBestBag = cell;
                        }
                        else
                        {
                            Bag bag = (Bag)item;
                            if (((Bag)inventoryBestBag.GetItem()).Capacity < bag.Capacity)
                            {
                                InventoryBestBag = cell;
                            }
                        }
                        break;

                    case ItemType.Heal:
                        if (inventoryBestHeal == null)
                        {
                            InventoryBestHeal = cell;
                        }
                        else
                        {
                            Heal heal = (Heal)item;
                            if (((Heal)inventoryBestHeal.GetItem()).Efficacity < heal.Efficacity)
                            {
                                InventoryBestHeal = cell;
                            }
                        }
                        break;

                    case ItemType.Boost:
                        if (inventoryBestBoost == null)
                        {
                            InventoryBestBoost = cell;
                        }
                        else
                        {
                            Boost boost = (Boost)item;
                            if (((Boost)inventoryBestBoost.GetItem()).Efficacity < boost.Efficacity)
                            {
                                InventoryBestBoost = cell;
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
        }