コード例 #1
0
        //Pour AI seulement
        //Calcul la quantité total d'un type objet
        //ex: toutes les helmet peu importe leur force du helmet
        public int GetItemQuantityInInventory(ItemType itemType, AmmoType ammoType)
        {
            Item item     = null;
            int  quantity = 0;

            if (ListInventory != null)
            {
                foreach (ObjectContainedInventory cell in ListInventory)
                {
                    if (cell != null)
                    {
                        item = cell.GetItem();
                        if (item != null && item.Type == itemType)
                        {
                            if (itemType != ItemType.AmmoPack)
                            {
                                quantity += cell.GetCompteur();
                            }
                            else
                            {
                                AmmoPack ammoPack = item as AmmoPack;
                                if (ammoType == ammoPack.AmmoType)
                                {
                                    quantity += cell.GetCompteur();
                                }
                            }
                        }
                    }
                }
            }
            return(quantity);
        }
コード例 #2
0
        public static void CreateItem(List <GameObject> itemList, Vector3 spawnPoint, System.Random random, AmmoType ammoType)
        {
            GameObject gameObject = SpawnObject(spawnPoint, AmmoPackPrefab[(int)ammoType]);

            AmmoPack ammoPack = gameObject.GetComponent <AmmoPack>();

            ammoPack.AmmoType = ammoType;

            int item = random.Next(0, 101);

            if (item >= Range1.x && item < Range1.y)
            {
                ammoPack.NumberOfAmmo = 30;
            }
            else if (item >= Range2.x && item < Range2.y)
            {
                ammoPack.NumberOfAmmo = 60;
            }
            else if (item >= Range3.x && item < Range3.y)
            {
                ammoPack.NumberOfAmmo = 90;
            }

            itemList.Add(gameObject);
        }
コード例 #3
0
        private float EvaluateAmmoPackValue(float distanceToItem, Item item)
        {
            float ammoPackValueLevel = 0.0f;
            //si on a la weapon augmente value selon force weapon???
            AmmoPack ammoPack = (AmmoPack)item;

            ammoPackValueLevel = AmmoPackGoalFactor * (1 - actor.Brain.GetAmmoPackStorageRatio(ammoPack.AmmoType)) / distanceToItem;
            return(ammoPackValueLevel);
        }