コード例 #1
0
        //returns true if spawned successfully
        private bool SpawnObject(SpaceOccupier newObject)
        {
            int     containerIndex = 0;
            Vector3 spawnPosition  = spawnPoint.position;

            while (containerIndex < containers.Length)
            {
                EquipmentContainer container = containers[containerIndex];
                if (container.Capacity.y >= newObject.Volume.y)
                {
                    spawnPosition.y = container.transform.position.y + newObject.Volume.y * 0.5f;
                    newObject.transform.position = spawnPosition;
                    Equipment equipment = newObject.GetComponent <Equipment>();
                    equipment.Initialize(container);
                    onEquipmentSpawned?.Invoke(equipment.gameObject);
                    return(true);
//                    break;
                }
                containerIndex++;
                if (containerIndex >= containers.Length)
                {
                    Destroy(newObject.gameObject);
                    return(false);
                }
            }
            return(true);
        }
コード例 #2
0
        public void PlaceInIronBox(Equipment equipment)
        {
            SpaceOccupier ironBox = Instantiate(ironBoxPrefab);

            equipment.GetComponent <Collider>().enabled = false;
            equipment.GetComponent <BoundingBoxRenderer>().Hide();
            ironBox.transform.position = equipment.transform.position;
            equipment.transform.parent = ironBox.transform;
            ironBox.transform.rotation = equipment.transform.rotation;
            ironBox.transform.position = Utility.KeepPositionInsideContainer(ironBox, equipment.transform.position, equipment.currentContainer);
            equipment.currentContainer.OccupySpace(ironBox);
            ironBox.GetComponent <DeleteableGameObject>().onDelete.AddListener(OnIronBoxDeleted);
        }
コード例 #3
0
        public void SpawnFuelTank()
        {
            SpaceOccupier newFuelTank = Instantiate <SpaceOccupier>(fuelTankPrefab);

            newFuelTank.GetComponent <DeleteableGameObject>().onDelete.AddListener(OnFuelTankDeleted);
            if (SpawnObject(newFuelTank))
            {
                onFuelTankSpawned?.Invoke();
            }
            else
            {
                onSpawnFailed?.Invoke();
            }
        }
コード例 #4
0
        public void SpawnBoltCutter()
        {
            SpaceOccupier newBoltCutter = Instantiate <SpaceOccupier>(boltCutterPrefab);

            newBoltCutter.GetComponent <DeleteableGameObject>().onDelete.AddListener(OnBoltCutterDeleted);
            if (SpawnObject(newBoltCutter))
            {
                onBoltCutterSpawned?.Invoke();
            }
            else
            {
                onSpawnFailed?.Invoke();
            }
        }