Ejemplo n.º 1
0
    public void SpawnObject()
    {
        ICommand cmd = new SpawnObjectCommand();

        cmd.execute(templateToCopy, objectGhost.transform.position, objectGhost.transform.rotation);
        m_undoStack.Push(cmd);
        m_redoStack.Clear();
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Executes the building logic.
    /// </summary>
    public override void Execute()
    {
        if (_XYLogic.inputFieldX.text == "" || _XYLogic.inputFieldY.text == "")
        {
            return;
        }

        SpawnObjectCommand command = new SpawnObjectCommand(Properties.buildings[(int)_buildingType], _buildingType, -15 + _XYLogic.x * 9, 5 + _XYLogic.y * 9);

        command.Execute();
    }
Ejemplo n.º 3
0
    void SpawnInstance(int index)
    {
        Ray ray = Camera.main.ViewportPointToRay(new Vector2(.5f, .5f));
        int roomBoundsMask = (1 << LayerMask.NameToLayer("RoomBounds"));

        RaycastHit hit; Vector3? spawnPosition = null;
        if(Physics.Raycast(ray, out hit, Mathf.Infinity, roomBoundsMask))
        {
            spawnPosition = hit.point;
        }

        index = Mathf.Clamp(index, 0, _assetsToSpawn.Length - 1);
        SpawnObjectCommand command = new SpawnObjectCommand(_assetsToSpawn[index], spawnPosition);
        UndoManager.GetInstance().Do(command);
    }
Ejemplo n.º 4
0
 protected void SpawnObjectCommandHandler(SpawnObjectCommand cmd)
 {
     cmd.result = _server.SpawnObject(cmd.spawnHandlerID);
 }