Ejemplo n.º 1
0
    public void AttemptToPlace()
    {
        if (!GameManager.instance.TryTakeMoney(attemptingToPlace.cost))
        {
            CleanCursor();
            return;
        }

        Placeable placeable = onCursor.GetComponent <Placeable>();
        TeamEnum  team      = GameManager.instance.currentTeam;

        if (placeable.GetType() == typeof(Building))
        {
            Building building = (Building)placeable;
            building.Place(team);
        }
        else
        {
            placeable.Place(team);
        }



        SetShader("Standard", onCursor.transform.GetChild(0).gameObject);
        attemptingToPlace = null;
    }
Ejemplo n.º 2
0
    private void Update()
    {
        var deltaPercent = DayCycleManager.GetInstance().ClockMinuteRate / 5 * Time.deltaTime * buildSpeed * GetComponent <Assignable>().GetWorkersInRange();

        deltaPercent     = Mathf.Min(deltaPercent, 100 - percentComplete);
        percentComplete += deltaPercent;
        pendingInstance.transform.position += new Vector3(0, (deltaPercent / 100) * DELTA_Y, 0);
        if (percentComplete >= 100)
        {
            pendingInstance.Place();
            Destroy(gameObject);
        }
    }
Ejemplo n.º 3
0
        public void Decorate(Floor floor, MapArea area, IGenerator rng)
        {
            MapArea restrictedArea = new MapArea();

            restrictedArea.Add(area.Positions);
            restrictedArea.Remove(area.Bounds.PerimeterPositions());

            int amount       = Math.Min(rng.Next(MinAmount, MaxAmount + 1), restrictedArea.Count);
            int amountPlaced = 0;

            while (amountPlaced < amount)
            {
                if (Placeable.Place(floor, restrictedArea.RandomPosition(rng), rng))
                {
                    amountPlaced += 1;
                }
            }
        }
    private void PlaceObject(Pose pose)
    {
        if (!objectInstance)
        {
            objectInstance = Instantiate(objectToInstantiate, pose.position, Quaternion.identity);

            objectInstance.SetMoving();
        }
        else
        {
            objectInstance.transform.position = pose.position;
            objectInstance.transform.rotation = pose.rotation;

            if (Input.touches[0].phase == TouchPhase.Ended)
            {
                objectInstance.Place();
                placed = true;
            }
        }
    }
Ejemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            ClearPlacer();
        }
        if (m_objectToPlace)
        {
            m_objectToPlace.IsPlacing(true);

            //Get mouse point
            Vector3 placeLoc = GetPlaceLoc();

            //Show preview -- will show whether it can be placed in that spot or not
            ShowPreview(placeLoc);

            //Snap preview to snappable locations

            //Place object
            //TODO:  make sure placeLoc is in playable bounds
            if (Input.GetMouseButtonDown(0) && !MouseInput.IsPointerOverUIElement())
            {
                //Instantiate(m_objectToPlace).transform.position = placeLoc;
                m_objectToPlace.Place(placeLoc);
            }
        }
        else if (m_destroy)
        {
            GameObject toDestroy = GetObjectAtMouse();
            if (toDestroy && Input.GetMouseButtonDown(0))
            {
                Placeable placeObj = toDestroy.GetComponent <Placeable>();
                if (placeObj)
                {
                    placeObj.DestroyThis();
                }
            }
        }
    }
 protected override void OnDragTool(int cell, int distFromOrigin)
 {
     if (!((Object)visualizer == (Object)null))
     {
         bool          flag      = false;
         EntityPreview component = visualizer.GetComponent <EntityPreview>();
         if (component.Valid)
         {
             if (DebugHandler.InstantBuildMode)
             {
                 source.Place(cell);
             }
             else
             {
                 source.QueuePlacement(cell);
             }
             flag = true;
         }
         if (flag)
         {
             Deactivate();
         }
     }
 }
Ejemplo n.º 7
0
 private void DetachFromCursor()
 {
     _dragObject = false;
     _placeable.Place();
 }