Exemple #1
0
    private void InitializeWorldGrid()
    {
        //0,0,0 is the center
        for (int k = (int)Mathf.Ceil((Math.Abs(zSize) / -2f)); k < (int)Mathf.Ceil((Math.Abs(zSize) / 2f)); k++)
        {
            for (int j = (int)Mathf.Ceil((Math.Abs(ySize) / -2f)); j < (int)Mathf.Ceil((Math.Abs(ySize) / 2f)); j++)
            {
                for (int i = (int)Mathf.Ceil((Math.Abs(xSize) / -2f)); i < (int)Mathf.Ceil((Math.Abs(xSize) / 2f)); i++)
                {
                    GridBlock gridBlock = new GridBlock(i, j, k);

                    if (isServer)
                    {
                        GameObject      gameObject = (GameObject)Instantiate(blockPrefab, GridToWorldCoordinates(i, j - 1, k), Quaternion.identity);
                        PlaceableObject plObject   = gameObject.GetComponent <PlaceableObject>();
                        plObject.OccupyingSlot = PlaceableObject.Slot.Whole_Block;
                        gridBlock.AddObject(gameObject);
                        NetworkServer.Spawn(gameObject);
                    }

                    grid.Add(new Vector3(i, j, k), gridBlock);
                }
            }
        }
    }
Exemple #2
0
    public void Select()
    {
        GameObject Canvas = GameObject.Find("BuilderGUICanvas(Clone)");

        //If you've clicked on a UI element then you didn't mean to click the terrain
        for (int i = 0; i < Canvas.transform.childCount; i++)
        {
            if (Canvas.transform.GetChild(i).name == "RR")
            {
                break;                                              //because RR covers the whole screen
            }
            RectTransform RT           = Canvas.transform.GetChild(i).GetComponent <RectTransform>();
            Vector3[]     worldCorners = new Vector3[4];
            RT.GetWorldCorners(worldCorners);
            if (Input.mousePosition.x >= worldCorners[0].x && Input.mousePosition.x < worldCorners[2].x &&
                Input.mousePosition.y >= worldCorners[0].y && Input.mousePosition.y < worldCorners[2].y)
            {
                return;
            }
        }
        foreach (PlaceableObject p in Scenery.Instance.Objects)
        {
            p.HideAllGizmos();
            p.DeselectClickColliders();
        }
        try { BezCtrlPt.Current.goRdMkr.GetComponent <RoadMarker>().Gizmo.SetActive(false); }
        catch { }
        Toolbox = Canvas.GetComponent <ToolboxController>();
        Toolbox.SetToolToggle("Scenery", false);
        ShowGizmo(Toolbox.Gizmo);
        Current = this;
        SelectClickColliders();
    }
 public void DeleteObjectOnMouse()
 {
     if (!objectOnMouse.isInit)
     {
         Destroy(objectOnMouse.gameObject);
         objectOnMouse   = null;
         isMouseOccupied = false;
     }
     else
     {
         if (objectOnMouse is Robot)
         {
             SimManager.instance.RemoveRobotFromScene(objectOnMouse as Robot);
         }
         else if (objectOnMouse is WorldObject)
         {
             SimManager.instance.RemoveWorldObjectFromScene(objectOnMouse as WorldObject);
         }
         else if (objectOnMouse is Marker)
         {
             SimManager.instance.RemoveMarkerFromScene(objectOnMouse as Marker);
         }
         else
         {
             Debug.Log("Delete on mouse failed");
             return;
         }
         objectOnMouse   = null;
         isMouseOccupied = false;
     }
 }
        public override IEnumerator Start()
        {
            PlaceableObject target  = null;
            var             targets = EnemyAI.ObjectManager.placeableObjects;
            var             distanceToClosestTarget = Mathf.Infinity;

            foreach (var possibleTarget in targets)
            {
                if (possibleTarget.GetComponent <HomeBase>() != null && EnemyAI.attackHomebase)
                {
                    target = possibleTarget.GetComponent <PlaceableObject>();
                    break;
                }

                var distanceToPossibleTarget = Vector3.Distance(EnemyAI.transform.position, possibleTarget.position);
                if (distanceToPossibleTarget <= distanceToClosestTarget)
                {
                    target = possibleTarget.GetComponent <PlaceableObject>();
                    distanceToClosestTarget = distanceToPossibleTarget;
                }
            }
            EnemyAI.target = target;
            EnemyAI.SetAIState(new NavToTarget(EnemyAI));

            yield break;
        }
Exemple #5
0
        public static PlayerRoomLayout FromPlaceableObjects(List <PlaceableObject> placeableObjects)
        {
            List <CompoundRoomItem> list = new List <CompoundRoomItem>(placeableObjects.Count);

            while (placeableObjects.Count > 0)
            {
                PlaceableObject placeableObject = placeableObjects[0];
                placeableObjects.Remove(placeableObject);
                if (placeableObject.PieceNumber == 1)
                {
                    List <PlaceableObject> list2 = new List <PlaceableObject>();
                    list2.Add(placeableObject);
                    while (placeableObject.Next != null)
                    {
                        list2.Add(placeableObject.Next);
                        placeableObjects.Remove(placeableObject.Next);
                        placeableObject = placeableObject.Next;
                    }
                    list.Add(CompoundRoomItem.FromPlaceableObjects(list2));
                }
            }
            PlayerRoomLayout playerRoomLayout = new PlayerRoomLayout();

            playerRoomLayout._compoundRoomItems = list;
            return(playerRoomLayout);
        }
 // ---- Add Objects -----
 public void AddObjectToSceneAtPos(PlaceableObject newObj, float x, float y, float phi, Color color)
 {
     newObj.objectID           = totalObjects++;
     newObj.transform.position = new Vector3(x / Eyesim.Scale, newObj.defaultVerticalOffset, y / Eyesim.Scale);
     newObj.transform.rotation = Quaternion.Euler(new Vector3(0f, Eyesim.UnityToEyeSimAngle(phi), 0f));
     newObj.isInit             = true;
     if (newObj is Robot)
     {
         SimManager.instance.AddRobotToScene(newObj as Robot);
     }
     else if (newObj is WorldObject)
     {
         SimManager.instance.AddWorldObjectToScene(newObj as WorldObject);
     }
     else if (newObj is Marker)
     {
         SimManager.instance.AddMarkerToScene(newObj as Marker);
         newObj.transform.rotation = Quaternion.Euler(new Vector3(90f, 0f, 0f));
         (newObj as Marker).SetColor(color);
     }
     else
     {
         Debug.Log("Error adding objects: Unknown type");
         Destroy(newObj.gameObject);
     }
 }
Exemple #7
0
    public bool PlaceObject(Vector2 position)
    {
        if (currentObject == null)
        {
            return(false);
        }

        CellIndex tile = levelScript.Grid.GetCellIndex(currentObject.transform.position);

        if (levelScript.Grid.CellIsEmpty(tile))
        {
            if (currentObject.IsType <Wall>())
            {
                wallPlacer.PlaceWall((Wall)currentObject);
            }
            else
            {
                levelScript.Grid.AddObjectToCell(currentObject, currentObject.transform.position);
            }

            currentObject = null;
            return(true);
        }
        else
        {
            Debug.Log("Cannot place there!");
            return(false);
        }
    }
        public PlaceableObject GetNearestFactory(Waypoint waypoint)
        {
            float                  closestWaypontDistance = Mathf.Infinity;
            PlaceableObject        closestWaypoint        = null;
            List <PlaceableObject> factoriesCleaned       = new List <PlaceableObject>();

            foreach (PlaceableObject factory in objectManager.factories)
            {
                if (factory == null)
                {
                    continue;
                }
                factoriesCleaned.Add(factory);
            }

            foreach (PlaceableObject factory in factoriesCleaned)
            {
                var currentComparison = Vector3.Distance(factory.GetWaypoint().transform.position, waypoint.transform.position);
                if (currentComparison < closestWaypontDistance)
                {
                    closestWaypontDistance = currentComparison;
                    closestWaypoint        = factory;
                }
            }
            return(closestWaypoint);
        }
Exemple #9
0
        PlaceableObject GenerateObject(
            int width, int height, params int[] roomsIn)
        {
            var placeableObject = new PlaceableObject(width, height, roomsIn.ToList());

            return(placeableObject);
        }
        private void InstantiateNewObject(Waypoint waypoint)
        {
            if (!waypoint.isPlaceable)
            {
                Debug.Log("Waypoint: " + waypoint + " is not placeable");
                return;
            }
            PlaceableObject newPlaceableObject = Instantiate(placeableObject, waypoint.transform.position, Quaternion.identity);

            newPlaceableObject.transform.parent = transform;
            newPlaceableObject.SetWaypoint(waypoint);
            factoryQueue.Enqueue(newPlaceableObject);
            waypoint.isPlaceable = false;
            newPlaceableObject.GetComponent <Collider>().enabled = true;
            //waypoint.isRoad = true;

            objectManager.placeableObjects.Add(newPlaceableObject.transform);
            if (newPlaceableObject.GetComponent <Factory>())
            {
                objectManager.factories.Add(newPlaceableObject);
            }
            if (newPlaceableObject.GetComponent <HomeBase>())
            {
                objectManager.factories.Add(newPlaceableObject);
                newPlaceableObject.GetComponent <HomeBase>().isHomebase = true;
                LevelManager.Instance.SetState(State.Game);
                FindObjectOfType <GameUIHandler>().SetButtonsDefaultColor();
                SetActivePlaceableObject(null);
            }
            if (newPlaceableObject.GetComponent <Blocker>())
            {
                objectManager.blockers.Add(newPlaceableObject.transform);
            }
        }
Exemple #11
0
		public static RoomItem FromPlaceableObject(PlaceableObject placeableObject)
		{
			RoomItem roomItem = new RoomItem();
			roomItem.pieceNumber = placeableObject.PieceNumber;
			roomItem.worldTransform = WorldTransform.FromTransform(placeableObject.transform);
			return roomItem;
		}
    public void TryPlaceObject()
    {
        // Determine final validitiy of placement option
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        bool valid = objectOnMouse.updateValidity(Physics.Raycast(ray, out hit, Eyesim.Scale, groundMask));

        if (valid && canPlaceObject)
        {
            // If it is new object, add to sim manager
            if (!objectOnMouse.isInit)
            {
                if (objectOnMouse is Robot)
                {
                    SimManager.instance.AddRobotToScene(objectOnMouse as Robot);
                }
                else if (objectOnMouse is WorldObject)
                {
                    SimManager.instance.AddWorldObjectToScene(objectOnMouse as WorldObject);
                }
                else if (objectOnMouse is Marker)
                {
                    SimManager.instance.AddMarkerToScene(objectOnMouse as Marker);
                }
            }
            // Place object physically
            objectOnMouse.PlaceObject();
            objectOnMouse   = null;
            canPlaceObject  = false;
            isMouseOccupied = false;
        }
    }
	// Update is called once per frame
	void Update () {
		Rect screenRect = new Rect(0, 0, Screen.width, Screen.height);
		if(screenRect.Contains(Input.mousePosition) && currentObject != null){
			//Returns a ray going from camera through a screen point.
			//Input.mousePosition gives us our current mouse position in pixel coordinates
			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			
			//This object will allow us to get information on the collider our ray hits.
			RaycastHit hit;

			//This if statement will only execute if the raycast hits into something
			if(Physics.Raycast (ray, out hit)){

				//If our mouse is over a platform
				if(hit.collider.tag == "Platform")
				{
					if(!placed)
						currentObject.transform.position = hit.point;

					if(Input.GetMouseButtonDown(0)){
						placed = true;
						currentObject.GetComponent<PlaceableObject>().isPlaced = true;
					}

					if(Input.GetMouseButtonUp(0)){
						GameState.Instance.windmillAmount++;
						currentObject = null;
						placed = false;
					}
				}
			}
		}
	}
Exemple #14
0
        private String PlaceableObjectData(PlaceableObject po)
        {
            StringBuilder text = new StringBuilder();

            if (po == null)
            {
                return(text.ToString());
            }
            text.Append("\n\n-----PlaceableObject Data-----\n");
            text.Append("\nbDezone: ").Append(po.bDezone);
            text.Append("\nbWriteToMapCache: ").Append(po.bWriteToMapCache);
            text.Append("\nCanBeDestroyed: ").Append(po.CanBeDestroyed);
            text.Append("\ncollectionIndex: ").Append(po.collectionIndex);
            text.Append("\nconstructionDuration: ").Append(po.constructionDuration);
            text.Append("\nconstructionState: ").Append(po.constructionState);
            text.Append("\nconstructionType: ").Append(po.constructionType);
            text.Append("\nCreatePrice: ").Append(po.CreatePrice);
            text.Append("\nfacingConfig: ").Append(FacingConfigData(po.facingConfig));
            text.Append("\nheight: ").Append(po.height);
            text.Append("\nHidden: ").Append(po.Hidden);
            text.Append("\nHourlyPrice: ").Append(po.HourlyPrice);
            text.Append("\niprefab: ").Append(po.iprefab);
            text.Append("\nIsCrosswalk: ").Append(po.IsCrosswalk);
            text.Append("\nisDestroyable: ").Append(po.isDestroyable);
            text.Append("\nisFootprintSet: ").Append(po.isFootprintSet);
            text.Append("\nisPseudoWall: ").Append(po.isPseudoWall);
            text.Append("\nMaxAllowed: ").Append(po.MaxAllowed);
            text.Append("\nMyZeroAllocName: ").Append(po.MyZeroAllocName);
            text.Append("\nPieceCountTotal: ").Append(po.PieceCountTotal);
            text.Append("\nPlacementSound: ").Append(po.PlacementSound);
            text.Append("\nplacementVOffset: ").Append(po.placementVOffset);
            text.Append("\nprefab: ").Append(po.prefab);
            text.Append("\nrequiresSectorRebuild: ").Append(po.requiresSectorRebuild);
            text.Append("\nrequiresSecureArea: ").Append(po.requiresSecureArea);
            text.Append("\nrotateType: ").Append(po.rotateType);
            text.Append("\nSector: -----\n").Append(po.Sector).Append("\nEnd Sector-----");
            text.Append("\nsnapToGridSize: ").Append(po.snapToGridSize);
            text.Append("\nVerticalHeight: ").Append(po.VerticalHeight);
            text.Append("\nwidth: ").Append(po.width);
            text.Append("\nfacing: ").Append(po.facing);
            text.Append("\nisBuilt: ").Append(po.isBuilt);
            text.Append("\nisPlaced: ").Append(po.isPlaced);
            text.Append("\nMarkers: ");
            foreach (Marker mo in po.Markers())
            {
                text.Append(MarkerData(mo));
            }
            text.Append("\n:Inspect(): ").Append(po.Inspect()).Append("\nEnd Inspect()-----\n");
            text.Append("\nOddRotation: ").Append(po.OddRotation());
            text.Append("\neffectEmitter: ").Append(EffectEmitterData(po.effectEmitter));
            text.Append("\nmaintainable: ").Append(MaintainableData(po.maintainable));
            text.Append("\nfootprint: ").Append(RectData(po.footprint));
            text.Append("\nrendererRect: ").Append(RectData(po.rendererRect));
            text.Append("\nOriginalPosition: ");
            text.Append("\n\tx").Append(po.OriginalPosition.x);
            text.Append("\n\ty").Append(po.OriginalPosition.y);
            text.Append("\n\tz").Append(po.OriginalPosition.z);

            return(text.ToString());
        }
    private GameObject InstantiateNewObject(PlaceableObject objectToPlace, Vector3 position, Quaternion rotation, Tile objectTile)
    {
        GameObject newObject = Instantiate(objectToPlace.gameObject, position, rotation, objectParent);

        levelManager.AddObjectToLists(newObject);

        //pathingGraph.UpdateGrapthBounds(objectToPlace.GetObjectBounds());

        if (CheckIfMachineOrPlaceable(ObjectToPlace))
        {
            economyManager.OnMachinePurchase(ObjectToPlace as Machine);
        }
        else
        {
            economyManager.OnBuildingPartPurchase(ObjectToPlace);
        }
        PlaceableObject newPlaceableObject = newObject.GetComponent <PlaceableObject>();

        newPlaceableObject.PlacedOnTile = objectTile;
        newPlaceableObject.PrefabName   = objectToPlace.name;
        objectTile.SetIfPlacedOn(true);

        levelManager.GetLevelCamera().SetRotationLock(false);

        return(newObject);
    }
Exemple #16
0
    public void CreateObjectToPlace(GameObject placeableObjectPrefab)
    {
        if (ObjecTransform != null)
        {
            CancelPlacement();
        }

        PlaceableObject placeableObject = placeableObjectPrefab.GetComponent <PlaceableObject>();

        if (StoreManager.Singleton.Money < placeableObject.Price)
        {
            //Not enough money
            UIManager.Singleton.ShowMessage("Not enough money!", "Not enough money to buy this " + placeableObject.Name + "!");
            return;
        }

        TutorialManager.Singleton.OnStartPlacingObject();
        GameObject newObject = (GameObject)Instantiate(placeableObjectPrefab);

        newObject.name = placeableObject.Name;
        ObjecTransform = newObject.transform;
        PlacingObject  = true;
        ObjectPrice    = placeableObject.Price;

        UIManager.Singleton.EnableControlsPanel(true);

        foreach (var tile in StoreManager.Singleton.FloorTiles)
        {
            if (tile.CanPlaceObjectHere)
            {
                tile.GetComponent <Renderer>().material = tile.GreenMaterial;
            }
        }
    }
Exemple #17
0
    private void InstantiateObject()
    {
        PlaceableObject objectData = TerrainController.Biomes[spawnPoints[PlacingIndex].ObjectPoolIndex.x].PlaceableObjects[spawnPoints[PlacingIndex].ObjectPoolIndex.y];
        int prefabIndex = Random.Range(0, objectData.Prefabs.Length);

        // Helpful error codes
        if (objectData.Prefabs.Length == 0)
        {
            Debug.LogError("Prefab array's length is zero at: " + "Region " + spawnPoints[PlacingIndex].ObjectPoolIndex.x + " PlaceableObject " + spawnPoints[PlacingIndex].ObjectPoolIndex.y);

            return;
        }
        else if (!spawnPoints[PlacingIndex].Prefabs[prefabIndex])
        {
            Debug.LogError("Prefab missing from: Region " + spawnPoints[PlacingIndex].ObjectPoolIndex.x + " PlaceableObject " + spawnPoints[PlacingIndex].ObjectPoolIndex.y + " Prefab " + prefabIndex);

            return;
        }

        if (Physics.Raycast(spawnPoints[PlacingIndex].Position, Vector3.down, out RaycastHit hit) && PlacingConditionsApply(hit, objectData) && spawnPoints[PlacingIndex].Prefabs[prefabIndex])
        {
            GameObject instantiatedObject = Instantiate(spawnPoints[PlacingIndex].Prefabs[prefabIndex],
                hit.point, Quaternion.identity, TerrainController.PoolObjectParent);

            ApplyTransform(instantiatedObject.transform, hit, objectData, prefabIndex);

            MoveObjectToPool(instantiatedObject, spawnPoints[PlacingIndex].ObjectPoolIndex);

            objectsOnTile.Add(instantiatedObject);
        }

        PlacingIndex++;
    }
    private void OnButtonClicked(PlaceableObjectButton clickedButton)
    {
        //Makes that only the button of the selected object is shown as selected
        PlaceableObject previewedObject = null;

        foreach (var button in _placeableObjectButtons)
        {
            if (button.Key == clickedButton && button.Key.Toggled)
            {
                previewedObject = button.Key.Prefab;
            }

            //Deactivate other buttons if needed
            if (button.Key != clickedButton && button.Key.Toggled)
            {
                button.Key.Toggle(false);
            }
        }

        Texture2D previewTexture = null;

        if (previewedObject != null)
        {
            previewTexture = previewedObject.Preview;
        }
        SetPreviewImage(previewTexture);
    }
    public void EnterBuildMode(PlaceableObject obj)
    {
        panel.SetActive(true);
        image.sprite         = obj.sprite;
        nameText.text        = obj.buildingName;
        descriptionText.text = obj.description;

        gold.SetActive(false);
        wood.SetActive(false);
        stone.SetActive(false);
        copper.SetActive(false);
        food.SetActive(false);

        if (obj.cost.gold > 0)
        {
            string resText = obj.cost.gold.ToString();
            if (obj.cost.gold > gameData.resources.gold)
            {
                resText = "<color=#ff0000ff>" + obj.cost.gold.ToString() + "</color>";
            }
            SetCostFor(gold, resText);
        }
        if (obj.cost.wood > 0)
        {
            string resText = obj.cost.wood.ToString();
            if (obj.cost.wood > gameData.resources.wood)
            {
                resText = "<color=#ff0000ff>" + obj.cost.wood.ToString() + "</color>";
            }
            SetCostFor(wood, resText);
        }
        if (obj.cost.stone > 0)
        {
            string resText = obj.cost.stone.ToString();
            if (obj.cost.stone > gameData.resources.stone)
            {
                resText = "<color=#ff0000ff>" + obj.cost.stone.ToString() + "</color>";
            }
            SetCostFor(stone, resText);
        }
        if (obj.cost.copper > 0)
        {
            string resText = obj.cost.copper.ToString();
            if (obj.cost.copper > gameData.resources.copper)
            {
                resText = "<color=#ff0000ff>" + obj.cost.copper.ToString() + "</color>";
            }
            SetCostFor(copper, resText);
        }
        if (obj.cost.food > 0)
        {
            string resText = obj.cost.food.ToString();
            if (obj.cost.food > gameData.resources.food)
            {
                resText = "<color=#ff0000ff>" + obj.cost.food.ToString() + "</color>";
            }
            SetCostFor(food, resText);
        }
    }
Exemple #20
0
 public void NewObjectSelected(PlaceableObject newObj)
 {
     objectName.text = newObj.name;
     objectID.text   = newObj.objectID.ToString();
     objectMass.text = newObj.rigidBody.mass.ToString();
     objectXPos.text = newObj.transform.position.x.ToString();
     objectYPos.text = newObj.transform.position.z.ToString();
 }
Exemple #21
0
 public void SetCurrentObject(PlaceableObject obj)
 {
     if (currentObject != null)
     {
         Object.Destroy(currentObject.gameObject);
     }
     currentObject = obj;
 }
    // ----- Handle placement of object via mouse -----

    public void AddObjectToMouse(PlaceableObject newObject, float vert)
    {
        objectOnMouse  = newObject;
        verticalOffset = vert;
        newObject.AttachToMouse();
        isMouseOccupied = true;
        StartCoroutine(DelayPlacement());
    }
Exemple #23
0
 private void CreatePlaceableObject()
 {
     if (_tray != null)
     {
         _activeObject = Instantiate(Prefab, _tray, false);
         _activeObject.Initialize(_guideLinePrefab);
     }
 }
 private void UpdateUI(PlaceableObject currentObject)
 {
     interactableMachineMenu.SetActive(false);
     objectName.text        = currentObject.Name1;
     objectCost.text        = currentObject.BuyCost.ToString();
     objectDescription.text = currentObject.Description;
     icon.sprite            = currentObject.Icon;
 }
 public bool RemoveObject()
 {
     if (IsTileEmpty())
     {
         return(false);
     }
     PlacedObject = null;
     return(true);
 }
 public bool PlaceObject(PlaceableObject objectToPlaceOnTile)
 {
     if (IsTileEmpty())
     {
         PlacedObject = objectToPlaceOnTile;
         return(true);
     }
     return(false);
 }
 void CreateCharacter()
 {
     if (currChar == null)
     {
         currChar = Instantiate(charPref) as GameObject;
         PlaceableObject po = currChar.GetComponent <PlaceableObject> ();
         po.OnSelect();
     }
 }
Exemple #28
0
    public void PlaceObjectfromSO(SerializableObject so)
    {
        GameObject      go       = GameObject.Instantiate(gameData.availableObjects[SearchIdByNameIn(so.name, gameData.availableObjects)]);
        PlaceableObject building = go.GetComponent <PlaceableObject>();

        building.gameData = gameData;
        building.type     = so.type;
        building.InitializeWithSO(so);
    }
 public void SetActivePlaceableObject(PlaceableObject placeableObjectPrefab)
 {
     placeableObject = placeableObjectPrefab;
     if (hoverPlaceableObject != null)
     {
         Destroy(hoverPlaceableObject.gameObject);
         hoverPlaceableObject = null;
     }
 }
Exemple #30
0
    public void AddCylinderToScene()
    {
        PlaceableObject newCyl = Instantiate(placeableCylinder).GetComponent <PlaceableObject>();

        newCyl.PostBuild();
        newCyl.objectID = totalObjects;
        totalObjects++;
        AddObjectToMouse(newCyl);
    }
    private void UpdateIndicators()
    {
        //Show the indicators for the current viable targets.
        bool activateIndicators = !Completed && PlaceableObject.ActiveModelAvailable(ModelName);

        foreach (var indicator in _indicators)
        {
            indicator.gameObject.SetActive(activateIndicators);
        }
    }
Exemple #32
0
	public void SetItem(GameObject b){
		hasPlaced = false;
		currentObject = ((GameObject)Instantiate(b)).transform;
		placeableObject = currentObject.GetComponent<PlaceableObject>();
	}
 public void SetItem(GameObject item)
 {
     hasPlaced = false;
     currentObject = Instantiate(item).transform;
     placeableObject = currentObject.gameObject.GetComponent<PlaceableObject>();
 }
        /// <summary>
        /// Handles the place object button click.
        /// Put the values of the placable object into the text list,
        /// and added a new placable object to the context.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void placeButton_Click(object sender, System.EventArgs e)
        {
            PlaceableObject.Shape objectShape = (PlaceableObject.Shape)objectSelect.SelectedItem;
            int positionX = int.Parse(posX.Text);
            int positionY = int.Parse(posY.Text);
            int sizeHeight = int.Parse(sizeH.Text);
            int sizeWidth = sizeHeight;
            if (objectShape == PlaceableObject.Shape.Rectangle)
            {
                sizeWidth = int.Parse(sizeW.Text);
            }

            PlaceableObject placeableObject = new PlaceableObject(objectShape, positionX, positionY, sizeHeight, sizeWidth);

            context.addPlacableObject(placeableObject);
            putVisibleObjectToGlControl(placeableObject);
        }
 /// <summary>
 /// Put the values of the placable object into the text list.
 /// </summary>
 /// <param name="placeableObject"></param>
 private void putVisibleObjectToGlControl(PlaceableObject placeableObject)
 {
     checkedListBox1.Items.Add(placeableObject);
 }