IEnumerator SpawnRoutine(float delay)
        {
            yield return(new WaitForSecondsRealtime(delay));

            float      colliderDetectionRadius = harvestableEntity.colliderDetectionRadius;
            Vector3    spawnPosition           = GetRandomPosition();
            Quaternion spawnRotation           = GetRandomRotation();
            bool       overlapEntities         = false;

            Collider[] overlaps = Physics.OverlapSphere(spawnPosition, colliderDetectionRadius);
            foreach (Collider overlap in overlaps)
            {
                if (overlap.gameObject.layer == gameInstance.characterLayer ||
                    overlap.gameObject.layer == gameInstance.itemDropLayer ||
                    overlap.gameObject.layer == gameInstance.buildingLayer ||
                    overlap.gameObject.layer == gameInstance.harvestableLayer)
                {
                    overlapEntities = true;
                    break;
                }
            }
            if (!overlapEntities)
            {
                GameObject        spawnObj = Instantiate(harvestableEntity.gameObject, spawnPosition, spawnRotation);
                HarvestableEntity entity   = spawnObj.GetComponent <HarvestableEntity>();
                entity.SetSpawnArea(this, spawnPosition);
                BaseGameNetworkManager.Singleton.Assets.NetworkSpawn(spawnObj);
            }
            else
            {
                ++pending;
                Debug.LogWarning("[HarvestableSpawnArea(" + name + ")] Cannot spawn harvestable it is collided to another entities, pending harvestable amount " + pending);
            }
        }
        protected void SetTargetHarvestable(HarvestableEntity harvestable)
        {
            if (uiTargetHarvestable == null)
            {
                return;
            }

            if (harvestable == null)
            {
                uiTargetHarvestable.Hide();
                return;
            }

            uiTargetHarvestable.Data = harvestable;
            uiTargetHarvestable.Show();
        }
Esempio n. 3
0
        public override void OnHarvestableReceivedDamage(BaseCharacterEntity attacker, HarvestableEntity damageReceiver, CombatAmountType combatAmountType, int damage)
        {
            var decreaseWeaponDurability = normalDecreaseWeaponDurability;
            var decreaseShieldDurability = normalDecreaseShieldDurability;
            var decreaseArmorDurability  = normalDecreaseArmorDurability;

            GetDecreaseDurabilityAmount(combatAmountType, out decreaseWeaponDurability, out decreaseShieldDurability, out decreaseArmorDurability);
            // Decrease Weapon Durability
            DecreaseEquipWeaponsDurability(attacker, decreaseWeaponDurability);
        }
Esempio n. 4
0
 public abstract void OnHarvestableReceivedDamage(BaseCharacterEntity attacker, HarvestableEntity damageReceiver, CombatAmountType combatAmountType, int damage);